/* Void Main's Red Hat/Fedora Tips */

{ Red Hat/Fedora Tips(); } else { main(); }
Hacking a Fedora Live CD
#include <stddisclaimer.h>

Prerequisites: This tip will hack a Fedora 10 Live CD into a more specialized boot CD. In this case it is intended to be used to restore a disk image to many Kiosk machines. It assumes you also have a Fedora 10 machine to perform this tip. It should work with any other version of the Fedora Live CD as well but I would recommend you match the build machine to the target Live CD version. In addition to creating the custom Live CD we'll also turn it into a bootable thumb drive.

Let us begin:

Ok, here's how I stripped down a Fedora Live CD and converted it into a base Kiosk Restore CD (minus actual menu/scripts and image). You should probably do all of this on the same version of OS that the Live CD you are hacking is running but I'm not sure that it HAS to be the same. This is also all covered in this forum thread.

1) Create a working directory and put a copy of the Fedora Live ISO there:

Commands:
[root@linux ~]# mkdir /iso
[root@linux ~]# cd /iso
[root@linux iso]# wget ftp://ftp.uci.edu/mirrors/fedora/linux/releases/10/Live/i686/F10-i686-Live.iso


2) Mount the ISO and copy the goodies out into a working Kiosk Restore Image Directory:

Commands:
[root@linux iso]# mkdir f10live
[root@linux iso]# mount F10-i686-Live.iso mnt -o loop
[root@linux iso]# mkdir Kiosk-Restore
[root@linux iso]# cp -a f10live/* Kiosk-Restore


3) You can modify the boot menu as needed by replacing Kiosk-Restore/isolinux/isolinux.cfg with my modified version:

Commands:
[root@linux iso]# wget http://voidmain.is-a-geek.net/files/Kiosk-Restore/isolinux/isolinux.cfg
[root@linux iso]# cp isolinux.cfg Kiosk-Restore/isolinux


4) Mount the compressed file system image and copy out the underlying ext3 file system so it can be mounted and modified:

Commands:
[root@linux iso]# mkdir mnt
[root@linux iso]# mount Kiosk-Restore/LiveOS/squashfs.img mnt -o loop -t squashfs
[root@linux iso]# mkdir squashfs
[root@linux iso]# cp -a mnt/* squashfs
[root@linux iso]# umount mnt
[root@linux iso]# mkdir ext3fs
[root@linux iso]# mount squashfs/LiveOS/ext3fs.img ext3fs -o loop


Now you have your 3GB ext3 Live root file system mounted so it can be modified as you wish.

5) First lets copy a new service script that will eventually have code to do the Kiosk Restore and fix selinux:

Commands:
[root@linux iso]# wget http://voidmain.is-a-geek.net/files/Kiosk-Restore/ext3fs/etc/selinux/config
[root@linux iso]# cp config ext3fs/etc/selinux
[root@linux iso]# wget http://voidmain.is-a-geek.net/files/Kiosk-Restore/ext3fs/etc/rc.d/init.d/kiosk
[root@linux iso]# chmod +x kiosk
[root@linux iso]# cp kiosk ext3fs/etc/rc.d/init.d
[root@linux iso]# wget http://voidmain.is-a-geek.net/files/Kiosk-Restore/ext3fs/usr/local/bin/kiosk-restore.py
[root@linux iso]# chmod +x kiosk-restore.py
[root@linux iso]# cp kiosk-restore.py ext3fs/usr/local/bin


To remove packages and change things just use the "chroot" command. CAUTION: Make sure you are in a chrooted window before removing packages or you will be removing packages from your host system rather than from the Live CD image. Same goes for setting root password disabling services and the rest of what is in the next step.

6) First lets just turn off services, set a root password (not really needed but can come in handy later for getting a normal logon shell) and add a service for our installation.

Commands:
[root@linux iso]# chroot /iso/ext3fs
[root@linux /]# passwd root (set a root password)
[root@linux /]# chkconfig --add kiosk


Use "chkconfig servicename off" to turn off any services that aren't in this list (again in the chrooted shell):

Commands:
[root@linux /]# chkconfig --list | grep :on
cpuspeed          0:off   1:on   2:on   3:on   4:on   5:on   6:off
haldaemon         0:off   1:off   2:off   3:on   4:on   5:on   6:off
irqbalance        0:off   1:off   2:off   3:on   4:on   5:on   6:off
kiosk             0:off   1:off   2:off   3:on   4:off   5:on   6:off
mdmonitor         0:off   1:off   2:on   3:on   4:on   5:on   6:off
messagebus        0:off   1:off   2:on   3:on   4:on   5:on   6:off
microcode_ctl     0:off   1:off   2:on   3:on   4:on   5:on   6:off
setroubleshoot    0:off   1:off   2:off   3:on   4:on   5:on   6:off
udev-post         0:off   1:on   2:on   3:on   4:on   5:on   6:off


7) I removed all packages using "rpm -e" except for what is left in this list (again from within the chrooted shell):

http://voidmain.is-a-geek.net/files/Kiosk-Restore/ext3fs/root/rpms.txt

(Above list created using "rpm -qa | sort > /root/rpms.txt" from within the chrooted shell). I removed NetworkManager as well but if you wanted to keep Networking on the bootable disk you might want to keep that and various other things.

Ok, now comes the fun (and easy) part, putting it all back together and testing.

8) Exit from your chrooted shell and unmount the ext3fs and create a new Kiosk-Resore.iso:

Commands:
[root@linux /]# exit
[root@linux iso]# rm /iso/Kiosk-Restore/LiveOS/squashfs.img
[root@linux iso]# mksquashfs /iso/squashfs /iso/Kiosk-Restore/LiveOS/squashfs.img
[root@linux iso]# mkisofs -o Kiosk-Restore.iso \
      -J -r -hide-rr-moved -hide-joliet-trans-tbl -V Kiosk-Restore \
      -b isolinux/isolinux.bin -c isolinux/boot.cat \
      -no-emul-boot -boot-load-size 4 -boot-info-table \
      /iso/Kiosk-Restore


If everything went right you should now have a base bootable restore CD that will simply boot quickly to a menu stub that does nothing (at the moment). If you press ENTER it will go to a text login screen where you can login with root and the password you set (but once menus/scripts are created there will be no need to logon). You can boot the ISO in QEMU without actually burning it to CD to test it:

Commands:
[root@linux iso]# qemu -m 512 --cdrom Kiosk-Restore.iso


I have one little quirk when booting it in QEMU is that the arrow keys do not work on the boot menu. The keypad arrows work though (everything works fine from a burned and booted CD).

Once you get to this place adding in your disk image is trivial and hooking in restore scripts (these would go in the kiosk service script).


P.S. If you find errors in this or things that need to be added let me know and I'll make changes.

Have fun!

Make bootable USB thunmb drive from this image
Forum topic that spawned this tip
Forums

Valid HTML 4.01!