Create your own customized Ubuntu Live CD

Jack Wallen
Nov 16, 2009
Updated • Nov 28, 2012

Here on Ghacks I have mentioned a few tools that allow you to create various types of Linux CDs. Most of these tools allow you to create Live CDs that are either images of your current working distribution or tools to create a Live CD with special packages. But none of these tools, so far, have allowed you to really get customized with your Live CD. You can't specify desktop backgrounds or other configuration options. These are tasks that can really make creating a customized Live CD worth the effort.

In this article I am going to show you how to take a downloaded Ubuntu 9.10 iso image, mount it, customize it, and rebuild the Live CD from your newly customized image. This process can be time consuming, but is worth it. This entire process will be done from the command line, so get your fingers ready to type.

The first thing you are going to need is an ISO image of a recent release. So hop on over to Ubuntu's web site and download a fresh copy of 9.10. Once that is done you are ready to get to work.

Before you continue with the customization, you need to install some tools that will be necessary. From the command line issue this command:

sudo aptitude install squashfs-tools genisoimage

Now create an empty directory that will be used to work with the ISO image. Let's create this in your users home directory, so issue the command:

mkdir ~/LIVECD

Now move that freshly downloaded iso image to the new directory and get ready to work.

The first thing to do is to mount the ISO image with the command. You will need to create a subdirectory to mount the image to, so issue the command:

mkdir ~/LIVECD/mount

Now mount the iso with the command:

sudo mount -o loop ubuntu-9.10-desktop-i386.iso ~/LIVECD/mount/

Now you will need to create yet another directory that you will then extract the contents of ~/LIVECD/mount to. Issue the command:

mkdir ~/LIVECD/extract-cd

And then extract with the command:

rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd

Now extract the squashfs file system with the command:

sudo unsquashfs mount/casper/filesystem.squashfs

sudo mv squashfs-root edit

The former of the above two commands will take some time. That is normal.
If you will need network access with this system (and you probably will) you will need to edit the /etc/resolv.conf file so it has the proper DNS addresses. To do this just copy your current working resolve.conf file into the ~/LIVECD/edit/etc directory with the command:

sudo cp /etc/resolve.conf ~/LIVECD/edit/etc/

Now to mount some important directories on your system:

sudo mount --bind /dev/ edit/dev
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

It will be very important later on to unmount these directories.

Next we make it so we avoid any locale issues and allow us to import GPG keys (if necessary) we issue the commands:

export HOME=/root

export LC_ALL=C

Now you can view all packages installed on the mounted ISO with the command:

dpkg-query -W --showformat='${Package}\n' | sort -nr | less

You can go through that list and delete any package you don't want on the Live CD with the command:

aptitude purge PACKAGE_NAME

Where PACKAGE_NAME is the name of the package you want to remove. You can then install new packages on the Live CD by issuing the command:

aptitude install PACKAGE_NAME

Where PACKAGE_NAME is the name of the package to install.

What about desktop background images? Yes, you can customize this as well. If you look at the file /usr/share/gnome-background-properties/ubuntu-wallpapers.xml you will see where the default background is configured. You can edit that file, but then you will have to make sure the .png file you want to use is located in /usr/share/gconf/defaults/16_ubuntu-wallpapers.

You can also edit the /etc/gconf/gconf.xml.defaults/%gconf-tree.xml file to make any additional customization changes (fonts, colors, panel options, etc) within that file. Understand that what this file is a blank file which you will add new default values to. If you would rather just use the gconftool to edit these values you can do so with a command like:

gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set KEY "VALUE"

Where KEY is the key you want to change and VALUE is the value to set for the key.

There are a ton of other possible configurations you can undertake here. But for the scope of this article, we'll leave it with what we have.

It's time to make sure to remove any temporary files that might be left behind from any package installation with the command:

aptitude clean

You can also remove the /etc/resolv.conf file you added with the command:

rm /etc/resolv.conf

Time to unmount the directories:

umount /proc
umount /sys
umount /dev/pts
sudo umount edit/dev

Put it all back together

Now it's time to piece everything back together. First you have to regenerate the manifest:

chmod +w extract-cd/casper/filesystem.manifest
sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop

Now to compress the file system:

sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs

The above command will take some time.

Now open up the ~/LIVECD/extract-cd/README.diskdefines file and make any necessary changes.

The next step requires you to remove the old md5 sums and calculate new sums. Do this with the following commands:

cd extract-cd
sudo rm md5sum.txt
find -type f -print0 | xargs -0 md5sum | grep -v isolinux/ | sudo tee md5sum.txt

Now it's time to create the ISO image. Do that with the following commands:

sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-9.04.1-desktop-i386-custom.iso .

Now, in the ~/LIVECD directory you will have your new ISO to burn to disk and use.

Congratulations, you just created your own customized Ubuntu Live CD!


Previous Post: «
Next Post: «


  1. Regimantas said on August 21, 2011 at 8:23 pm

    change last command to:

    cd ..

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

  2. Bob said on December 4, 2009 at 4:01 am

    after the text:
    mkdir ~/LIVECD

    you should add:
    cd ~/LIVECD

    the text:
    rsync –exclude=/casper/filesystem.squashfs -a mnt/ extract-cd

    should read:

    rsync –exclude=/casper/filesystem.squashfs -a mount/ extract-cd

  3. lefty.crupps said on November 16, 2009 at 2:48 pm

    Ubuntu already has plenty of remixes and remastering apps. Care to show us how to do this for a Debian Sid or Testing installation disk?

  4. yeahright said on November 16, 2009 at 3:39 pm

    I’ve found Remastersys to be an easier way for non Linux peeps to make a LiveCD and or mini distro. Configure the OS hands-on and then use Remastersys to make the new LiveCD image.

  5. stlouisubntu said on November 16, 2009 at 7:38 am

    Thanks for this great tutorial! Question: What would need to be changed for this procedure to work to customize an alternate install CD? (to basically modify the packages to be installed by default — i.e. vlc instead of totem, thunderbird w/lightening instead of evolution, etc.) What I want to do is to make a LXDE desktop alternate install CD for the powerpc (on old slow, low RAM, iMac G3s.)

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.