Preseed Ubuntu 16.04 not working (preseed file not found)

After playing around with it for weeks I finally got it working. Since I found many open questions, I will answer my own to help others.

When does it work?

At first I wasn't sure how that preseed process would look like. When the file was picked up and what to expect if my preseed file was not complete or incorrect. So I first did a manual installation and wrote down all the questions which were asked. After preseeding I found out that some questions are no longer asked, but the failed questions were still asked. So after that I did trial and error to preseed them all

Server edition

I read on the web that you require the server edition of ubuntu, cause it won't work with the desktop edition. I'm not sure if that is true, but I just installed the server version and installed the desktop packages (gnome in my case) in the preseed files.

Boot options

Sometimes they talk about passing parameters through the boot options. I had no idea how to do that, but in the end it's quite simple. Just boot from the install medium and choose your installation language. Than hit f6 to open other options and the boot parameters will appear. Just hit esc to close the other options dialog. boot options in ubuntu

I didn't like to type all those options into the boot options every time, so I modified the file \isolinux\isolinux.cfg (of my usb stick) and changed it into this:

# D-I config version 2.0
# search path for the c32 support libraries (libcom32, libutil etc.)
path 
include menu.cfg
default vesamenu.c32
prompt 0
timeout 0
ui gfxboot bootlogo

 LABEL custom
 menu label ^Belle Custom Installation
 kernel /install/vmlinuz
 append file=/cdrom/preseed/my.seed debian-installer/language=en debian-installer/country=NL console-setup/ask_detect=false keyboard-configuration/layoutcode=us debian-installer/locale=en_US.UTF-8 localechooser/preferred-locale=en_US.UTF8 initrd=/install/initrd.gz quiet --

When is preseed file loaded

I just placed my preseed file on the usb stick. The official documentation of ubuntu describes that the different preseed methods (file, network etc.) are loaded during different phases of the installation, but they don't describe when the file is loaded from the usb stick. This is done right after all the questions about keyboard, language etc. So you need to preseed those by the boot options.

Late command

One of the preseed questions (late command) allows you to run custom commands just before the installation finishes. Like many others I had trouble to get that working. In the end I ended up copying a script to the disk and modifying /etc/rc.local to let that script run during the first boot. I did this since I had all the commands available that I needed. Some commands are unfortunately available during that phase of the installation.

References

I took this info from a lot of other forums and guides. I don't remember them all, but to get you on the way:

  • Official ubuntu documentation (also has an example presee file): https://help.ubuntu.com/lts/installation-guide/armhf/apbs02.html
  • The official ubuntu server book (it describes it in more detail). This site has a part of the preseed topic online: http://searchitchannel.techtarget.com/feature/Performing-an-automated-Ubuntu-install-using-preseeding