Streamlining Linux Installs by Auto-Installing Ubuntu 16.04 with Preseed File
In the previous post we did spend a little time looking at how we could install the latest Ubuntu LTS version: 1604. A manual install is great if it is for just a single installation but very often you will need more than one Ubuntu Server. In this blog we now take a look at auto-installing Ubuntu 16.04 server. Making use of preseed files. These preseed files are the answer files that the debian installer uses.
To begin with will will try to keep this as simple as possible and we will not use PXE boot. Although PXE is the obvious way to achieve this it would mean you having to install and configure PXE, Network Boot and you may not want this. We will boot from the ISO file and point to a preseed file on an FTP server. Yes you will need to setup and FTP server but that is quite straight forward and you could easily use an HTTP server is you wish.
The preseed file that is at the heart if the install and is a text file that has a list of answers to question the the debian installer will ask. The file that I use in the demonstration is shown below but you may also refer to the Ubuntu documentation. This file is saved as 1604.cfg on my KVM host which is an FTP server. The URL for this is ftp://192.168.56.1/pub/1604.cfg.
# Ubuntu Server 16.04 d-i debian-installer/locale string en_GB.UTF-8 d-i console-setup/ask_detect boolean false d-i keyboard-configuration/xkb-keymap select gb d-i keyboard-configuration/layout string "United Kingdom" d-i netcfg/choose_interface select auto d-i netcfg/get_hostname string unassigned d-i netcfg/get_domain string unassigned d-i mirror/country string UK d-i mirror/http/proxy string d-i clock-setup/utc boolean true d-i time/zone string Europe/London d-i clock-setup/ntp boolean true d-i clock-setup/ntp-server string uk.pool.ntp.org d-i partman-auto/disk string /dev/vda d-i partman-auto/method string lvm d-i partman-lvm/device_remove_lvm boolean true d-i partman-lvm/device_remove_lvm_span boolean true d-i partman-auto/purge_lvm_from_device boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-auto-lvm/new_vg_name string sys_vg d-i partman-auto/choose_recipe atomic d-i partman-auto-lvm/guided_size string max d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true d-i partman-auto/confirm boolean true d-i passwd/root-login boolean false d-i passwd/make-user boolean false d-i passwd/user-fullname string tux d-i passwd/username string tux d-i passwd/user-password password Password1 d-i passwd/user-password-again password Password1 d-i user-setup/allow-password-weak boolean true d-i user-setup/encrypt-home boolean false tasksel tasksel/first multiselect server, openssh-server d-i pkgsel/include string openssh-server update-motd d-i pkgsel/update-policy select none d-i grub-installer/only_debian boolean true d-i grub-installer/with_other_os boolean true d-i finish-install/reboot_in_progress note
We add in settings for the locale, users and partitions etc. The partitioning scheme that I use is builtin and called atomic. This implements a single filesystem for the root partition. Even though I do set the locale and keyboard in the preseed file these question are also asked before the file is retrieved. To ensure that we can proceed without interruption we add additional options as kernel parameters. This is where a PXE server is great as it can pass these parameters at boot time. The additional kernel parameters that we pass are listed below. These are passed to the boot options and a space separated list when auto-installing Ubuntu server.
ksdevice=ens3 locale=en_GB.UTF-8 keyboard-configuration/layoutcode=gb hostname=unassigned interface=ens3 url=ftp://192.168.56.1/pub/1604.cfg
We can access the boot option using F6 from the install screen.
With this set the install will complete while you are safely eating biscuits and coffee. The video steps you through the process of auto installing Ubuntu 16.04.