Code: Select all
#!/bin/bash
# This is a (short) example and HOWTO for modifying the gentoo minimal livecd.
# (The example is about creating a reiser4 minimal livecd with our own kernel
# from original minimal livecd.)
# 0) We need about 600 MB of free space.
cd /tmp/
mkdir gentoo-min/
cd gentoo-min/
wget http://gentoo.osuosl.org/releases/x86/2007.0/installcd/install-x86-minimal-2007.0-r1.iso
# [[ It is assumed that we have a kernel with reiser4 and squashfs installed
# (in this example, its 2.6.22-helium9), and also that we have squashfs-tools
# and reiser4progs :
emerge -u squashfs-tools reiser4progs
# ]]
# 1) Extract the livecd contents, the squashfs img contents and initrd contents :
mkdir iso/ iso-ori/
mount install-x86-minimal-2007.0-r1.iso iso/ -o loop
cp -a iso/* iso-ori/
umount iso/
rm -rf iso/
cp -a iso-ori/ iso-new/
mkdir sqfs-old/
unsquashfs -f -d sqfs-old/ iso-ori/image.squashfs
cp -a sqfs-old/ sqfs-new/
gunzip < iso-ori/isolinux/gentoo.igz > gentoo.i
mkdir initrd-old/
cd initrd-old/
cpio -idv < ../gentoo.i
cd ..
cp -a initrd-old/ initrd-new/
# 2) Modify stuff :
# 2a) For adding reiser4 support :
emerge -u gentoolkit
mkdir -p /usr/portage/packages/
emerge -u reiser4progs
quickpkg reiser4progs libaal
mkdir 1/ 2/
tar -xjpf /usr/portage/packages/All/libaal-1.0.5.tbz2 -C 1/
tar -xjpf /usr/portage/packages/All/reiser4progs-1.0.6.tbz2 -C 2/
cp -a 2/* 1/* sqfs-new/
# 2b) For adding the our own kernel :
cp /usr/src/linux/arch/i386/boot/bzImage iso-new/isolinux/gentoo
cp /usr/src/linux/.config iso-new/isolinux/config
rm -rf initrd-new/lib/modules/
rm -rf sqfs-new/lib/modules/*
cp -a /lib/modules/$(uname -r)/ sqfs-new/lib/modules/
# Note that this assumes that we have all ide and sata and raid related
# drivers compiled into our kernel (and not as modules). Its also assumed
# that we have reiser4 and squashfs compiled into the kernel (not as modular).
# [[ 2c) Optional : Additional firmware (for network cards say ;-) -
cp -a /lib/firmware/* sqfs-new/lib/firmware/
# ]]
# 3) Merge back :) -
rm iso-new/image.squashfs
mksquashfs sqfs-new/ iso-new/image.squashfs
cd initrd-new/
find . | cpio --quiet --dereference -o -H newc | gzip -9 > ../gentoo.igz
cd ../
cp gentoo.igz iso-new/isolinux/
cd iso-new/
echo \#\!/bin/bash >> create_iso.sh
echo "mkisofs -R -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux/boot.cat -iso-level 3 -o ../livecd.iso . " >> create_iso.sh
chmod +x create_iso.sh
./create_iso.sh
cd ..
# Thats it, we have our livecd.iso :D.
# Hirakendu Das
# (20070905)
Many thanks to many livecd guides, and to Wainkoko for his excellent kernel patchsets (kamikaze sources)


