Tuesday, August 25, 2009

How to create a custom Ubuntu distro

(link to note)
*Get the packaged you need
sudo apt-get install squahfs-tools mkisofs

*Load the squashfs
sudo modprobe squashfs

create a iso image of Dapper CD
* confirm that cdrom is not mounted, if it is then
sudo umount /cdrom

* dd if /dev/hdc of=/pathtoiso/image.iso
else dd if /dev/cdrom of=/pathtoiso/image.iso

* Create a working directory
mkdir ~/custom

* move the iso to custom
mv /pathtoiso/image.iso ~/custom
cd ~/custom

* mount the image.iso
mkdir mnt
sudo mount -o loop image.iso mnt

* get the contents of iso in to a local dir
mkdir extract
rsync –exclude=/casper/filesystem.squashfs -a mnt/ extract

*Mount squashfs
mkdir squahfs
sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs
mkdir tmp
sudo cp -r squashfs/* edit

*Mount the root
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
export HOME=/root

*Customization
Now you have all the settings ready and you can readily customise by apt-get
for eg, to add mplayer
sudo apt-get install mplayer

*The default backgrounds and splashscreens can be simpley copied .

*Edit LiveCD user
sudo vi edit/usr/share/initramfs-tools/scripts/casper-bottom/10adduser
sudo vi edit/usr/share/initramfs-tools/scripts/casper

*Cleanup
rm -rf /tmp/*
umount /proc
umount /sys
exit

chmod +w extraxt/casper/filesystem.manifest
sudo chroot edit dpkg-query -W –showformat=’${Package} ${Version}\n’ > extract/casper/filesystem.manifest
sudo cp extract/casper/filesystem.manifest extract/casper/filesystem.manifest-desktop
sudo sed -ie ‘/ubiquity/d’ extract/casper/filesystem.manifest-desktop
sudo mksquashfs edit extract/casper/filesystem.squashfs
sudo vim extract-cd/README.diskdefines

*Generate new md5sum
sudo -s
rm extract/md5sum.txt
(cd extract && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)
exit

*Create the iso
cd extract
sudo mkisofs -r -V “$IMAGE_NAME” -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../custom.iso .

*You can test the cd by
qemu -cdrom custom.iso -boot d

*Burn the iso using k3b or nautilus-cd-burner
or
cdrecord dev=/dev/hdc custom.iso