2

Need a step by step procedure for creating a kickstart server on Ubuntu 14.04 LTS

2 Answers 2

2

This is a good step-by-step guide

TL;DR; use isohybrid after repacking the custom iso

To make this usb, I used a virtual machine with Ubuntu 14.04 installed. The goal here is to make a bootable usb that doesn’t require selection of things like keyboard layout, language, etc. We want an automatic install of an Ubuntu server.

We need to get the ubuntu image that we’re going to be customizing for our installation.

wget http://releases.ubuntu.com/14.04/ubuntu-14.04.2-server-amd64.iso

We’re going to need a place to mount the unpacked iso file.

sudo mkdir -p /mnt/iso

After we have created a mount point for it, now we have to mount it. This will expose the files that are held inside the iso. Unfortunately, the files will be read-only

. sudo mount -o loop ubuntu-14.04.2-server-amd64.iso /mnt/iso

In order to modify the files, we need to copy them to a directory where we can modify them, so we’ll create the directory and then copy the files to it.

sudo mkdir -p /opt/ubuntuiso
sudo cp -rT /mnt/iso /opt/ubuntuiso

Our new working directory will be /opt/ubuntuiso

cd /opt/ubuntuiso

In order to avoid being prompted for language selection in the installation process, we need to tell it what language we’re going to use. In this case, en is being used because I speak english.

echo en | sudo tee isolinux/lang

Now we are actually going to build the kickstart file with a program called system-config-kickstart. So we make sure it’s installed and then run it.

sudo apt-get install system-config-kickstart
system-config-kickstart

Then save the file from the GUI in /opt/ubuntuiso/. This should save a file called ks.cfg. My ks.cfg looks like the following

#Generated by Kickstart Configurator
#platform=AMD64 or Intel EM64T
#System language
lang en_US
#Language modules to install
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone America/Denver
#Root password
rootpw --disabled
#Initial user
user ubuntu --fullname "ubuntu" --iscrypted --password $1$MQ0zGB4W$pwjX8nolgr2RJch2Omamt.
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use CDROM installation media
cdrom
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype ext2 --size 100 --asprimary
part swap --recommended
part / --fstype ext4 --size 1 --grow
#System authorization infomation
auth --useshadow --enablemd5
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled
#Do not configure the X Window System
skipx
%post
#!/bin/bash
exec < /dev/tty6 > /dev/tty6
chvt 6
echo 'Acquire::http { Proxy "http://10.2.4.27"; };' > /etc/apt/apt.conf.d/02proxy
apt-get update
apt-get -y upgrade
apt-get -y dist-upgrade
apt-get install -y git ansible openssh-server vim
chvt 1

There is a little bit of hijacking done in the postscript (everything after %post). The line beginning with exec and the following line (chvt 6) are forcing the installer show the output from the commands that are run after that. The reason for this is that the loading bar will not move during the installation, and it can appear as though the installer has hung. The following line that does the proxy is for the apt-cache on our local network. The final line (chvt 1) reverts the output to the main installer.

Now we need to add the preseed file so that we can avoid other questions.

echo 'd-i partman/confirm_write_new_label boolean true d-i partman/choose_partition \ select Finish partitioning and write changes to disk d-i partman/confirm boolean true' | sudo tee ks.preseed

Now we need to tell the installer about the files that we just saved, so we need to modify isolinux/txt.cfg. First we need to make the file writable.

sudo chmod +w isolinux/txt.cfg

Then we need to replace the append line of the following section

label install
menu label ^Install Ubuntu Server
kernel /install/vmlinuz
append file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet --

Replace the append line with

append file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed --

Save and exit the file. We also need to make sure that we put the file back in its original state, so remove the write permissions.

sudo chmod -w isolinux/txt.cfg

Now create the new iso file that we will use to create the bootable usb.

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/ubuntuiso

In order to finalize the bootable iso for a usb, we need to hybridize it.

sudo isohybrid /opt/autoinstall.iso

After hybridizing it, we can push it to the usb drive. The usb drive in my virtual machine shows up in /dev/sdb, but you need to use the correct label, so replace X accordingly Make sure that the usb drive is unmounted.

sudo umount /dev/sdX

And finally push the iso onto the usb drive. (Please note **this destroys data on the target device - make sure you know what you are doing)

sudo dd if=/opt/autoinstall.iso of=/dev/sdX

Now your usb drive should be ready for installation!

1
  • 2
    While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Especially in case the site ever goes down.
    – Thomas Ward
    Jul 5, 2017 at 17:24
1

The complete solution:

Remaster a CD, ie, download a non-graphical Ubuntu installation ISO (server or alternate installation CD) and mount it. In this case, your Ubuntu 14 ISO.

sudo mkdir -p /mnt/iso
sudo mount -o loop ubuntu.iso /mnt/iso

Copy the relevant files to a different directory

sudo mkdir -p /opt/ubuntuiso
sudo cp -rT /mnt/iso /opt/ubuntuiso

Prevent the language selection menu from appearing

cd /opt/ubuntuiso
echo en | sudo tee isolinux/lang

Use GUI program to add a kickstart file named ks.cfg

sudo apt-get install system-config-kickstart
system-config-kickstart # save file to ks.cfg

To add packages for the installation, add a %package section to the ks.cfg kickstart file, append to the end of ks.cfg file something like this.

%packages
@ ubuntu-server
openssh-server
ftp
build-essential

This will install the ubuntu-server "bundle", and will add the openssh-server, ftp and build-essential packages.

Add a preseed file, to suppress other questions

echo 'd-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition \
select Finish partitioning and write changes to disk
d-i partman/confirm boolean true' | sudo tee ks.preseed

Set the boot command line to use the kickstart and preseed files

sudo nano isolinux/txt.cfg

Search for

label install
  menu label ^Install Ubuntu Server
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet --

add ks=cdrom:/ks.cfg and preseed/file=/cdrom/ks.preseed to the append line. You can remove the quiet and vga=788 words. It should look like

append file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed --

Now create a new iso

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/ubuntuiso

That's it. You'll have a CD that would install an Ubuntu system once you boot from it, without requiring any input.

Tweak the ks.cfg and preseed files as needed.

You must log in to answer this question.

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