Debian/Ubuntu Preseed Documentation and Working Examples

Wednesday, October 14, 2015

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 grok 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 as well as the comments found in Ubuntu’s example Preseeds.

So far, I have Preseeds for installing via the Ubuntu ISO and via 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.

I will continue to iterate these Preseeds and add more. 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 continually 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

Using preseed to create two volume groups on same disk



comments powered by Disqus