Customize an Ubuntu Live CD / USB
The default ubuntu live CD is nice: it can boot fast, detect the hardware correctly, etc. But I always dreamed of customizing it (eg. add medibuntu support
, etc.). The
script offers a simple approach to do just this: we start with a working live CD ISO image, change its contents, and create a new live CD image. This script does not create a whole new CD from scratch (debootstrap
, etc.): it starts with an existing live CD image. But if you're insteresting in building a live CD from scratch, there is this other page
Besides allowing to create customized ubuntu live CDs, this script makes it also easy to setup a chroot environment (for schroot
for example) without requiring neither to install the system on the disk the usual way (eg. boot from the live cd, install the OS on its own partition, etc.), nor to bootstrap the OS from scratch in a pristine chroot (debootstrap), nor to use some chemistery based on the installation of the system via a virtual machine (eg. qemu, VirtualBox, etc.). In my case, I used this script to create a small schroot
installation to have access to the 32bits ubuntu software from my 64bits running system.
This script allows to customize an Ubuntu live CD in 3 simple steps:
- extract the contents of an ubuntu CD ISO image to your hard drive
- chroot to the working area containing the extracted CD contents. This allows to do all the /etc configs, aptitude purge/install, etc. to prepare the future ISO image
- generate a new ISO image containing the (hopefully modified) working area you just prepared
- Tested with the jaunty/x86_32 (9.04) desktop live CD image on an intrepid/x86_64 (8.10) host
- Tested with the jaunty/x86_32 (9.04) desktop live CD image on a karmic/x86_64 (9.10) host
- Tested with the karmic/x86_32 (9.10) desktop live CD image on a karmic/x86_64 (9.10) host
- Tested with the lucid/x86_64 (10.04) Xubuntu desktop live CD image on a lucid/x86_64 (10.04) host
It should work with the other ubuntu flavors (eg. kubuntu, xubuntu, edubuntu, gobuntu, etc.) and support the server
live CDs as well.
Note: to remaster karmic (9.10) live CD images, the host must be running karmic or newer. For example, it is not possible to remaster a karmic live CD on a jaunty host. A workaround to this would be to compile a custom kernel for the host with a newer squashfs kernel support.
All the following commands MUST be run as root (sudo).
- remaster_ubuntu.sh extract /path/to/original/ubuntu.iso /path/to/working/area
This will extract the contents of the ISO into 2 subdirectories of path/to/working/area/ (should be empty initially):
extract-cd/: the files needed to boot (isolinux config, kernel, initramfs, etc.), but not the root FS
edit/: the root file system (complete with /etc, /usr, etc.)
- remaster_ubuntu.sh chroot /path/to/working/area
This will start a root bash shell inside the root file system. Takes care of mounting /dev, /proc, /sys. In that shell, you can aptitude purge/install, edit /etc files, create users, even start X applications (xauth is configured), etc. But do NOT edit anything in /dev, as this will affect your host (the host's /dev is mounted inside the chroot: anything changed in the chroot's /dev is also changed in the host's /dev !): avoid doing rm in /dev at this point :) ! Beware also that issuing some aptitude install commands might start /etc/init.d daemons which will run inside the chroot, even after you exited from it: you might have to kill these manually so that they don't interfere with the host
Note: This operation will also copy the host's apt config into the working area, so that the same repositories can be used. The original ubuntu apt config will be restored when the regen command is issued
- remaster_ubuntu.sh release /path/to/working/area
You will probably never need to use this operation manually. It is essentially an internal command used by the regen operation. But it might be important to use manually if you plan to remove /path/to/working/area (eg. rm -rf) after you chroot'ed to it at least once. This command makes sure the host will not be impacted by the removal of the working area (eg. it will unmount the /dev mount in the chroot). After this command, it is safe to remove completely the working area. You will still be able to use the chroot operation after a release
operations will be verbose and stop at the first error that occurs. You can of course run the extract
operation just once, and run the chroot
operations thousands of times on the same working area. You can also run several chroot
sessions in parallel. But be sure NOT to run a chroot
operation while a regen
is in progress.
If you're planning to update the kernel, or to change the live user configuration, follow these instructions
Try VirtualBox OSE
(aptitude install virtualbox-ose
) on the resulting iso file. Or burn a CD and reboot on it. Or use unetbootin
(aptitude install unetbootin
) to create a bootable USB memory stick.