Debian/Ubuntu Preseed Documentation and Working Examples

• Updated June 2, 2018


Debian/Ubuntu’s Preseed is not the easiest thing to understand. Having used Red Hat/CentOS Kickstart Profiles for so long, trying to setup a Preseed file for the first time was an extremely uninviting process.

Ubuntu has support for using Kickstart Profiles, but it isn’t as full featured as Preseed, and I have encountered plenty of edge cases where Kickstart Profiles do not work for provisioning Ubuntu systems.

I currently spend a lot more time with Ubuntu than Red Hat or CentOS, so all I can do is try to better understand Preseed.

Understanding PartMan

Arguably the most difficult part of Preseed to understand is the partitioning. There are plenty of examples to do unattended guided partitioning, but what gets very confusing is trying to setup custom partitioning.

The Wikimedia Foundation has a wiki called Wikitech where they have put together a guide to Understanding PartMan. It’s a valuable resource to better understand PartMan. Additionally, be sure to check out PartMan/Auto which is documentation from the Debian/Ubuntu packages.

Ubuntu’s Preseed Examples

Ubuntu has some example Preseed files. Here are two of them for the current and last LTS releases:

Working, Unattended Preseeds

I have put together some generic, unattended Preseeds through troubleshooting, using reference Preseeds, and reading too many blog posts. I have organized the various sections in a way that makes sense to me, and I have added my own comments in addition to the comments found in Ubuntu’s example Preseeds.

So far, I have Preseeds for installing from the Ubuntu ISO and Cobbler.

The Preseed for the Ubuntu ISO cannot be fully unattended because networking has to be configured before downloading the Preseed file.

The Preseed for Cobbler is unattended as long as you pass kernel options informing Preseed which NIC to use to PXE boot - typically eth0 or em1.

The GitHub repository for these Preseeds can be found here.

Gotchas

I have come across a lot of “gotchas” when troubleshooting Preseed files. These are those gotchas. I will add to this section as I discover more.

Cannot Leave Space in LVM Volume Group

I have been unable to figure out how to tell PartMan to leave space in an LVM Volume Group. When it is building out the LVM Logical Volumes, the last LVM Logical Volume to be built will consume all remaining space.

It may not be possible to do this. If you know of a way to do this other than creating a dummy LVM Logical Volume then deleting it after the system is provisioned, let me know.

d-i preseed/early_command string

d-i preseed/early_command string can be used to run shell commands before the Preseed process begins. However, there can only be one instance of it. If you have multiple instances of it, the first instance will be the one to run. The other instances will be ignored.

If you have a single shell command to run, the instance in the Preseed file will look like the following:

d-i preseed/early_command string echo "Starting"

If you have many shell commands to run, you can simply append semicolons to the end of each command to form one really long line:

d-i preseed/early_command string echo "Starting"; wget http://example.com/file.txt; cat file.txt > /tmp/test

Or, you can break up the lines for better readability:

d-i preseed/early_command string \
  echo "Starting"; \
  wget http://example.com/file.txt; \
  cat file.txt > /tmp/test

d-i preseed/late_command string

d-i preseed/late_command string can be used to run shell commands just before the Preseed process ends. Just like, early_command, there can only be one instance of it. If you have multiple instances of it, the last instance will be the one to run. The other instances will be ignored.

If you have a single shell command to run, the instance in the Preseed file will look like the following:

d-i preseed/late_command string echo "Ending"

If you have many shell commands to run, you can simply append semicolons to the end of each command to form one really long line:

d-i preseed/late_command string echo "Ending"; wget http://example.com/file.txt; cat file.txt > /tmp/test

Or, you can break up the lines for better readability:

d-i preseed/late_command string \
  echo "Ending"; \
  wget http://example.com/file.txt; \
  cat file.txt > /tmp/test

No Order

While reading Preseed files, it may seem like there is an order to everything, but I don’t believe there is. The entire file seems to be read and parsed at the beginning of the Preseed process.

Tricky Spaces

If the Ubuntu installer says your Preseed is corrupted, it may be because you have spaces in places it doesn’t like.

References

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided links.

The following links are part of affiliate programs, and I will receive a referral payment from any of the services you sign-up for.

  • Get Faster Shipping: About to order some stuff on Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free, 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.
  • Start Investing Now: Looking to start investing some of your saved income? Get started by opening an account with Webull, where upon sign-up and opening a brokerage account with an initial deposit of $100 or more you will receive free stock(s). The promotions are always changing, so be sure to click the link to see the latest.

Thanks for reading and take care.