How To Customize the Hoary/Breezy Ubuntu Live CD
NOTE: HowTo bellow is outdated - for customizing newest Ubuntu LiveCD (6.06, named DapperDrake) look at http://www.atworkonline.it/~bibe/ubuntu/custom-livecd.htm (mirrored at ftp.akl.lt/Linux/Ubuntu/ )
Here we try to explain how to build a customized Ubuntu LiveCD based on the new Live CD infrastructure (first used in the HoaryHedgehog development cycle). The method will be to modify an already existing CD and re-build it. This way is less flexible, but avoids most of the (really unnecessary) complexity of building CDs from scratch.
Why? Well, because some people want to create specialized Live CDs to show off a particular application or localized to a certain language. If you can think of anything else that can be done, put it on the wiki.
System Setup and Requirements
- About 3 gigabytes of available disk space
cloop-utils - tools to compress and decompress the filesystem image
mkisofs
An Ubuntu kernel, version 2.6.9-7 or later (for the cloop module)
- A massive amount of swap space (3-5GB). You should be able to store the unextracted FS image in swap TWICE. Else, the recompression process will fail.
If you don't have enough swap, do:
$ sudo dd if=/dev/zero of=/tmp/swap bs=1M count=3000 $ sudo mkswap /tmp/swap $ sudo swapon /tmp/swap
Copy and paste:
$ sudo apt-get install cloop-utils mkisofs $ echo "Kernel version is" $(dpkg-query -W --showformat '${Version}' linux-image-$(uname -r))
The Process
First you will need to extract the loopback compressed file system image - [http://build.lnx-bbc.org/packages/kernel/cloop.html Cloop], so we would be able to customize it as we see fit - this could usually mean setting up packages and software we would like to have available from the LiveCD, presetting some of its configuration and more. After all our good work is done, we would put everything back, and a new LiveCD is born.
Simple.
The Extraction Process
NOTE: Before starting make sure your locale is set to C (avoiding Unicode - but don't do this everywhere unless you know what you're doing), this just makes life easier:
$ export LC_ALL=C
Grab a CD image from from http://mirror.mcs.anl.gov/pub/ubuntu-iso/ and put it into an empty directory. Make sure it is a Hoary image (Warty uses a different system).
Mount the image() as a loop device:
$ mkdir mnt $ sudo mount ubuntu-5.04-live-i386.iso mnt -o loop
Extract everything except the compressed filesystem to a temporary directory:
$ rsync --exclude=/casper/filesystem.cloop -a mnt/ extracted_cd
Then we uncompress and extract the compressed filesystem:
$ extract_compressed_fs mnt/casper/filesystem.cloop > extracted_fs
(Cup of tea time, because this takes a while)After all this, we are done with the original CD and can unmount it (maybe also delete it if you are short of disk space):
$ sudo umount mnt
Customizations
To do the customizations we mount the now uncompressed filesystem image, use chroot to do our modifications and then start putting everything back together again.
Preparing the chroot
So, to mount the uncompressed filesystem we do:
$ sudo mount extracted_fs mnt -o loop
Mounting proc and sysfs can also be a good idea:
$ sudo mount -t proc proc mnt/proc $ sudo mount -t sysfs sysfs mnt/sys
If you want to transfer data from your home directory, the easiest way is a bind mount:
$ sudo mount -o bind /home mnt/home
NOTE: Obviously saving space on the compressed filesystem is a a good idea, so during these customizations some parts of the filesystem can be temporarily mounted with tmpfs and unmounted later. That way a lot of space can be saved. Some good targets for these mounts are var/log var/run var/cache/apt var/lib/apt tmp. Just remember to unmount them all before unmounting extracted_fs!!!
Language Localizations (hoary)
To add support for a specific language to a liveCD, follow the 'Updating Specific Packages' section below to install the appropriate language-support and language-pack packages for the desired languages.
You can pre-select a language at boot time with the following process: Edit extracted_cd/isolinux/isolinux.cfg to add preseed/locale=foo_BAR to the APPEND section. This will skip the language selection section in the installer, and presumes that you've installed the appropriate language/locale packages.
For example, to support greek, install language-pack-el, language-support-el, and add preseed/locale=el_GR to the isolinux.cfg. Note that the installed files generally require only the language (en, es, el, etc.) while the isolinux.cfg requires the full locale (en_US, en_GB, etc.)
To also set the default keymap, add preseed/locale=en_US kbd-chooser/method=us to isolinux.cfg.
TODO -
- Helping to translate with Rosetta
Language Localizations (breezy)
Same as above, except replace preseed/locale with debian-installer/locale, and additionally install language-pack-gnome-foo_BAR-base or language-pack-kde-foo_BAR-base besides the language packs above.
Updating Specific Packages
If you need to test an additional package on a live CD, it's this easy:
$ sudo chroot mnt/ /bin/sh # cd dir-holding-all-packages/ # dpkg -BOGiE *.deb
This will only update packages that are already installed on the live CD, but have newer versions available.
Installing Additional Packages
A common use for a LiveCD is to show off an application, normally not already installed on the CD.
NOTE: The default user is created on startup, so if you want to copy a file to the default users home directory, you could place the file in mnt/etc/skel.
Copy in resolv.conf (containing already-resolved DNS addresses, because DNS doesn't work inside chroot):
$ sudo cp /etc/resolv.conf mnt/etc
If the packages you wish to add are not available with the default sources.list, you may modify it, or copy in your own:
$ sudo vi mnt/etc/apt/sources.list
Finally, we chroot into the chroot and install some packages, updating the apt cache along the way, and making sure to purge instead of just remove anything we want to get rid of:
$ sudo chroot mnt /bin/bash # apt-get update # apt-get install banana deadly-weapon # apt-get clean # dpkg --purge foobaz # exit
- To re-generate the manifest to reflect any changes you have made, you must become root. If you have not set up a root password than do so:
$ sudo passwd root
Then you can re-generate the manifest to reflect any changes you have made.$ chroot mnt dpkg-query -W --showformat='${Package} ${Version}\n' > extracted_cd/casper/filesystem.manifest # exit
Finding Packages to Remove
Obviously removing packages is dangerous; proceed at your own risk However, you can find the biggest packages (and hence sometimes the best to remove if you need space) with this command, run in the chroot:
dpkg-query -W --showformat='${Installed-Size;10} ${Package}\n' | sort -gr | less
TODO :
* Help removing stuff- 'recommended' list of packages to remove, including extra languages and everything that takes a lot of space so you can put your own apps on the CD. Note that you can see what the GNOME liveCD removes in: http://cvs.gnome.org/viewcvs/livecd-project/livecd.conf?view=markup
GNOME Customizations
A list of GNOME-specific customizations (changing gconf keys, making GDM colors match, etc.) is at [http://live.gnome.org/GnomeLiveCd_2fHowTo the GNOME Wiki.]
User-Mode bootsplash customizations
You can also customize the colors and the image presented to the user while the services are load. You can even customize the scrollbar colors! For further information, see ["USplashCustomizationHowto"].
Notice that this this is different than the image showed just after the CD boots up. That image is loaded by the bootload and its customization process is described [#isolinuxsplash just below].
Closing up the chroot
Make sure to unmount everything mounted when setting up the chroot (tmp?? var/log??):
$ sudo umount mnt/proc $ sudo umount mnt/sys $ sudo umount mnt
Customizing the bootsplash
To create a custom splash screen:
Create an image that is 640 pixels wide by somewhere between 200 and 300 pixels high, with 16 colors. (You can convert to 16 colors in GIMP with the Image->Mode->Indexed... menu item. Unselect "dithering" while converting, for a better result.). As a starting point, you may use [http://www.inkscape.org Inkscape] and this [http://planet.hellug.gr/misc/gnome-greek-logo.svg example file].
Save the image as BMP, or if that is not possible, save to .png and run convert splash.png splash.bmp
Convert the BMP to RLE format: bmptoppm < splash.bmp | ppmtolss16 > splash.rle If you're missing these tools, bmptoppm is in the netpbm package, and ppmtolss16 is in the syslinux package.
copy the output (splash.rle) into extracted_cd/isolinux/
Cleaning up the extracted image
Ok, here's the deal: If you deleted files, the corresponding blocks in the extracted_fs file aren't zeroed. Therefore, as far as the create_compressed_fs program (which compresses the extracted_fs image) is concerned, the files are still there. As a result, files you delete won't really improve the amount of free space :(.
So, a quick workaround is to copy the old image onto a new one:
$ sudo mkdir mnt.new $ sudo dd if=/dev/zero of=extracted_fs.new bs=1M count=2000 $ sudo mkfs.ext2 extracted_fs.new $ sudo mount -o loop,noatime,nodiratime extracted_fs mnt $ sudo mount -o loop,noatime,nodiratime extracted_fs.new mnt.new $ sudo rsync -avx --progress mnt/. mnt.new/. $ sudo umount mnt mnt.new
Now, you have a new image, extracted_fs.new, that's both defragmented and cleaned with zeros.
Putting the CD back together
OK, almost done. We only have to pack up the CD.
First compress the compressed filesystem and put it back on the CD (Another cup of tea required here):
$ sudo create_compressed_fs extracted_fs.new 65536 > extracted_cd/casper/filesystem.cloop
TIP: If you'd like better compression (MantasKriaučiūnas: don't use cloop-utils from Ubuntu 5.10 with --best, because this version doesn't use 7zip compression and doesn't produce better compression), but with a SIGNIFICANTLY SLOWER (5-fold, at least) process, use:
$ sudo create_compressed_fs --best extracted_fs.new 65536 > extracted_cd/casper/filesystem.cloop
Then generate md5sum.txt file:
$ (cd extracted_cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)
Then we re-build the cd. NOTE: This procedure is specific to the Intel x86 (i386) and x86_64 (amd64) live CDs. Other architectures, such as PowerPC and IA64, will require different command line options.
$ sudo mkisofs -r -V "Custom Ubuntu Live CD" \ -cache-inodes \ -J -l -b isolinux/isolinux.bin \ -c isolinux/boot.cat -no-emul-boot \ -boot-load-size 4 -boot-info-table \ -o custom-breezy-live-i386.iso extracted_cd
On PowerPC, download [http://people.ubuntu.com/~cjwatson/hfs.map], then use the following command:
$ sudo mkisofs -r -V "Custom Ubuntu Live CD" \ --netatalk -hfs -probe -map hfs.map \ -chrp-boot -iso-level 2 -part -no-desktop \ -hfs-bless extracted_cd/install \ -hfs-volid Ubuntu/PowerPC_breezy \ -o custom-breezy-live-powerpc.iso extracted_cd
On ia64:
$ sudo mkisofs -r -V 'Custom Ubuntu 5.10 live ia64' \ -o custom-breezy-live-ia64.iso -no-emul-boot \ -J -b boot/boot.img -c boot/boot.catalog extracted_cd
And we are done!
Useful scripts: livecd_tools
All the above commands are resumed in this set of scripts: [attachment:livecd_tools-0.0.1.tgz livecd_tools v0.0.1]. This package includes the following commands:
livecd_extractcd: Extracts the Live CD content and uncompress the compresed filesystem. Needs to run as root, it mounts the iso using the loop device
livecd_createcd: Compress the filesystem and creates the Live CD iso image.
livecd_mountfs: Mount a filesystem with a linux instalation, mounting temporal directories with tmpfs.
livecd_umountfs: umount a filesystem with a linux instalation, umounting temporal directories
livecd_swap: Creates and activates a temporal swap file
With this tools you can do:
# ./livecd_tools-0.0.1/livecd_extractcd ubuntu-live.iso # ./livecd_tools-0.0.1/livecd_mountfs -t livecd_fs.ext2 mnt ... Modify the instalation ... # ./livecd_tools-0.0.1/livecd_umountfs mnt # ./livecd_tools-0.0.1/livecd_swap start # ./livecd_tools-0.0.1/livecd_createcd myubuntu-live.iso
This scripts accept options to tune paths. Read Readme.txt
More information
The LiveCD is based on the Ubuntu installer and uses its infrastructure to bootstrap the system. An additional installer component (casper) is used to load the live environment after bootstrap is complete.
Perhaps you can find more information here: LiveCDDesign, LiveCD. Or look at the code by downloading casper and the debian installer (apt-get source casper debian-installer). NOTE: no source code modifications of any kind are necessary in order to customize live environment (for example, installing additional packages). This is purely informational.
From GrantEmsley Tue Apr 12 17:31:58 +0100 2005 From: Grant Emsley Date: Tue, 12 Apr 2005 17:31:58 +0100 Subject: Live DVD Message-ID: <20050412173158+0100@www.ubuntulinux.org>
Would I do the same thing to make a Live DVD? I assume some steps (esp. the mkisofs command) would be different for a DVD.
From unknown Sun May 8 05:34:13 +0100 2005 From: Date: Sun, 08 May 2005 05:34:13 +0100 Subject: Message-ID: <20050508053413+0100@www.ubuntulinux.org>
This page belongs in Releases >> HoaryHedgehog >> LiveCD >> not in Releases >> WartyWarthog >> LiveCD >>
From unknown Sun May 8 05:37:34 +0100 2005 From: Date: Sun, 08 May 2005 05:37:34 +0100 Subject: InstallCDCustomizationHowTo InstallDVDCustomizationHowTo
- liveDVDCustomizationHowTo
Message-ID: <20050508053734+0100@www.ubuntulinux.org>
are the InstallCDCustomizationHowTo, InstallDVDCustomizationHowTo, liveDVDCustomizationHowTo available,.. planned?
From JordiMassaguerPla Tue Jun 7 18:14:34 +0100 2005 From: Jordi Massaguer Pla Date: Tue, 07 Jun 2005 18:14:34 +0100 Subject: needed enough swap space Message-ID: <20050607181434+0100@https://www.ubuntulinux.org>
In order to use the "create_compressed_fs" tool, you must have enough swap space. Having enough swap space, means having a big swap partition and, in some cases, cleaning it. By having enough I mean around 5Gb (at least). Cleaning the swap parition could be done like this (before using the create_compressed_fs):
sudo mkswap /dev/hda4 sudo swapon -a
Replace /dev/hda4 by your swap partition Be very careful when cleaning your partition. Make sure that you do it on your swap partition and that you are not running any crucial programs that could be using your swap space. Also, be very careful if you resize your swap partition, and thus, you change your partition table.
From LuisVilla Tue Jun 7 18:24:55 +0100 2005 From: Luis Villa Date: Tue, 07 Jun 2005 18:24:55 +0100 Subject: swap space size Message-ID: <20050607182455+0100@https://www.ubuntulinux.org>
Jordi, are you sure on that? I've been making liveCDs with only 1.5G of swap (though tons of other free space.) Are you sure you're not confusing swap and other free space?
From ArneCaspari2 ( Arne Caspari )
Debconf Questions
To skip all questions during startup ( ie. let the CD not to ask for the screen resolution ), add DEBCONF_PRIORITY=critical to the APPEND string in extracted_cd/isolinux/isolinux.cfg.
Default User
The easiest way to create a usefull default for the live CD user is to boot once with the customized CD, then do all the actions to create the default settings ( ie. change the desktop background; create symlinks on the Desktop and so on ). Then log out and select "Save current setup" on the logout window ( this will save the session obviously so all windows that are still open while logging off will be opened when the CD starts ). After logout, change to a console ( eg. by pressing CTRL+ALT+F1 ) and create a TAR archive of the user's home directory. Copy this archive to a permanent storage ( ie. a network share or onto an USB stick ). Put the contents of the TAR archive into mnt.extracted_fs/etc/skel and recreate the CD. The new defaults will be copied when the user is created during the boot process.
Accelerate the CD Creation Process
This sounds strange and your mileage may vary according to your system/graphics card: I build the CD on a system with an SIS chipset which is possibly not too well accelerated. The actions that give plenty of output to the console ( ie. the rsync step or the create_compressed_fs step ) run significantly slower because the terminal takes up too much time drawing the text. They run way faster if the terminal is minimized while they run but if you want to see the progress of these commands, resizing the window to show only two lines of text also helps. ( Maybe running the commands on a text only console might also perform better ).
Testing the CD
The obvious tip to test the CD is to use rewritable CDs until you are realy happy with the result. But another tip to just check if the CD still boots correctly after making big changes is to boot the ISO image with qemu. QEMU is available in the universe repository. Run it like this:
$ qemu -cdrom liveimage.iso -boot d
It might be a bit slow but at least it squares a burn/reboot/test/reboot cycle.