I’ve lost count of the number of times that I have installed Ubuntu Server on my VMware vSphere box – so I finally looked in to performing an unattended install.
I could have setup DHCP and TFTP servers and done PXE boot from images over the network – but I wanted to work on something quicker than that (and I don’t have that much spare RAM on my vSphere box as it is).
So I settled on re-mastering an Ubuntu Server .iso image. The result is an unattended install, except for the initial boot screen (where I need to select a minimal virtual machine installation anyway).
The following steps were performed on Ubuntu Desktop.
Download Ubuntu Server – I am using the 32 bit version of Ubuntu 12.04.
Open a Terminal and create a directory to mount the Ubuntu Server iso to.
sudo mkdir -p /mnt/iso
The -p switch is very useful as it allows you to create a directory structure which does not already exist (as opposed to creating a single directory).
Change directory to Downloads:
I renamed my download UbuntuServer.iso.
Mount UbuntuServer.iso to /mnt/iso:
sudo mount -o loop UbuntuServer.iso /mnt/iso
Create a directory and copy the mounted Ubuntu Server files:
sudo mkdir -p /opt/serveriso
sudo cp -rT /mnt/iso /opt/serveriso
The -r switch copies directories recursively and -T specifies no (singular) target directory.
Now we have a copy of our Ubuntu .iso to work on in /opt/serveriso – but we need to make these files writable:
sudo chmod -R 777 /opt/serveriso/
With this preparation done we can start customizing things.
If we look at the isolinux/langlist file we see all the supported languages listed that Ubuntu supports (in an abbreviated format):
I am only interested in an English install so I am going to overwrite the contents of isolinux/langlist with the single abbreviation for English, which is “en”.
echo en >isolinux/langlist
This stops the language selection menu from appearing during installation.
The next step of the process is to create a kickstart file – this will provide the server install with the answers to the various questions asked during installation, such as timezone, username, password, partition structure and so on.
Install Kickstart Configurator:
sudo apt-get install system-config-kickstart
Click the Dash button and type kickstart and then click on the kickstart application.
Obviously you should customize your settings as you see fit – I have provided mine for reference.
Basic Configuration: Set Timezone
Installation Method: Choose the CD-ROM installation method
Partition Options: Add an ext4 partition to the root file system that fills all unused space on the disk
Partition Options: Add a swap file system that uses the recommended swap size
Network Configuration: Add network device eth0 and set to DHCP
User Configuration: Provide username and password
Click File, Save File and save the kickstart file ks.cfg to /opt/serveriso.
While using the Kickstart Configurator you may have noticed that the Package Selection screen did not work. Fortunately we can manually edit the ks.cfg file so that the packages that we want are installed during Ubuntu Server installation.
At the end of ks.cfg add %packages and then list the packages that you want installed. I chose to install nano, openssh-server and open-vm-tools:
–no-install-recommends installs open-vm-tools in headless mode.
Now we need to configure the CD boot command line to use the kickstart ks.cfg file.
Browse to and open /opt/serveriso/isolinux/txt.cfg.
We need to edit the append line of the default install section at the top of the file.
At the end of the append line add ks=cdrom:/ks.cfg. You can remove quiet – and vga=788.
My append line is as follows:
append file=/cdrom/preseed/ubuntuserver.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg
The final step is to create a new Ubuntu Server .iso using this command:
sudo mkisofs -D -r -V "ATTENDLESS_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /opt/autoinstall.iso /opt/serveriso
The finished .iso is /opt/autoinstall.iso.
Test your .iso in a virtual machine to make sure that everything works as it should.
The minimal interaction that I need to set my Ubuntu Server install going is documented below:
Press the Enter key to confirm the English language selection
Press F4, select Install a minimal virtual machine, and then press Enter
Press Enter to install Ubuntu Server
From here installation continues without any further input being required.