How do I create a completely unattended install of Ubuntu Desktop 16.04.1 LTS?

Answering

I gave it some time from originally asking my question to see if there were any other solutions, but it looks like the solution I came up with while waiting is the only viable solution I've seen so far.

Misconception

Since this was the source of a lot of confusion, I will try to clear it up. It seems that some of the answers tried to use the Ubuntu 16 Server image when I was specifically trying to create an unattended Ubuntu 16 Desktop image install. The issue arises because of the implementation differences of d-i (debian installer) and ubiquity. Since the Server image will pay attention and use all of the d-i commands in the preseed file, most of the questions I asked are irrelevant to the Server image. However, due to the implementation of ubiquity as the installer of the Desktop image a lot of d-i commands are ignored and you are very limited and a lot of documentation is missing.

Documentation Links Found

  • Here is the link for Ubiquity ignoring the preseed/late_command (I believe it ignores the preseed/early_command too)
  • Here is the Ubiquity Documentation it talks about which installer components will not be used in Ubiquity, but as you will notice even in this documentation it says the preseed/early_command but I would test that thoroughly to verify since it didn't seem to work for me (I admit I didn't test the early_command rigorously so I may be wrong).

Successful Process

Here is my process for successfully creating an unattended Ubuntu Desktop 16.04 LTS iso.

Mount Ubuntu ISO

You will need to mount the ISO files so that you can edit the pertinent files.

mkdir -p /mnt/iso
mount -o loop ~/Downloads/ubuntu-16.04.1-desktop-amd64.iso /mnt/iso

Copy ISO Files

We will need to copy the files in mounted ISO to a different directory so that we can edit them. Feel free to use any directory you like, I chose the /opt directory due to another how-to, but /tmp could just as easily be used.

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

Edit the txt.cfg File

Here we will edit the /opt/ubuntuiso/isolinux/txt.cfg file and customize our boot parameters to get a completely unattended install which will include a preseed file. Use any editor of your choice:

#default live
#label live
#  menu label ^Try Ubuntu without installing
#  kernel /casper/vmlinuz.efi
#  append  file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash ---
#label live-install
#  menu label ^Install Ubuntu
#  kernel /casper/vmlinuz.efi
#  append  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash ---
#label check
#  menu label ^Check disc for defects
#  kernel /casper/vmlinuz.efi
#  append  boot=casper integrity-check initrd=/casper/initrd.lz quiet splash ---
#label memtest
#  menu label Test ^memory
#  kernel /install/mt86plus
#label hd 
#  menu label ^Boot from first hard disk
#  localboot 0x80

default live-install
label live-install
  menu label ^Install Ubuntu
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/ks.preseed auto=true priority=critical debian-installer/locale=en_US keyboard-configuration/layoutcode=us ubiquity/reboot=true languagechooser/language-name=English countrychooser/shortlist=US localechooser/supported-locales=en_US.UTF-8 boot=casper automatic-ubiquity initrd=/casper/initrd.lz quiet splash noprompt noshell ---

Please take note of a few things:

  • I commented out all original text in the file.
  • I added all text after and including "default live-install" at the bottom
  • I named the preseed file "ks.preseed" and it will be in the top level directory of the ISO (/opt/ubuntuiso)

Use or Create a Preseed File

Use an already existing preseed file with caution! I have not found any that just work. This isn’t to say they don’t exist, I just didn’t find any with quite a bit of searching. There are many ways to configure a preseed file, but I found many options to be ignored, outlined in the Ubiquity Documentation I linked above and in the link for preseed/late_command vs ubiquity/success_command. I am including my simple working preseed file that works with the above txt.cfg file.

For netcfg/get_hostname string and netcfg/get_domain string you can put whatever you want it to be. I used unassigned-hostname and unassigned-domain since I will just change it later through a scripting process.

For any custom command you want to run after installation you need to use the:

ubiquity ubiquity/success_command string

Followed by any command you want to run. Pay attention to continuing the strings with ";\" and using the "/target" to change anything pertaining to the new system installed.

# Partitioning
# Old style using d-i command
#d-i partman-auto/disk string /dev/sda
#d-i partman-auto/method string regular
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-md/device_remove_md boolean true
#d-i partman-auto/choose_recipe select atomic

# Newer ubiquity command
ubiquity partman-auto/disk string /dev/sda
ubiquity partman-auto/method string regular
ubiquity partman-lvm/device_remove_lvm boolean true
ubiquity partman-md/device_remove_md boolean true
ubiquity partman-auto/choose_recipe select atomic

# This makes partman automatically partition without confirmation
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

# Locale
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us

# Network
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/choose_interface select auto

# Clock
d-i clock-setup/utc-auto boolean true
d-i clock-setup/utc boolean true
d-i time/zone string US/Pacific
d-i clock-setup/ntp boolean true

# Packages, Mirrors, Image
d-i mirror/country string US
d-i apt-setup/multiverse boolean true
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true

# Users
d-i passwd/user-fullname string User
d-i passwd/username string user
d-i passwd/user-password-crypted password yourEncryptedPasswd
d-i passwd/user-default-groups string adm audio cdrom dip lpadmin sudo plugdev sambashare video
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password rootEncryptedPasswd
d-i user-setup/allow-password-weak boolean true

# Grub
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i finish-install/reboot_in_progress note

# Custom Commands
ubiquity ubiquity/success_command string \
  sed -i -e 's/dns=dnsmasq/#dns=dnsmasq/' /target/etc/NetworkManager/NetworkManager.conf ;\
  cp -a /cdrom/scripts/ /target/root/ ;\
  cp -a /cdrom/salt/ /target/root/

Please note these things as I left them in for illustrative purposes and they will likely be different in your preseed command.

  • The user/root password need to be added by you. Here is the link that shows you 3 different ways to make a crypt 3 password.
  • You may want to change the groups your user is assigned to.
  • You will definitely want to change the success_command. I left it to show how it can be formatted and how to use the /target environment.

Create New ISO

Create the ISO so you can test out your preseed file. If you use one or make your own, you will need to test it as this will LIKELY be the place your process will fail. I wrote a script for quick testing, but you could just point the preseed file at an http:// hosted preseed file and test very quickly that way.

mkisofs -D -r -V "UNATTENDED_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /tmp/ubuntu16-desktop-unattended-install.iso /opt/ubuntuiso

Feel free to change the output name and the the directory in which you will save it.

Burn ISO

I would suggest testing on virtualbox or the like and once you have it working, then burn it to a DVD. You should now have a working unattended Ubuntu Desktop 16.04 LTS install DVD.

Feedback, Corrections, Errors

I wrote this all in one go and there may be errors, typos, or things that got messed up along the way. If anyone tries this, please let me know if you encounter an error in the process. And please remember that if you create your own preseed file, I will probably not be able to answer why your unattended install is broken and not working since ubiquity likes to ignore and not do certain things in the preseed file. I hope this helpful to someone.


Have a look at: https://github.com/core-process/linux-unattended-installation

This project provides all you need to create an unattended installation of a minimal setup of Linux, whereas minimal translates to the most lightweight setup - including an OpenSSH service and Python - which you can derive from the standard installer of a Linux distribution. The idea is, you will do all further deployment of your configurations and services with the help of Ansible or similar tools once you completed the minimal setup.


Great job Brandon Authier for your post and instructions, you helped me a lot.

I had one issue with your method though: I found out that after install finishes and PC reboots the GRUB hangs.

So I added to the ks.preseed the following:

# Due notably to potential USB sticks, the location of the MBR can not be
# determined safely in general, so this needs to be specified:

d-i grub-installer/bootdev  string /dev/sda

# To install to the first device (assuming it is not a USB stick):
#d-i grub-installer/bootdev  string default

This prevents crashing the grub install if you do not remove the USB stick. I got this from https://www.debian.org/releases/stable/example-preseed.txt