No public Twitter messages.
  • facebook
  • twitter
  • linkedIn

Custom Ubuntu Server ISO

  • August 24th,
  • by Razvan Gavril

Remastering the Ubuntu Desktop ISO is easy considering the existing graphical tools but did you ever wanted to build your custom Ubuntu Server Edition ISO ?

Preparing the Environment

You’ll need a clean copy of the Ubuntu Server ISO that you want to customize. Since 10.04 is the latest Ubuntu version I will write down my examples using it but everything should work pretty much unchanged for older or newer versions.

After you have you have the original iso image downloaded, make a copy it’s contents so we can later apply our patching there.

cd /home/rgavril/Work

mkdir original-iso custom-iso
mount -o loop ./ubuntu-10.04-server-i386.iso ./original-iso

cp -r ./original-iso/* ./custom-iso/
cp -r ./original-iso/.disk/ ./custom-iso/

umount ./original-iso/

Adding a Boot Menu Option

For start let’s add a option to the cd boot menu. You’ll need to modify isolinux/text.cfg and insert the next lines between default install and label install:

label custom
  menu label ^Install Custom Ubuntu Server
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-custom.seed initrd=/install/initrd.gz quiet ks=cdrom:/isolinux/ks-custom.cfg --

This newly added block is very similar to the label install one. The two important additions being the file and ks boot options that I will later explain.

If you want to make your menu option the default one, you only need to change the default install to default custom or whatever you used as a label.


KickStart is a unattended installation method developed by Red Hat and later adopted and adapted by Debian and Ubuntu. To keep it short, the Ubuntu installer can read an external file and figure out how to configure the system (create partitions, set timezones and keyboard layouts ..) without asking the user.

There’s no need to write everything using a text editor as we have a powerful tool to create such configuration files:

apt-get install system-config-kickstart

After creating your ks.cfg file, you will need to move it on the custom-iso/ at the path specified in text.cfg. That’s the location where the ubuntu installer will look for it.

cp ks.cfg custom-iso/isolinux/ks-custom.cfg

Preseeding Packages

The installer in not the only one that may present questions to the user. When installed, some package rely on the user to explicitly set different parameters.

Preseeding is the action of setting, in advance, this kind of package parameters. It’s a very powerful method that you can use even for replacing kickstart. In this article, I’ll use it as a addition to kickstart as is more harder to tune the ubuntu installer, mostly because it lacks a gui.

The params can be set trough a configuration file specified by the file in text.cfg. I recommend starting with the existing preseed file from the original cd:

cp custom-iso/preseed/ubuntu-server.seed custom-iso/preseed/ubuntu-custom.seed

Using debconf-get-selections from the debconf-utils package you can look over a running ubuntu system to figure out what parameters you can tune. For example here are the possible configuration settings for the openssh-server together with their values :

root@xps1330:~/work# debconf-get-selections | grep openssh
openssh-server	ssh/vulnerable_host_keys	note
openssh-server	ssh/use_old_init_script	boolean	true
openssh-server	ssh/encrypted_host_key_but_no_keygen	note
openssh-server	ssh/disable_cr_auth	boolean	false

Adding Extra Packages

Ubuntu’s ksconfig utility does’n provide a way to select extra packages as the Package Selection is not working. In order to specify what extra packages you want to install you’ll need to modify the kickstart configuration file by hand.

vim custom-iso/isolinux/ks-custom.cfg

Depending on the extra packages that you want to install by default, add some similar lines to the end of the file :


Offline Installation

When having additional packages installed by default, there’s a big chance are that those particular packages may not be on the default iso. If you have an active internet connection during the install, the packages will be automatically fetched from the online repositories. But if you’re internet connection is not working, the install process will fail. In order to prevent the problem and create a offline installable cd, you’ll need to perform some extra steps.

You’ll need to downloading and copying the extra debs and all their dependencies on your iso. Please note that in doing so you may increase the iso size a lot and be forced to use a dvd.

It’s very hard to figure out what debs are missing from your iso. In order to make a list of needed debs I use the following steps:

  • On a virtual machine, install a ubuntu server using the original cd image.
  • Boot the newly installed ubuntu server, make sure the cd is mountable and cdrom directive is available in sources.list
  • Do an apt-get install of the extra packages that I want to have installed by default
  • Make a backup of the debs located in /var/cache/apt/archives as this are the missing ones that need to be on the iso

Considering that you downloaded the extra packages, and that they are located in the extradebs/ directory within the current folder. You will need to copy them on the cd and create a repository by running this commands:

mkdir -p custom-iso/dists/stable/extras/binary-i386
mkdir -p custom-iso/pool/extras/

cp ./extradebs/*.deb custom-iso/pool/extras/

pushd custom-iso
apt-ftparchive packages ./pool/extras/ > dists/stable/extras/binary-i386/Packages
gzip -c ./dists/stable/extras/binary-i386/Packages | tee ./dists/stable/extras/binary-i386/Packages.gz > /dev/null

Generating the new ISO

All you need to do now is build you new iso and give it a test drive to see how it works:

mkisofs -J -l -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -z -iso-level 4 -c isolinux/ -o ./ubuntu-10.04-custom-i386.iso custom-iso/

26 Comments Post a comment ↓

  1. diemos said:

    So, I’ve followed this walkthrough to a T, as best I could…

    It gave me “Permission Denied” in a few of the steps where I had to copy new files into the custom-iso folder.

    The following commands gave me these problems:
    [code]mkdir -p custom-iso/dists/stable/extras/binary-i386
    mkdir -p custom-iso/pool/extras/

    cp ./extradebs/*.deb custom-iso/pool/extras/

    apt-ftparchive packages ./pool/extras/ > dists/stable/extras/binary-i386/Packages
    gzip -c ./dists/stable/extras/binary-i386/Packages | tee ./dists/stable/extras/binary-i386/Packages.gz > /dev/null

    Also, if you don’t add the extra packages at the end of ks-custom.cfg, will it still install them?


    October 4, 2010

  2. Razvan Gavril said:

    @diemos : I written down most of the tutorial from memory and I usually run the commands myself as root. Let me know what problem you had and I will correct my article.

    If you don’t add the extra packages to ks-custom.cfg, the packages will not get installed by default, even if they are on the iso.

    October 5, 2010

  3. Janderson said:

    Hello I am doing your tutorial, but to perform the installation in a VM to test and load additional components the server returns me: “Failed to copy from CD-ROM. Retry?”. Well what I did was changed to resolve the row by generating the iso here:
    mkisofs -D -r -V “Custom Install CD” -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -o custom.iso /opt/ubuntu-server/. Sorry, i’m not speak english. Thanks for tutorial .

    December 10, 2010

  4. rakesh said:

    Hi razvan,

    I want to do offline installation of *.deb packages using Ubuntu server iso image. (Maverick 10.10). Can you tell me the steps needed to do it. ? Manually doing them using “sudo dpkga -i package.deb” is taking lot of time as we have to add each and every dependent package.

    March 7, 2011

  5. haruman said:

    you need to run an md5sum check again to rebuild it if you add/del files

    ie, md5sum `find ! -name “md5sum.txt” ! -path “./isolinux/*” -follow -type f` > md5sum.txt

    then generate your iso!

    May 5, 2011

  6. Michael Wilson said:

    I can’t seem to get my %post commands %end to run. As soon as grub is installed the system reboots. Any idea what I might be doing wrong?

    June 23, 2011

  7. kris weston said:

    Hi, theres actually a script to do this which ive been hacking around – check it out:

    learned a few things here. thanks!

    July 7, 2011

  8. Pratap said:

    Hi Razvan,

    Thanks for this tutorial on customisation.
    I followed this tutorial I am not able to install extra packages,(gnome-session)

    November 16, 2011

  9. alsury said:

    Hello :)
    after all this steps i can,t founded my extra package(Offline Installation )
    and this is a message after the last command
    Warning: Creating ISO-9660:1999 (version 2) filesystem.
    Warning: ISO-9660 filenames longer than 31 may cause buffer overflows in the OS.
    Warning: creating filesystem with Joliet extensions but without Rock Ridge
    extensions. It is highly recommended to add Rock Ridge.
    Warning: using transparent compression. This is a nonstandard Rock Ridge
    extension. The resulting filesystem can only be transparently
    read on Linux. On other operating systems you need to call
    mkzftree by hand to decompress the files.
    Warning: transparent decompression is a Linux Rock Ridge extension, but
    creating filesystem without Rock Ridge attributes; files
    will not be transparently decompressed.
    genisoimage: Symlink custom-iso/ubuntu ignored – continuing.
    genisoimage: Symlink custom-iso/dists/stable ignored – continuing.
    genisoimage: Symlink custom-iso/dists/unstable ignored – continuing.
    genisoimage: Symlink custom-iso/install/netboot/pxelinux.cfg ignored – continuing.
    genisoimage: Symlink custom-iso/install/netboot/pxelinux.0 ignored – continuing.
    Size of boot image is 4 sectors -> No emulation
    1.43% done, estimate finish Sun Jan 29 11:50:22 2012
    and thanks

    January 29, 2012

  10. Ken Larson said:

    I found that these instructions worked great for installing in VMWare, but when I put the ISO on a USB stick and install on a real PC, I get a very brief (so brief I had to take a movie with my phone to read it) error:
    /lib/kickseed/initrd-kickseed: line 133: can’t open /cdrom/isolinux/ks-custom.cfg: no such file

    The PC was happy if I specified the path in text.cfg to be “syslinux” instead of “isolinux”, but vmware didn’t like that.

    The fix I found was to put the ks-custom.cfg file in the preseed folder instead of the iso, and reference it in text.cfg as:


    And this works from both VMWare, and a real PC

    April 30, 2012

  11. Abed Dabbas said:

    I was wondering if I can get your permission to use this info to answer a question on a Q&A site.


    July 5, 2012

  12. Mustafa said:

    Hi, for offline packages I copied all the dependencies with the package itself however in the installation it says it cannot find my package. However both deb files and the Packages & Packages.gz is present in the locations you mentioned what can I do now?

    July 9, 2012

  13. srijanss said:

    Hi Razvan I am having problem during installation of extra packages (in case of Offline Installation). It says that Select and Install software failed!!
    I have also tried to generate md5sum and still the error is same.

    August 25, 2012

  14. OrazioPirataDelloSpazio said:

    Problems with “cd-rom integrity”?

    I tried it with ubuntu server 12.04 and installation aborted because of some md5 of some files cannot be verified (the installer suggest that the cd-rom is broken).

    The real reason is that package with long filename are truncated during the mkisofs.

    The solution is to add the “-joliet-long” option to the mkisofs in the last step of this good tutorial! :)

    August 28, 2012

  15. Installing Ubuntu Server 12.10 on a Mac Mini (Late 2012) | Werner Strydom said:

    [...] Creating a custom installation of Ubuntu [...]

    January 13, 2013

  16. Installing Ubuntu Server 12.04 on a Mac Mini (Late 2012) | Werner Strydom said:

    [...] Creating a custom installation of Ubuntu [...]

    January 13, 2013

  17. Ubuntu Server 12.04: How does one configure the firewall during installation? - Admins Goodies said:

    [...] following instructions to automate the installation of Ubuntu Server 12.04 using kickstart. It works well for [...]

    January 14, 2013

  18. Howard said:

    Thanks, it works for me!

    February 12, 2013

  19. comarius said:

    With: ubuntu-13.04-server-amd64.iso, just mounting, copying, re-iso-ing fails to boot
    as DVD and in virtual box. Any workaround.
    Thank you, Razvane.

    $sudo mount -o loop ./image/ubuntu-13.04-server-amd64.iso original_iso
    $sudo rsync -rav original_iso/ ./custom_iso/
    $mkisofs -r -V “MY-UBUNTU” -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -o theiso.iso /custom_iso/

    September 30, 2013

  20. Installing new kernel within Linux kickstart | Joe Kuan Defunct Code said:

    [...] The above dpkg line is basically to install the kernel image package file pre-packed inside the installer ISO. So that the installer can work straight offline. For details on how to create an installer ISO with pre-packed packges, see this link. [...]

    October 11, 2013

  21. khalil said:

    xml = (“/usr/share/system-config-kickstart/”, domain=domain)

    November 1, 2013

  22. marius said:

    you cd right from start into
    cd /home/rgavril/Work
    then you mention the
    You’ll need to modify isolinux/text.cfg..
    than later on you mention
    Can you be more precise which one these folders are.

    March 10, 2014

  23. Installing Ubuntu Server 12.04 on a Mac Mini (Late 2012) - Werner StrydomWerner Strydom said:

    [...] Creating a custom installation of Ubuntu [...]

    March 24, 2014

  24. Installing Ubuntu Server 12.10 on a Mac Mini (Late 2012) - Werner StrydomWerner Strydom said:

    [...] Creating a custom installation of Ubuntu [...]

    March 24, 2014

  25. vallabh said:

    Very nice information,I am trying it on VMplayer but showing initramfs screen
    BusyBox V1.21.1 ……….

    Please provide me solution

    July 31, 2014

  26. hoiis said:

    mkisofs -r -v

    August 19, 2014

Leave your comment: