Create and test CentOS LiveCD ISOs on remote server

A Linux Live CD is an optical media that you insert into your drive and it will load the Linux operating system of choice for your use. This article explains how to create a customized CentOS LiveCD ISO using LiveCD tools and how to test it using qemu. All operations was done on CentOS server used for LiveCD development with SSH access enabled.
Prerequisites
The LiveCD project requires some additional RPMs which are not currently hosted by CentOS. You can get access to those packages by configuring an additional yum repository on your system.
Create a file named /etc/yum.repos.d/CentOS-LiveCD.repo and fill it with this content:
# Name: CentOS LiveCD repository
[livecd]
name = CentOS $releasever - LiveCD
baseurl = http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live
enabled=1
protect=0
gpgkey = http://www.nanotechnologies.qc.ca/propos/linux/RPM-GPG-KEY-PGuay
Next step is preparing working dir. All work will be done in the /home/livecd directory:
mkdir /home/livecd
chown root:root /home/livecd
Download files from nanotechnologies. These files will be used for LiveCD creation process:
mkdir -p /home/livecd/repos/propos/linux/centos-live/i386/live/RPMS
cd /home/livecd/repos/propos/linux/centos-live/i386/live/RPMS
wget http://www.nanotechnologies.qc.ca/propos/linux/centos-live/i386/live/RPMS/syslinux-3.82-1.2.i386.rpm
wget http://www.nanotechnologies.qc.ca/propos/linux/centos-live/i386/live/RPMS/perl-Crypt-PasswdMD5-1.3-1.2.1.noarch.rpm
mkdir -p /home/livecd/repos/propos/linux/centos-live/i386/live/repodata
cd /home/livecd/repos/propos/linux/centos-live/i386/live/repodata
wget http://www.nanotechnologies.qc.ca/propos/linux/centos-live/i386/live/repodata/repomd.xml
wget http://www.nanotechnologies.qc.ca/propos/linux/centos-live/i386/live/repodata/primary.xml.gz
Get Live CD Tools and Libs
First of all, install LiveCD Tools using yum:
yum install livecd-tools
The livecd-tools contain the source python scripts that are used to create the ISO.
Download the Fedora LiveCD tools and other applications from the GIT repository:
cd /home/livecd/
git clone git://git.fedoraproject.org/git/hosted/livecd
You should update mksquashfs, because the original mksquashfs package was version 3.0 (2006/08/16). This is incompatible with the version 0.28 livecd tools when run on the build server: mksquashfs version 3 does not allow the -no-progress option and the build fails.
Before of all, install the prerequisites for building a new version of squashfs:
yum install gcc zlib-devel
Upgrading to Version 3.4 is not complicated:
cd ~
mkdir work; cd work
wget http://downloads.sourceforge.net/project/squashfs/squashfs/squashfs3.4/squashfs3.4.tar.gz?use_mirror=voxel
tar xvf squashfs3.4.tar.gz
cd squashfs3.4/squashfs-tools/
make
make install
cd ../../
rm -rf squashfs3.4*
Create LiveCD
Download the kickstart file in raw format and rename it:
wget https://projects.centos.org/trac/livecd/browser/trunk/centos-livecd-minimal.ks?format=raw
mv centos-livecd-minimal.ks?format=raw centos-livecd-minimal.ks
Edit the file to match your needs:
nano -w centos-livecd-minimal.ks
Run validator to check for errors:
ksvalidator centos-livecd-minimal.ks
Create LiveCD:
LANG=C livecd-creator --config=centos-livecd-minimal.ks --fslabel=CentOS-minimal
Test LiveCD
For this you can burn this ISO image to a CD or DVD ROM and test it on a local machine. However, it is much easier to test it with qemu. For this, install qemu and run CentOS iso:
yum install qemu
qemu -cdrom CentOS-minimal.iso -boot
Testing LiveCD could be done remotely, but it is a bit complicated because in console mode you cannot see what is happening during the boot. To see the boot messages when running LiveCD you should edit iso file on your local machine. For this you may use isomaster.
Open the file /isolinux/isolinux.cfg and alter the line:
append initrd=initrd0.img root=CDLABEL=CentOS-minimal rootfstype=iso9660 ro quiet liveimg console=ttyS0
This will redirect console output to /dev/ttyS0, rather than the main virtual console window. You won't see most normal boot messages displayed in the virtual console anymore, but if you wait long enough you should eventually see the normal login prompt.
Once changes are done, save the iso with the name CentOS-minimal-altered.iso and invoke qemu with following options:
qemu -cdrom CentOS-minimal-altered.iso -boot d -nographic -serial tcp::1333,server
Console output will be redirected to QEMU's serial port and outputted to a Telnet session. Option -serial tcp::1235 tells QEMU to wait for connection on host port 1333 before booting up.
Once QEMU begins booting, it will stop and wait for you to connect to serial port. You can use netcat too see the boot messages (see above screenshot):
nc localhost 1333
Recent Comments