47

I'd like to create a customized Ubuntu Server 12.04 ISO but couldn't find a clear approach on how to do it. I see that Ubuntu-builder is a very good app to create a customized Ubuntu Desktop, but what about Ubuntu Server?

0

1 Answer 1

68
+200

Download

Download the Ubuntu server ISO from this location. You have the option to go 32-bit or 64-bit. The file name for the server edition will look similar to this:

ubuntu-13.10-server-i386.iso 
ubuntu-13.10-server-amd64.iso 

I will assume the 13.10 64-bit version in the following instructions, so adjust the commands to the download you did. Keep a copy of your download so you can create multiple new versions from the original download in case you need to improve your project. I will also assume we use ~/Downloads/ to do all our work.

Initial setup

This will create 2 directories "iso" and "isoNew" inside your Downloads directory, mount the ISO and copy the contents from "iso" over to "isoNew" to start a new project.

Put this in a text file, save it, make it executable and execute it:

# Ubuntu custom server 
# rinzwind askubuntu.com
# topic: http://askubuntu.com/questions/409607/how-to-create-a-customized-ubuntu-server-iso/409651#409651
cd ~/Downloads/    
mkdir -p iso newIso
sudo mount -o loop ./ubuntu-13.10-server-amd64.iso ./iso    
sudo cp -r ./iso/* ./newIso/
sudo cp -r ./iso/.disk/ ./newIso/    
sudo umount ./iso/
cd ~/Downloads/newIso/
  • It will throw 1 error message: mount: block device /discworld/Downloads/ubuntu-13.10-server-amd64.iso is write-protected, mounting read-only

Example images on how this will look like:

Executing:

Executing

Result:

Result

Adding a Boot Menu Option

The menu options for the installer are stored in isolinux/txt.cfg and you can create new options in-between default install and label install.

This will create a new option called "Install Custom Ubuntu server" and it will add a kickstart file (the kickstart file is used to alter options; explained below):

label myownoption
  menu label ^Install Custom Ubuntu Server
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-custom.seed initrd=/install/initrd.gz quiet ks=cdrom:/preseed/ks-custom.cfg --
  • myownoption is just a label you can use to identify your option.
  • "Install Custom Ubuntu Server" is the text that will show up in the boot menu.
  • If you want to make your menu option the default one, you only need to change the default install to default myownoption.

Example:

enter image description here

and editing the file (I used nano but if available use gedit, vim or another editor). Here is my addition to this file where I used "lampserver" as a label and my seed will be named "lampserver" too.

enter image description here

Kickstart (graphically setting up a configuration file)

The Red Hat Kickstart installation method is used primarily (but not exclusively) by the Red Hat Enterprise Linux operating system to automatically perform unattended operating system installation and configuration.

Documentation on preseeding/kickstart for Ubuntu. Ubuntu has limited support for kickstart (and preseeding); one of the missing things is a graphical interface for preseeding. Kickstart does have options for this (see the images) but these do not seem to work on Ubuntu. You can do this manually though (see Preseeding below).

Installation and starting kickstart:

sudo apt-get install system-config-kickstart
ksconfig

** WARNING **

kickstart is bugged in Ubuntu 13.10 and when starting it, it errors out. Here is a fix. Put the patch in the comment into a text file, save it (I named it "patch") and commit it:

enter image description here

After that ksconfig worked and it will start a configuration editor that allows for you to manipulate a lot of options.

enter image description here

enter image description here

See the Red Hat Linux 7.2: The Official Red Hat Linux Customization Guide for a description for all of the options you can set.

After you are done, save the changes to a ks.cfg file and copy it over to the ISO we are changing:

sudo cp ks.cfg ~/Downloads/newIso/preseed/ks-custom.cfg
  • If you change anything here the installer will SKIP asking for that information if it is considered valid. If you did not change an option the installer will still ask for you to answer.
  • You can also download kickstart files and save those in as ks-custom.cfg in ~/Downloads/newIso/preseed/.

Example where I inserted my credentials. I started it with sudo ksconfig from commandline.

enter image description here

And saving it to the project:

enter image description here

Preseeding (manually setting up a configuration file)

Preseeding provides a way to set answers to questions asked during the installation process, without having to manually enter the answers while the installation is running. This makes it possible to fully automate most types of installation and even offers some features not available during normal installations.

Copy the preseed for the normal install over to your own label:

sudo cp newIso/preseed/ubuntu-server.seed newIso/preseed/ubuntu-myownoption.seed
  • change the myownoption to what you used.

Now for changing settings. Using debconf-get-selections from the debconf-utils you can investigate what parameters you can use with specific software.

Example setting this up:

enter image description here

And adding lamp-server to be installed with tasksel:

enter image description here

  • If you want to add packages "openssh" and "build-essential" you can include this in the seed file:

    d-i pkgsel/include string openssh-server build-essential
    
  • An example for openssh:

    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
    
  • You can add these options to custom-iso/preseed/ubuntu-myownoption.seed.

  • Explanation/examples using debconf settings.
  • An example preseed file
  • Examples regarding: Localization, Network configuration, Network console, Clock and time, partitioning
  • At the end of the preseed file you can add packages (random examples) like this:

    %packages openssh-server mysql-server apache2

Offline installation

In case you add packages and those are NOT in the ISO the installer will download these from the repository. If you do not have an active internet connection this will be problematic so you will need to add all those packages (and dependencies) to your project and burn them to a DVD. Luckily the normal server ISO has a lot of room but beware: CD and/or DVDs do have a limited size.

Download all the DEB packages you need and store them in ~/Downloads/. These 2 directories are needed on the new ISO:

mkdir -p ~/Downloads/newIso/dists/stable/extras/binary-i386
mkdir -p ~/Downloads/newIso/pool/extras/
sudo cp ~/Downloads/*.deb newIso/pool/extras/

And this will update our project with the new packages:

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

Create the ISO

cd ~/Downloads/     
sudo md5sum `find ! -name “md5sum.txt” ! -path “./isolinux/*” -follow -type f` > md5sum.txt
sudo mkisofs -J -l -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -z -iso-level 4 -c isolinux/isolinux.cat -o ./ubuntu-13.10-myowninstall-amd64.iso -joliet-long newIso/
  • the 2nd line creates a new checksum and is only needed when adding packages.
  • the 3rd makes an ISO from your project that you can burn to a DVD.

Result:

enter image description here

And now you can try the it out by actually burning and installing it. I would advise to use as virtual machine since it will be quicker for testing the initial created ISO (otherwise you keep rebooting).

And after installing VirtualBox I get the following menu:

enter image description here

Bug hunting

Ran into 1 problems while installing: the default was not selected.

Shadin. From your seed file in comment

### Package Selection
tasksel tasksel/first multiselect Custom-Ubuntu-Server
d-i pkgsel/include string openssh-server build-essential
%packages openssh-server postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1 libpq-dev postgresql-server-dev-9.1 pgadmin3

probably needs to be like this:

### Package Selection
tasksel tasksel/first multiselect lamp-server
d-i pkgsel/include string openssh-server build-essential postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1 libpq-dev postgresql-server-dev-9.1 pgadmin3

Ditch the tasksel line of you do not want a LAMP server (ie. Apache, Mysql, Php)

9
  • Can this be used for desktops versions?
    – Braiam
    Jan 25, 2014 at 3:56
  • THANK YOU SO MUCH!! I really can't thank you enough for making this process easy and smooth! I just had one problem, after I installed VirtualBox and chose to install my customized server, I got this error message !Valid XHTML.
    – Shadin
    Jan 27, 2014 at 11:34
  • Yes i did. actually I prefer if you take a look at my seed file [megafileupload.com/en/file/493602/… I'm not sure about the way I added the packages at the end of the file
    – Shadin
    Jan 27, 2014 at 12:22
  • oh! thanks! I'll try that and get back to you. also I'd like to know if there is any way to remove any additional servers during this process from the image like mail server, web server, JBOSS.. etc. I want it to include only postgresql and its packages.
    – Shadin
    Jan 27, 2014 at 13:44
  • 2
    @shadin that is ok watch how Lucio does that ;-) Cleaned up comments. Braiam: yes it can. Though there are a lot more things to alter on desktop this is a start (kickstart works too if you patch it but it is still limited supported by Ubuntu).
    – Rinzwind
    Jan 29, 2014 at 9:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .