This CD is based of CentOS 4.3 (http://www.centos.org) In addition to CentOS packages file system driver’s unionfs, SquashFS and boot loader ISOLINUX 3.11 is used. A list of mirrors where the source code of CentOS can be found here: http://www.centos.org/modules/tinycontent/index.php?id=13 Direct link to CentOS source code: http://mirrors.kernel.org/centos/4.3/os/SRPMS/ Source Code for unionfs and SquashFS can be found on the following locations: SquashFS - http://squashfs.sourceforge.net unionfs - http://www.fsl.cs.sunysb.edu/project-unionfs.html Source Code for ISOLINUX can be found here: http://www.kernel.org/pub/linux/utils/boot/syslinux/ ---------------------------------------- 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: - Boot a Linux kernel and load an initial ram disk. - Execute linuxrc script in initial ram disk. - linuxrc will mount the CD. - linuxrc will mount a squashfs file system - linuxrc will unify the squashfs read only file system with a read write tmpfs. - 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. First you need to install a build/development environment; I used CentOS 4.3 and chose to install all development packages. 2. You need to install the Kernel Source Code. Obtain the kernel-.src.rpm file from one of the following Sources: - The SRPMS directory on the appropriate "SRPMS" CD ISO image - The FTP site where you got the kernel package - By running the following command: bash# up2date --get-source kernel Install kernel-.src.rpm (given the default RPM configuration, the files this package contains will be written to /usr/src/redhat/) Change directory to /usr/src/redhat/SPECS/, and issue the following command: bash# rpmbuild -bp --target= kernel.spec (Where is the desired target architecture.) On a default RPM configuration, the kernel tree will be located in /usr/src/redhat/BUILD/. In resulting tree, the configurations for the specific kernels shipped in Red Hat Enterprise Linux 4 are in the /configs/ directory. For example, the i686 SMP configuration file is named /configs/kernel--i686-smp.config. Issue the following command to place the desired configuration file in the proper place for building: bash# cp ./.config 3. We need to add SquashFS support. Download SquashFS from: http://squashfs.sourceforge.net First patch the kernel source code: (http://www.artemio.net/projects/linuxdoc/squashfs/SquashFS-HOWTO.html#preparing) Change to the SquashFS source directory and copy the kernel patch (we'll assume it's named squashfs-patch) to /usr/src/linux. bash# cd /usr/src/squashfs bash# cp linux-2.x.y/squashfs-patch /usr/src/linux Go to the Linux kernel source directory /usr/src/linux: bash# cd /usr/src/linux Note: please remember that we will not be leaving this directory during all further kernel-related procedures, and all paths will be given relative to /usr/src/linux. Now patch the source with the SquashFS patch: bash# patch -p1 < squashfs-patch Second we need to compile and install the mksquashfs tool: (http://www.artemio.net/projects/linuxdoc/squashfs/SquashFS-HOWTO.html#mksquashfs) bash# cd /usr/src/squashfs/squashfs-tools Compile and install mksquashfs: bash# make bash# cp mksquashfs /usr/sbin If everything went fine, typing mksquashfs at the shell prompt should print its "usage" message. 4. To compile the Kernel change directory to the location of the source code and run the following commands: bash# make oldconfig Answer YES to add SqushFS support. bash# make menuconfig I made changes so ext3 support is built into the kernel instead of a kernel module which is default. You will need to build a kernel with support for your hardware so that it can boot without and initrd. bash# make bash# make install 5. We need to reboot using our newly built kernel. Copy the new bzImage into /boot and edit your boot loader configuration. Reboot. 6. We need to add unionfs support. Getting unionfs to play with CentOS was a bit unpleasant. In the later versions of unionfs it is possible to patch the kernel sources to add unionfs support, this however does not work with the CentOS Kernel sources. In addition the later versions also failed when I tried to compile them as modules. In the end I found that the most recent version of unionfs that I could get to play with CentOS is unionfs-1.0.9. Download: unionfs-1.0.9.tar.gz from ftp://ftp.fsl.cs.sunysb.edu/pub/unionfs/ Extract the archive and run the following commands: bash# make bash# make install bash# depmod -a To check that the unionfs module was successfully build run commands: bash# modprobe unionfs bash# dmesg 7. We need to install OMSA on the develop/build install to compile driver modules for our kernel Run the following command to install OMSA: bash# wget -q -O - http://linux.dell.com/yum/software/bootstrap-omsa-all.sh | bash bash# OMIIGNORESYSID=1 up2date -i srvadmin-all (I use OMIIGNORESYSID=1 because I made this CD using VMWare which is not a supported system. If you create the CD on a Power Edge System this should not be necessary.) To Compile the OMSA driver modules I did the following: Edit the /etc/init.d/instsvsdrv script: Comment out this line: SYS_TYPE=$1 Add this directly below the line we comment out: SYS_TYPE=0 Now to compile the dcdbas driver only: bash# /etc/init.d/instsvcdrv start bash# /etc/init.d/instsvcdrv stop Edit /etc/init.d/instsvsdrv again: Change SYS_TYPE=0 to SYS_TYPE=1 Then to compile the dcdtvm driver do: bash# /etc/init.d/instsvcdrv start bash# /etc/init.d/instsvcdrv stop Repeat above action setting SYS_TYPE=2 and SYS_TYPE=4 as well. SYS_TYPE=2 will compile dcdesm driver. SYS_TYPE=4 will compile dcdipm driver. ********* NOTE!!!!! After SYS_TYPE=4 (dcdipm driver) do not run bash# /etc/init.d/instsvcdrv stop In VMware unloading the dcdipm drive module cause a kernel panic. ********* ****** We have now built the kernel and the kernel modules we need to make our live CD. ****** Next up is installing minimal CentOS onto a second partition or hard drive. 8. Install CentOS 4.3, use the GUI installer. (Will refer to this install as "LiveCD Install" later) - I installed a custom system with no SElinux, and choose "minimal" at package selection. I created the following partitions during install: /boot / swap 9. After the install, configure the system to use the Dell yum repository, and update the system: bash# wget -q -O - http://linux.dell.com/yum/software/bootstrap.sh | bash bash# rpm --import /usr/share/rhn/RPM-GPG-KEY bash# up2date -u 10. To install X and Gnome Run the following commands: bash# up2date -i system-config-display bash# up2date -i gnome-session 11. We need to copy the kernel modules for our custom kernel over from the development/build system. Reboot into the development/build system, mount the minimal root (/) partition of the minimal install. bash# mount /dev/hdb3 /mnt/livecd Copy the custom-kernel modules over to the livecd install: bash# cp -a /lib/modules/ /mnt/livecd/lib/modules/ Remove the kernel modules for the default-centos-kernel: bash# rm -rf /mnt/livecd/lib/modules/ 12. We need to install OMSA on the "liveCD Install". Reboot into the "liveCD Install". Run the following command to install OMSA: bash# wget -q -O - http://linux.dell.com/yum/software/bootstrap-omsa-all.sh | bash bash# OMIIGNORESYSID=1 up2date -i srvadmin-all (I use OMIIGNORESYSID=1 because I made this CD using VMWare which is not a supported system. If you create the CD on a Power Edge System this should not be necessary.) I choose to configure the CD no to auto start OMSA services: bash# chkconfig instsvcdrv off bash# chkconfig dataeng off bash# chkconfig omsad off bash# chkconfig omawsd off 13. Cleanup the startup, faster boot and some services fail to start from the CD. (I do not remember exactly what services I turned off; here is a short list to give you a general idea.) bash# chkconfig smartd off bash# chkconfig sendmail off bash# chkconfig cron off bash# chkconfig anacron off bash# chkconfig kudzu off bash# chkconfig isdn off 14. To make networking work on all systems We need to edit the following file: /etc/sysconfig/network-scripts/ifcfg-eth0 Remove the line with the MAC address. 15. To Auto configure X and automatically start a GNOME session Edit the following file: /etc/rc.local Add the following: echo "Trying to auto configure X" system-config-display --noui --reconfig --set-resolution=1024x768 echo "Starting X and GNOME" startx 16. To help the initrd we need to move chroot from to /bin bash# mv /usr/sbin/chroot /bin (I believe it is located in /usr/sbin/ as default, if not look in /sbin or /usr/bin) 17. Install any additional software you want, add any configuration changes that you want etc. When you have done all the changes you want, reboot into the build/development install. 18. We need to populate /dev on the "liveCD install" root partition. bash# mount /dev/hdb3 /mnt/livecd bash# tar xvzf dev.tar.gz -C /mnt/livecd/ 19. We need to edit /etc/fstab on the "liveCD install" 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 20. Creating the initrd First we create an image file, put an ext2 file system on it and mount it a loop device. bash# dd if=/dev/zero of=initrd BS=1M count=8 bash# mke2fs initrd bash# mkdir /mnt/loop bash# mount -o loop initrd /mnt/loop Now we need to create the files and directories we need in our initial ram disk. bash# mkdir etc dev lib bin proc new cdrom static dynamic union bash# touch linuxrc bash# chmod +x linuxrc bash# touch etc/mtab bash# 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) cat chroot insmod mkdir mount pivot_root sh tar umount To figure out what files should go in /mnt/loop/lib (The initrd /lib directory) use the ldd command. Example: bash# 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 bash# cp /lib/modules//kernel/fs/unionfs.ko /mnt/loop/lib bash# cp /lib/modules//modules.dep /mnt/loop/lib Populate the /dev directory in our initial ram disk: bash# mknod /mnt/loop/dev/console c 5 1 bash# mknod /mnt/loop/dev/null c 1 3 bash# mknod /mnt/loop/dev/hda b 3 0 bash# mknod /mnt/loop/dev/hdb b 3 64 bash# mknod /mnt/loop/dev/hdc b 22 0 bash# mknod /mnt/loop/dev/hdd b 22 64 bash# mknod /mnt/loop/dev/tty c 4 0 bash# 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: #!/bin/sh export PATH=/bin for x in hda hdb hdc hdd do mount -t iso9660 /dev/${x} /cdrom if [ "$?" == "0" ] then CDROM=${x} break fi done if [ "${CDROM}" == "" ] the echo "FATAL --- LIVECD NOT FOUND" exec /bin/sh exit fi echo "LiveCD found in /dev/${CDROM}" /bin/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 chroot . /bin/sh <<- EOF >dev/console umount /initrd echo "Starting init!" exec /sbin/init EOF Finally we need to unmount the initrd, and compress it with gzip. bash# ummount /mnt/loop bash# gzip initrd 21. We need to copy out bzImage, ISOLINUX and initrd into what will be the BOOT directory on the CD bash# mkdir boot bash# mkdir isolinux bash# cp boot/isolinux/ bash# touch boot/isolinux/isolinux.cfg bash# cp initrd.gz boot/isolinux/ bash# cp bzImage boot/isolinux/livekrnl 22. Edit the isolinux.cfg file, my isolinux.cfg file look like this: timeout 1 default Linux label Linux kernel livekrnl append initrd=initrd.gz init=/linuxrc root=/dev/ram0 23. Preparing the CDROOT directory bash# mkdir cdroot bash# cp -a boot cdroot/ 24. Creating the SquashFS file system bash# cd cdroot/ bash# mksquashfs /mnt/livecd livecd.squashfs bash# cd .. 25. Create a bootable CD ISO image using mkisofs bash# 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. To save space I also spent some time deleting documentation files and the rpm database etc.