Remastering Ubuntu Edgy

This information was taken from and is largely the same

How do you make a local version of Ubuntu? There are three ways to proceed

  1. Install the system on a real computer, tinker with it,
    • and then make an image snapshot of the disk.
  2. Remaster the Install CD. This gives the most control,
    • but takes a little more thought and understanding
  3. Remaster the Live CD. Starting with the Edgy Drake,
    • the live system has an installer program, which it is quite easy to influence

For the sake of simplicity, I have experimented with the last of these methods, and explain my workings below.

This recipe has been tested with Ubuntu Edgy.

The Live CD installer works by copying the working system onto the target system, with some preparation and cleaning up.


Get yourself a large amount of disk. You'll need an ext2 partition to work in with 2.5 gbytes, space for several copies of the compressed file system (another couple of gbytes). You'll also need the squashfs package installed.

First get a handle on the ISO image:

mount -o loop dapper.iso /mnt

now copy all of that to a working location with a 1Gb free. Lets call that $CD:

rsync -ax /mnt/. $CD/

Edit $CD/isolinux/isolinux.cfg to add

preseed/locale=en_GB kbd-chooser/method=gb DEBCONF_PRIORITY=critical

to get language right and stop it asking too many questions, but thats about all that is needed in the main CD directory. You can kill programs and disctree to save space if needed.

Now you can dismount the CD:

umount /mnt

Next we need to unpack the real working file system, which is inside a compressed filesystem on the CD setup. You can get at it with

mount $CD/casper/filesystem.squashfs /mnt -t squashfs -o loop

I find it easiest to copy this to a directory on disk. Make this on an ext2 partition, however. Lets call that $Source; copy over the contents, and unmount the file system:

rsync -av /mnt/. $Source/.
umount /mnt

Setting up the new system

Now you can start the real work, by doing sudo chroot $Source and adding or deleting packages. You'll want to tinker with /etc/apt/sources.list to add local repositories, or enable eg Ubuntu multiverse. That's needed for Sun Java. If you are wanting to connect to a network cp /etc/resolv.conf $Source/etc/ to move your settings across from the working operating system.

If you do install Java, you'll need to change the setup to let it prompt you for license agreement. This is done with

dpkg-reconfigure debconf

and choosing dialog. Now you can get Java with

apt-get install sun-java5-jdk

but you'll also probably need to make it the default, with

 update-alternatives  --config java

My changes are quite complex, as I want to install a web server, Tomcat, an XML database and a lot of TEI stuff. This is the script I run:

echo update repository
apt-get update
dpkg-reconfigure debconf
echo Make some sapce
apt-get remove  \
        evolution  \
        evolution-data-server  \
        gnome-games  \
        gnome-games-data  \
        sun-java5-demo  \
        ttf-arphic-ukai  \
        ttf-arphic-uming  \
        ttf-baekmuk  \
        festival \
        festlex-cmu \
        festlex-poslex \
echo Some adds
apt-get install  \
        openssh-server  \
        abcde   \
        apache2  \
        deborphan  \
        emacs21  \
        gnumeric  \
        libapache2-mod-php5  \
        php5  \
        php5-cli  \
        php5-common   \
        php5-xsl   \
        subversion \
        sun-java5-jdk  \
        tidy  \
update-alternatives  --config java
echo Now some removes
echo More adds preparatory to TEI
apt-get install jakarta-tomcat
apt-get install cocoon
apt-get install exist
echo Add TEI packages
apt-get install tei-emacs trang-java saxon xmlstarlet jing
apt-get install \
        tei-oxygen  \
        tei-p4-doc  \
        tei-p4-lite  \
        tei-p4-schema  \
        tei-p4-xsl  \
        tei-p5-doc  \
        tei-p5-exemplars  \
        tei-p5-schema  \
        tei-p5-source  \
        tei-p5-test  \
        tei-p5-xsl  \
        tei-roma  \
echo Add TEI packages which need tomcat
mount -t proc none /proc
/etc/init.d/jakarta-tomcat start
apt-get install tei-p5-database
apt-get install tei-teaching
umount /proc
/etc/init.d/jakarta-tomcat stop

If you do tricksy stuff like starting up Tomcat inside the chrootted system, you need to make sure it is closed down in the main system first, and properly stopped inside the chrooted system when you are done with your work. In the example above, I need to get it running to start up the eXist database so that I can add my data.

Anything you put into /etc/skel gets copied into the new user space. So to set up defaults on the desktop, browser bookmarks, etc, boot up with the Live CD, and make things just the way you want them. Before you shut down, make a copy of the home directory on a USB key or another computer, and use that to people /etc/skel in your master system.

Don't forget to set up a site for the web server, if you have provided that,

Preparing for the CD

Finished fooling around? Now you can get out of the chrooted environment and make the CD image.

There are some small but important steps to take first, however. The CD wants a list of the packages on your system, which you can get using dpkg-query, using this recipe:

chroot $Source dpkg-query -W --showformat='${Package} ${Version}\n' \
        | grep -v deinstall > $CD/casper/filesystem.manifest

When the Live installer runs, it copies everything to the target system, but then cleans up by removing packages which are not listed in a second manifest file. This stops the target system inheriting the installer, for example.

I manage this by filtering the manifest we just created using a sed script:

cat > /tmp/$$.control <<FOO
sed -f /tmp/$$.control < $CD/casper/filesystem.manifest > $CD/casper/filesystem.manifest-desktop
rm /tmp/$$.control

Influencing the live installer

When the user runs your remastered CD and does the install, how can you get the default choices changed? Surprisingly easily, because the install systems for Debian make use of a concept they call 'preseeding', which means supplying answers to the questions an install program asks. You can get the current answers to questions on a system by doing


If you save that to a file, and edit it as needed, you can use the result to set up the system you are creating. I keep my answers in a file called preseed.cfg and get them on my new system as follows:

chroot $Source debconf-set-selections <  preseed.cfg

This preseed file is not trivial to understand. An older manual at should help somewhat, but be prepared to do some head-scratching.

Compresssing the file system

Time to take that tree in $Source we were working on, and squash it down. Easy:

rm $CD/casper/filesystem.squashfs
mksquashfs $Source/ $CD/casper/filesystem.squashfs

This takes 15-20 minutes, so have a cup of tea now.

Finally, update the md5sums on the CD system:

cd $CD && find . -type f -print0 | xargs -0 md5sum > md5sum.txt

Making the CD image

This should be familar stuff if you are using to making CD images:

mkisofs    \
 -r    \
 -V "Custom Ubuntu Live CD"    \
 -cache-inodes    \
 -J    \
 -l    \
 -b isolinux/isolinux.bin    \
 -c isolinux/    \
 -no-emul-boot    \
 -boot-load-size 4    \
 -boot-info-table    \
 -o /tmp/MyCD.iso "$CD"

The result in /tmp/MyCD.iso can be burnt to disk and tried. If you have VMWare, it is faster to test it by setting up a new VM and making the ISO image by the CD drive.

Obviously, if the image is over 700 Mbytes, you'll need to burn the image to a DVD instead of a CD. That should just work, up to 2 gigabytes.

OSSWatchWiki: UbuntuEdgy/Remaster (last edited 2013-04-15 13:56:28 by localhost)

Creative Commons License
The content of this wiki is licensed under the Creative Commons Attribution-ShareAlike 2.0 England & Wales Licence.

OSS Watch is funded by the Joint Information Systems Committee (JISC) and is situated within the Research Technologies Service (RTS) of the University of Oxford.