How to make a Custmized Ubuntu live DVD

How-To: Customize your Ubuntu Live CD

Live CD are great, they let you try out a distribution without installing it. They allow you to run your favorite distribution on any computer and on the top of this, they become handy to recover a system.

Ubuntu live CD is already packed up with some pretty nifty software that allow you to do pretty much everything with the Live CD, but still, they might be some software you don’t need that are include with it or, some software you need might be missing.

Another Pro for this is that by customizing your image, you will be able to install

This tutorial will show the steps to follow in order to customize an Ubuntu Live CD to your need by removing some component and adding some others.

During this tutorial, we are going to remaster our Ubuntu Gutsy Gibbon 7.10 Live CD with the following spec:

  • remove non english language pack
  • Update the softwares release shiiped in the live CD
  • Enable universe and multiverse repository
  • Include divx, mp3 support, realplayer ….
  • Include ndiswrapper support
  • Add Firefox flash-nonfree plugin, add skype.
  • Add some network troubleshooting tools: traceroute, wireshark, kismet…

The resulting image will be bigger that 800M, so it won’t fit on a CD, but will be fine on a DVD.

1. Preparing the host

First of all, we need to get the current karmic Live CD image and store it let say on ~/Desktop , also, we will need to install an extra piece of software to rebuild our karmic live CD’s squashfs:

$ sudo apt-get install squashfs-tools chroot

Now let’s get started by setting up our working environment. First, we are going to mount the iso under /tmp/livecd:

$ mkdir /tmp/livecd
$ sudo mount -o loop ~/Desktop/ubuntu-9.10-desktop-i386.iso /tmp/livecd

Then create a directory containing our future CD image (cd) in our working directory (~/livecd) and copy all the CD content but casper/filesystem.squashfs in our ~/livecd/cd directory:

$ mkdir ~/livecd
$ mkdir ~/livecd/cd
$ rsync –exclude=/casper/filesystem.squashfs -a /tmp/livecd/ ~/livecd/cd

This copy all but the squashfs file, which is the compressed file containing our live CD filesystem.

Now we need to mount casper/filesystem.squashfs onto a directory called ~/livecd/squashfs in order to copy its content in a directory where we are going to edit our live CD filesystem: ~/livecd/custom

$ mkdir ~/livecd/squashfs
$ mkdir ~/livecd/custom
$ sudo modprobe squashfs
$ sudo mount -t squashfs -o loop /tmp/livecd/casper/filesystem.squashfs ~/livecd/squashfs/
$ sudo cp -a ~/livecd/squashfs/* ~/livecd/custom

And finally, let copy /etc/resolv.conf and /etc/hosts to our ~/livecd/custom/etc so we will be able to access network from within the image we are going to customize (through chroot):

$ sudo cp /etc/resolv.conf /etc/hosts ~/livecd/custom/etc/

2. Getting into our future image:

In order to customize the image, we will chroot into ~/livecd/custom directory, mount some necessary pseudo-filesystem (/proc and /sys). From there, we will be able to customize our Live CD.

$ sudo chroot ~/livecd/custom
# mount -t proc none /proc/
# mount -t sysfs none /sys/
# export HOME=/root

Now we are ready, let’s customize….

How-To: Customize your Ubuntu Live CD — page 2

3. Customizing our future live CD

3.1. Removing packages

First of all, we are going to remove non-english language pack, and in order to free some more space, we are going to remove gnome-games packages.

# apt-get remove –purge gnome-games*
# apt-get remove –purge `dpkg-query -W –showformat=’${Package}\n’ | grep language-pack | egrep -v ‘\-en’`

Mind that you might want to remove some other software. In order to see installed software, you can run the following:

# dpkg-query -W –showformat=’${Package}\n’ | less

3.2. Updating the existing image

Now that we have remove softwares we do not need, we can update our /etc/apt/sources.list in order to enable universe and multiverse repository along with gutsy-updates, gutsy-security and the partner repository so we can install vmware-server.

Open and edit /etc/apt/sources.list

# vim /etc/apt/sources.list

and make it look like:

deb http://archive.ubuntu.com/ubuntu karmic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu
karmic main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu karmic-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu
karmic-updates main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu karmic-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu
karmic-security main restricted universe multiverse

deb http://archive.canonical.com/ubuntu karmic partner
deb-src http://archive.canonical.com/ubuntu
karmic partner

deb http://ppa.launchpad.net/openoffice-pkgs/ubuntu karmic main
deb-src http://ppa.launchpad.net/openoffice-pkgs/ubuntu karmic main

deb http://ppa.launchpad.net/compiz/ubuntu karmic main
deb-src http://ppa.launchpad.net/compiz/ubuntu karmic main

deb http://ppa.launchpad.net/netbook-remix-team/ubuntu karmic main
deb-src http://ppa.launchpad.net/netbook-remix-team/ubuntu karmic main

deb http://ppa.launchpad.net/lidaobing/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/lidaobing/ppa/ubuntu karmic main

deb http://ppa.launchpad.net/asac/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/asac/ppa/ubuntu karmic main

deb http://ppa.launchpad.net/globalmenu-team/ubuntu karmic main
deb-src http://ppa.launchpad.net/globalmenu-team/ubuntu karmic main

deb http://ppa.launchpad.net/themuso/ubuntu karmic main
deb-src http://ppa.launchpad.net/themuso/ubuntu karmic main

deb http://ppa.launchpad.net/zulcss/ubuntu karmic main
deb-src http://ppa.launchpad.net/zulcss/ubuntu karmic main

deb http://ppa.launchpad.net/q-funk/ubuntu karmic main
deb-src http://ppa.launchpad.net/q-funk/ubuntu karmic main

deb http://ppa.launchpad.net/ted-gould/ubuntu karmic main
deb-src http://ppa.launchpad.net/ted-gould/ubuntu karmic main

deb http://ppa.launchpad.net/hyperair/ubuntu karmic main
deb-src http://ppa.launchpad.net/hyperair/ubuntu karmic main

deb http://ppa.launchpad.net/bigon/ubuntu karmic main
deb-src http://ppa.launchpad.net/bigon/ubuntu karmic main

deb http://ppa.launchpad.net/gnomefreak/ubuntu karmic main
deb-src http://ppa.launchpad.net/gnomefreak/ubuntu karmic main

deb http://ppa.launchpad.net/marceloshima/ubuntu karmic main
deb-src http://ppa.launchpad.net/marceloshima/ubuntu karmic main

deb http://ppa.launchpad.net/freenx-team/ubuntu karmic main
deb-src http://ppa.launchpad.net/freenx-team/ubuntu karmic main

deb http://ppa.launchpad.net/bhavi/ubuntu karmic main
deb-src http://ppa.launchpad.net/bhavi/ubuntu karmic main

deb http://ppa.launchpad.net/scott/ubuntu karmic main
deb-src http://ppa.launchpad.net/scott/ubuntu karmic main

deb http://ppa.launchpad.net/intuitivenipple/ubuntu karmic main
deb-src http://ppa.launchpad.net/intuitivenipple/ubuntu karmic main

deb http://ppa.launchpad.net/suraia/ubuntu karmic main
deb-src http://ppa.launchpad.net/suraia/ubuntu karmic main

deb http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu karmic main

Now we can update the image by running:

# apt-get update
# apt-get dist-upgrade

3.3. Installing new packages

Let install all multimedia packages that we might need. As per http://www.debuntu.org/how-to-play-dvd-under-ubuntu-linux, we need to install:

# apt-get install gstreamer0.10-ffmpeg gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse vlc mplayer mplayer-fonts
# /usr/share/doc/libdvdread3/install-css.sh

Then, let install RealPlayer:

# wget http://www.debian-multimedia.org/pool/main/r/realplay/realplayer_10.0.9-0.1_i386.deb -O /tmp/realplay.deb
# dpkg -i /tmp/realplay.deb

Now, let’s install some utils that are not included by default on Ubuntu live cd but become handy most of the time:

# apt-get install rar unrar unace-nonfree

Plus, let’s install some wireless network utils so we might be able to get wireless functionning with the live CD:

# apt-get install ndiswrapper-common ndiswrapper-utils-1.9 cabextract unshield \
bcm43xx-fwcutter \
kismet aircrack-ng

Let’s add some other network network utility tools:

# apt-get install wireshark nmap ettercap traceroute

Also, we are going to add some firefox plugins:

# apt-get install flashplugin-nonfree mozilla-plugin-vlc

On the top of this, I want to be able to use skype and vmware-server:

# apt-get install libqt4-core libqt4-gui
# wget http://skype.com/go/getskype-linux-ubuntu -O /tmp/skype.deb
# dpkg -i /tmp/skype.deb
# apt-get install vmware-server

Well, that’s about it, we now have whatever software that we (I) will need when using our live CD.
It is now about time to do some clean up.

4. Cleaning up the chroot

When we install packages, apt caches the packages, we will need to remove them in order to save some space:

# apt-get clean

Also, there is some files in /tmp that need to be removed:

# rm -rf /tmp/*

Before chrooting, we have added 2 files: /etc/hosts and /etc/resolv.conf, let remove them:

# rm -f /etc/hosts /etc/resolv.conf

Finally, we are ready to exit the chroot and repack the CD. We need first to umount /proc and /sys:

# umount /proc/
# umount /sys/
# exit

Finally, we are back to our host, as we have modified some packages, we need to rebuild some manifest files, recreate the squashfs and recreate the ISO.

5. Recreating the ISO

Fisrt, lets recreate the manifest files:

$ chmod +w ~/livecd/cd/casper/filesystem.manifest
$ sudo chroot ~/livecd/custom dpkg-query -W –showformat=’${Package} ${Version}\n’ > ~/livecd/cd/casper/filesystem.manifest
sudo cp ~/livecd/cd/casper/filesystem.manifest ~/livecd/cd/casper/filesystem.manifest-desktop

And regenerate the squashfs file:

$ sudo mksquashfs ~/livecd/custom ~/livecd/cd/casper/filesystem.squashfs
Parallel mksquashfs: Using 2 processors
Creating little endian 3.0 filesystem on ~/livecd/cd/casper/filesystem.squashfs, block size 65536.
….
….

Now, alternatively, you might want to customize the file: ~/livecd/cd/README.diskdefines
and finally, update ~/livecd/cd/md5sum.txt which contains the files in ~/livecd/cd md5 sums:

$ sudo rm ~/livecd/cd/md5sum.txt
$ sudo -s
# (cd ~/livecd/cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)

We are now almost done, the last thing left is too create the ISO with the following command:

$ cd ~/livecd/cd
$ sudo mkisofs -r -V “Ubuntu-Live-Custom” -b isolinux/isolinux.bin -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -o ~/Desktop/Ubuntu-Live-7.10-custom.iso .

Here you go, you can now test your image by either booting your computer with or by using a virtualization/emulation software such as qemu, kvm, vmware…..

6. Conclusion

With a bit of work, one can customize an Ubuntu Live CD in order to remove/include some softwares, make sure the live CD is up-to-date, and on the top of this, allow administrator to deploy pre-customized Ubuntu distros.

The common mitake i found was in

sudo mkisofs -r -V “Ubuntu-Live-Custom” -b isolinux/isolinux.bin -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -o ~/Desktop/Ubuntu-Live-7.10-custom.iso . <===

the . <== represents current drectory

it will show an error genisoimage

add a space and . at the end


Advertisements

One comment

  1. apt-get remove –purge `dpkg-query -W –showformat=’${Package}\n’ | grep language-pack | egrep -v ‘\-en’`

    $ sudo chroot ~/livecd/custom dpkg-query -W –showformat=’${Package} ${Version}\n’ > ~/livecd/cd/casper/filesystem.manifest

    There is a difference between ’ and ‘
    Had to change ’ to ‘ everywhere en then it all worked like a charm.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s