Translations of this page:

CentOS Live CD Howto

This CD is based of CentOS 4.4 (http://www.centos.org) In addition to CentOS packages file system drivers unionfs, SquashFS.

The following non-open source software is installed on the LiveCD.

Dell_SAS_RAID_Storage_Manager-1.18-00 (Download Link: ftp://ftp.us.dell.com/sysman/SSM_Linux_1.18-00.tar.gz

	ftp://ftp.dell.com/sysman/SSM_Linux_1.18-00.tar.gz )

dell-pediags-2.7.0-193 (Download Link: ftp://ftp.us.dell.com/diags/dell-pediags-linux-

	ftp://ftp.dell.com/diags/dell-pediags-linux- )

All these are in the OM_5.1_ManNode_LIN_A00.tar.gz package available on http://support.dell.com.


(Download link: ftp://ftp.us.dell.com/sysman/OM_5.1_ManNode_LIN_A00.tar.gz

	ftp://ftp.dell.com/sysman/OM_5.1_ManNode_LIN_A00.tar.gz )

srvadmin-storage-5.1.0-392 (Download link: ftp://ftp.us.dell.com/sysman/srvadmin-storage-5.1.0-392.i386.rpm

	ftp://ftp.dell.com/sysman/srvadmin-storage-5.1.0-392.i386.rpm )

Available source code is in the “SRPMS” folder, patches and dev.tar.gz is in the “files” folder.

A quick How-To describing how this CD came to life:

This how-to is heavily based on this Gentoo LiveCD how-to - http://forums.gentoo.org/viewtopic-t-410389.html

First a short description on how the CD works:

  1. Boot a Linux kernel and load an initial ram disk.
  2. Execute linuxrc script in initial ram disk.
  3. linuxrc will mount the CD.
  4. linuxrc will mount a squashfs file system
  5. linuxrc will unify the squashfs read only file system with a read write tmpfs.
  6. linuxrc will execute init, and CentOS should load.

And now some more details:

NOTE! I wrote this how-to from memory; it is possible that I have missed something.

1. Install a build environment; I used CentOS 4.4 and chose to install all development packages in the build environment. 2. We need to add SquashFS and UnionFS support.

Source RPM's for UnionFS and SquashFS can be downloaded here: ftp://ftp.psi.ch/psi/livecd/SRPMS

- Install src.rpm's with rpm -i <pacage-name>. - Go to /usr/src/redhat/SPECS/ - Run command $ rpmbuild -ba –target=i686 unionfs.spec - Run command $ rpmbuild -ba –target=i686 squashfts.spec

This will build the driver for the running kernel. If you are running a different kernel look in the .spec files to se how you can build for a different kernel.

Now install the rpm's we just built. $ cd /usr/src/redhat/RPMS/i686 $ rpm -Uhv kernel-module-squashfs-<kernel-release>.sl4.psi.i686.rpm $ rpm -Uhv squashfs-3.1.2-1.sl4.psi.i686.rpm $ rpm -Uhv –nodeps unionfs-1.1.5-2.sl4.psi.i686.rpm $ rpm -Uhv kernel-module-unionfs-<kernel-release>.sl4.psi.i686.rpm

NOTE: The kernel-module-unionfs package and the unionfs package is dependen of each other so we get a “chicken or the egg” situation. Just install one of the packages with the –nodeps options, then install the other package afterwards.

3. We need to build openipmi drivers for OMSA.

Install DKMS $ rpm -i dkms-2.0.13-1.noarch.rpm $ rpm -i openipmi-33.13.RHEL4-1dkms.noarch.rpm $ dkms mkrpm -m openipmi -v 33.13.RHEL4

An rpm package with module built for your running kernel is created in /usr/src/redhat/RPMS/noarch/.

5. Creat another installation of CentOS on a nother system, or a dual boot environment.

6. Install dkms and openipmi drivers using the rpm created previously in the build environment.

7. Installed the following software in the LiveCD environment.

OMSA 5.1 (OM_5.1_ManNode_LIN_A00.tar.gz)
OMSA Storage patch. (srvadmin-storage-5.1.0-392.i386.rpm)
Dell PowerEdge Diagnostics (dell-pediags-linux-
Dell SAS RAID Storage Manager (SSM_Linux_1.18-00.tar.gz)

8. To make networking work on all systems

We need to edit the following file:


Remove the line with the MAC address.

(I also created ifcfg-ethX files for 3 additional NIC's.)

9. Apply the following patch to rc.sysinit. This will add autoconfiguration of X and a prompt for root's password during boot. (The patch is available in “files” directory.)

--- /etc/rc.d/rc.sysinit        2006-11-22 10:08:57.000000000 +0100
+++ /mnt/livecd/etc/rc.d/rc.sysinit     2006-11-30 06:05:01.000000000 +0100
@@ -975,6 +975,16 @@

+# Autoconfigure xorg.conf
+echo "Autoconfiguring X Windows"
+system-config-display --noui --reconfig --set-resolution=1024x768
+# Ask user to set the root's password
+echo ""
+echo "Please set the password for root: "
+passwd root
 # Let rhgb know that we're leaving rc.sysinit
 if [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then
     /usr/bin/rhgb-client --sysinit

10. I also commented a lot of /etc/init.d/halt to disable umount during shutdown. See patch file halt.diff in “files” directory.

Ugly, but effective… :)

11. Edit /etc/fstab

The /etc/fstab file should include only the following:

	unionfs			/	    unionfs 	defaults    	0 0
	none                    /dev/pts    devpts  	gid=5,mode=620  	0 0
	none                    /dev/shm    tmpfs   	defaults        	0 0
	none                    /proc       proc    	defaults        	0 0
	none                    /sys        sysfs   	defaults        	0 0

12. Create the initrd (Initial ram drive.)

Reboot to the build environment.

Creating the initrd

  • First we create an image file, put an ext2 file system on it and mount it a loop device.
	$	dd if=/dev/zero of=initrd BS=1M count=8
	$	mke2fs initrd
	$	mkdir /mnt/loop
	$	mount -o loop initrd /mnt/loop
  • Now we need to create the files and directories we need in our initial ram disk.
	$	mkdir etc dev lib bin proc new cdrom static dynamic union
	$	touch linuxrc 
	$	chmod +x linuxrc 
	$	touch etc/mtab 
	$	touch etc/fstab
  • Then we need to copy the files, binaries, libraries and kernel modules that we need in our initial ram disk.
  • Files that go in /mnt/loop/bin (The initrd /bin directory)

To figure out what files should go in /mnt/loop/lib (The initrd /lib directory) use the ldd command.

Example: $ ldd /bin/sh

Will output:

	linux-gate.so.1 =>  (0xffffe000) 
	libreadline.so.5 => /lib/libreadline.so.5 (0xb7f72000) 
	libhistory.so.5 => /lib/libhistory.so.5 (0xb7f6b000) 
	libncurses.so.5 => /lib/libncurses.so.5 (0xb7f33000) 
	libdl.so.2 => /lib/libdl.so.2 (0xb7f2f000) 
	libc.so.6 => /lib/libc.so.6 (0xb7e42000) 
	/lib/ld-linux.so.2 (0xb7fad000)

So, sh need the above list of libraries to run, copy them into place.

NOTE! Ignore linux-gate.so.1

In addition to this wee need to copy our unionfs drive module and the modules.dep file into /lib

$	cp /lib/modules/'uname -r'/kernel/fs/unionfs.ko /mnt/loop/lib
$	cp /lib/modules/'uname -r'/kernel/fs/squashfs.ko /mnt/loop/lib
$	cp /lib/modules/'uname -r'/kernel/drivers/block/loop.ko /mnt/loop/lib

$	cp /lib/modules/<kernel>/modules.dep /mnt/loop/lib

Populate the /dev directory in our initial ram disk:

$	mknod /mnt/loop/dev/console 	c 5 1 
$	mknod /mnt/loop/dev/null 	c 1 3 
$	mknod /mnt/loop/dev/hda 	b 3 0 
$	mknod /mnt/loop/dev/hdb 	b 3 64 
$	mknod /mnt/loop/dev/hdc 	b 22 0 
$	mknod /mnt/loop/dev/hdd 	b 22 64
$ 	mknod /mnt/loop/dev/scd0 	b 11 0 
$ 	mknod /mnt/loop/dev/scd1 	b 11 1
$ 	mknod /mnt/loop/dev/scd2 	b 11 2 
$ 	mknod /mnt/loop/dev/scd3 	b 11 3
$ 	mknod /mnt/loop/dev/sda 	b 8 0
$ 	mknod /mnt/loop/dev/sdb 	b 8 16
$ 	mknod /mnt/loop/dev/sdc 	b 8 32
$ 	mknod /mnt/loop/dev/sdd 	b 8 48
$ 	mknod /mnt/loop/dev/sde 	b 8 64
$ 	mknod /mnt/loop/dev/sdf 	b 8 80
$	mknod /mnt/loop/dev/tty 	c 4 0 
$	mknod /mnt/loop/dev/loop0 	b 7 0

Create/Edit the linuxrc script that will find the CD, mount the file systems and execute init in the end:


	export PATH=/bin

	echo "Wait 5 seconds for slower USB CD-ROM devices to be detected..."
	for x in 1 2 3 4 5
	                usleep 1000000
                	echo -n " $x"
	echo ""

	for x in hda hdb hdc hdd sda sdb sdc sdd sde sdf scd0 scd1 scd2 scd3
                	mount -t iso9660 /dev/${x} /cdrom
                	if [ "$?" == "0" ]

	if [ "${CDROM}" == "" ]
        	echo "FATAL --- LIVECD NOT FOUND"
	        exec /bin/sh

	echo "LiveCD found in /dev/${CDROM}"

	insmod /lib/loop.ko
	insmod /lib/squashfs.ko
	insmod /lib/unionfs.ko

	mount -t squashfs -o loop /cdrom/livecd.squashfs /static
	mount -t tmpfs -o size=300M none /dynamic
	mount -t unionfs -o dirs=/dynamic=rw:/static=ro unionfs /union

	cd /union

	/bin/pivot_root . initrd
	mount --move /initrd/dynamic /mnt/dynamic
	mount --move /initrd/static /mnt/static
	mount --move /initrd/cdrom /mnt/cdrom
	mount -t tmpfs -o size=50M none /tmp

	mount -t proc none /proc

	cat /proc/mounts > /etc/mtab
	umount /proc

	exec /usr/sbin/chroot . /bin/sh <<- EOF >dev/console
	umount /initrd
	echo "Startng init!"
	exec /sbin/init

Finally we need to unmount the initrd, and compress it with gzip.

$ ummount /mnt/loop
$ gzip initrd

13. We need to copy out bzImage, ISOLINUX and initrd into what will be the BOOT directory on the CD

$	mkdir boot
$	mkdir boot/isolinux
$	cp <path-to-isolinux.bin> boot/isolinux/
$	touch boot/isolinux/isolinux.cfg
$	cp initrd.gz boot/isolinux/	
$	cp /boot/'uname -r' boot/isolinux/vmlinuz

14. Edit the isolinux.cfg file:

timeout 1
default Linux
label Linux
	kernel vmlinuz
	append initrd=initrd.gz init=/linuxrc root=/dev/ram0

15. Preparing the CDROOT directory

$	mkdir cdroot
$	cp -a boot cdroot/

16. Before we create the squashfs filesystem we need to populate /dev on the LiveCD install.

mount /dev/(s/h)dXX /mnt/livecd
tar xvzf dev.tar.gz -C /mnt/livecd

(dev.tar.gz is available in the “files” folder.)

17. Creating the SquashFS file system

$	cd cdroot/
$	mksquashfs /mnt/livecd livecd.squashfs
$	cd ..

18. Create a bootable CD ISO image using mkisofs

$	mkisofs -R -b boot/isolinux/isolinux.bin -no-emul-boot -boot-load-size \ 
	4 -boot-info-table -c boot/isolinux/boot.cat -iso-level 3 -o livecd.iso cdroot/

Once this ISO I created it is time to burn it to a CD and test it.



howto/centos-live.txt · Last modified: 12.12.2008 13:38 by npelov
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki