Image of the glider from the Game of Life by John Conway
Skip to content

Automating Debian/Ubuntu Installs With Preseed

As a Linux instructor for Guru Labs, I get the opportunity to do a great deal of system administration. One of those responsibilities as an admin is performing installations of RHEL, Fedora, SLES, OpenSUSE and OEL. Soon, hopefully, we'll be adding Debian and Ubuntu to the mix of courses and courseware. As such, along with Christer Edwards who also teaches at Guru Labs, I've taken it upon myself to find the necessary admin tools to bring to the table for our future courses. One such tool that has bothered me as of late, is automating an Ubuntu or Debian install.

With Red Hat and Fedora, the Anaconda installer automatically creates a /root/anaconda-ks-cfg file. This file is a Kickstart file necessary for automating installs if I want to build machines exactly like the one I just installed. In other words, this file is all the answers to the questions that I just entered for that installation. This is a handy feature. Why doesn't Debian and Ubuntu do this? Actually, they do. Kind of.

When asked the necessary questions in the Debian text-based installer, a database is created keeping track of each of those answers. When the system is finished installing, that database is stored under /var/log/installer/questions.dat. Unfortunately, if you installed your system via the GUI installer, this file is not created. Further, you will need a utility to extract the answers to those questions, as the questions.dat file is a binary database.

So, we need to install debconf-utils for access to a couple of binaries necessary to build this preeseed config file for automating the rest of the installations that I wish to perform.

sudo aptitude install debconf-utils

After installed, I now have access to the debconf-get-selections tool for helping be exctract the answers out of the questions.dat database. So...

sudo debconf-get-selections --installer > preseed.cfg
sudo debconf-get-selections >> preseed.cfg

I now have a preseed config file necessary for my automated installs. However, that config file may have a bunch of unnecessary stuff that I may not want for the install. So, I should open up that config file, and edit it as necessary, removing a lot of the bloat. It is best, rather, to build a preseed.cfg file from scratch, or using an example template, and building from there. This approach is superior for a couple of reasons. First, I will learn the internals of preseed itself. Second, I will become intimately familiar with the Debian installer questions, and the power that I probably take for granted. After building my own preseed file from scratch, I can then customize it to fit my needs, or my network needs, as necessary.

To build one such file, the Debian documentation team has some decent docs for helping me get started. However, the docs are hardly exhaustive, so you may find yourself spending a bit of time on Google, before getting the hang of it. At the documentation site, I have "Creating a preconfiguration file" and "Contents of the preconfiguration file" documents available. Spending some time there, learning preseed is time well spent. After the file is created, there is a syntax checker to make sure the contents of the preseed file are sound:

sudo debconf-get-selections -c preseed.cfg

Now that I have my built preseed file, it's time to boot my boxes using the file. Obviously, I will need to make the file accessible somehow. I can make this preseed file accessible via HTTP, FTP, NFS, locally on a hard drive or partition, CDROM or even built into the initial RAM disk itself. Once I have that access, at the boot prompt, I enter the following (adjusting as necessary for the location of the preseed file):

linux preseed/url=

And, based on the contents of the preseed file located at that web address, the installer starts, and off we run with installing the new Debian or Ubuntu system, completely hands-off (again, based on the file contents).

As an ending thought, preseed can read Anaconda Kickstart files, but there is still a bit to yet be implemented. If you prefer using Kickstart as a method for automating your installs, you should probably build a hybrid file for the missing Kickstart features with preseed. There is also a GUI tool for building Kickstart files available in the Debian and Ubuntu repositories:

sudo aptitude install system-config-kickstart

However, using Kickstart files to build your Debian or Ubuntu box isn't as flexible or powerful as preseed, and further, you really won't learn the internals of the Debian installer. Kickstart is heavily documented, unlike the sparse documentation that exists for preseed, so you'll likely find more answers if building a Kickstart file.

{ 19 } Comments

  1. jimcooncat | May 22, 2008 at 12:36 pm | Permalink

    Hard disk partitioning help in preseed configs:

  2. Bjorn Thor | November 18, 2009 at 3:09 pm | Permalink

    Thank you for a great article. This cleared things a lot regarding kickstart vs preseed

  3. Joseph Hall | February 10, 2013 at 8:54 pm | Permalink

    Always excellent to stumble across your posts when looking for answers. Reading through the preseed docs, I have yet to find any way to config multiple network interfaces using preseed. Do you know if this is possible?

  4. sandra lynn | October 15, 2016 at 1:41 am | Permalink

    Appreciating the dedication you put into your blog and in depth information you offer. Please visit for Linux training course

  5. Tibco Online Training | February 27, 2017 at 11:58 am | Permalink

    Thank you for such amazing post.. Really informative.. We are MindboxTrainings where we provide Tibco Online Training , Devops Online Training and more....

  6. Linux training | August 9, 2018 at 3:00 am | Permalink

    Thanks for the awesome tutorial.

  7. Nancy nanck | September 10, 2018 at 11:33 am | Permalink

    RPA training in Hyderabad. We are providing rpa training with real time industry expert,we also providing 100% job assistance.

  8. michael techenoid | November 9, 2018 at 1:36 am | Permalink

    really this post values for us

  9. sadha onnisa | November 9, 2018 at 5:18 am | Permalink

    I really appreciate information shared above. It’s of great help. If someone want to learn Online training, kindly contact us

  10. akshay | November 20, 2018 at 2:47 am | Permalink

    Great post.Thanks for sharing. keep going

  11. Kelly Technologies | January 21, 2019 at 4:12 am | Permalink

    Thanks a lot for a great blog your article is so expansive nice information on Automations. thanks again for wonderful knowledge with great organized. Take time to visit site at

  12. Kalyan | February 23, 2019 at 1:51 am | Permalink

    Nice! Visit here for learn Linux basic tutorials:

  13. chandu vepambattu | February 26, 2019 at 11:20 pm | Permalink

    I am Here to Get Learn Good Stuff About DevOps, Thanks For Sharing

  14. LandMark Hospital | February 28, 2019 at 11:10 pm | Permalink

    thank you for installation guide.

  15. jothikumar | July 27, 2019 at 3:39 am | Permalink

    Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    Blockchain online training

  16. gowsalya | August 10, 2019 at 2:55 am | Permalink

    Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
    hadoop admin online training

  17. manjuladevi | August 10, 2019 at 4:16 am | Permalink

    Awesome..You have clearly explained …Its very useful for me to know about new things..Keep on blogging..
    Best MEAN Stack Online Training

  18. gautham | September 26, 2019 at 5:14 am | Permalink

    I think you provided a nice information cyber security online training

  19. gautham | September 30, 2019 at 3:53 am | Permalink

    This is the nice blog to learn cognos tm1 online training training hyderabad

Post a Comment

Your email is never published nor shared.