Skip to content

A comprehensive guide and examples for using preseed.cfg files to automate Debian and Ubuntu installations.

Notifications You must be signed in to change notification settings

3ricGvald3z/Preseed-File-Tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation

Using preseed.cfg for Automated Debian/Ubuntu Installs

A preseed.cfg file is a configuration file used by the Debian and Ubuntu installers to automate the installation process. It allows you to pre-answer all the questions that would normally be asked during a manual installation, such as language, keyboard layout, partitioning scheme, and user accounts. This is particularly useful for deploying many identical systems, as it ensures consistency and saves a lot of time and effort.


How it Works

The installer, whether from a CD, USB, or network boot, can be pointed to a preseed.cfg file. When it starts, it reads the file and uses the provided answers to automatically progress through the installation steps. This completely bypasses the need for human interaction. The preseed file can be hosted on a web server, embedded in the installation media, or served via a network boot setup.

A Simple Example

Here's a snippet from a basic preseed.cfg file to show how it works. Each line specifies an answer for a particular question. The syntax is package_name/variable_name followed by a space and then the value.

# Language and keyboard
d-i debian-installer/language string en
d-i keyboard-configuration/xkb-model select pc105
d-i keyboard-configuration/xkb-layout select us

# Networking
d-i netcfg/get_hostname string my-server
d-i netcfg/get_domain string my-domain.local

# Partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/expert_recipe string                         \
  boot-root ::                                                \
    100 200 100 ext4                                          \
      $primary{ } $bootable{ }                                 \
      method{ format } format{ }                              \
      use_filesystem{ } filesystem{ ext4 }                    \
      mountpoint{ / }                                         \
    .                                                         \
    100 500 100 ext4                                          \
      $primary{ }                                             \
      method{ format } format{ }                              \
      use_filesystem{ } filesystem{ ext4 }                    \
      mountpoint{ /home }                                     \
    .                                                         \
    100 200 100 swap                                          \
      $primary{ }                                             \
      method{ swap } format{ }                                \
    .


Benefits of Using preseed.cfg

Using a preseed.cfg file offers significant advantages, especially in environments where you need to deploy many systems.

1. Automation and Efficiency πŸ€–

By automating the installation process, you can deploy multiple systems simultaneously without manual intervention. This drastically reduces the time and labor required for system setup.

2. Consistency and Standardization βš–οΈ

A preseed file ensures that every system is installed with the exact same configuration. This eliminates human error and guarantees that all your systems are standardized, which simplifies management, troubleshooting, and security.

3. Scalability πŸ“ˆ

Once you've created a preseed.cfg file, you can use it to deploy dozens or even hundreds of machines. It's a key component of scalable infrastructure management, particularly when combined with network booting (PXE).

4. Version Control πŸ“

Because the preseed.cfg file is a plain text file, you can easily store it in a version control system like Git. This allows you to track changes, revert to previous versions, and collaborate with others on the installation configuration.

5. Customization and Flexibility ✨

You can customize the preseed file to include specific packages, run custom scripts after the base installation, and configure post-install settings. This allows you to create a "golden image" that's tailored to your exact needs.


Getting Started

  1. Create your preseed.cfg file: Start with a template or use the Debian Installer Reference Manual to find the variables you need.

  2. Host the file: Place the preseed.cfg file on a web server, TFTP server, or embed it on your installation media.

  3. Boot the installer: Point the installer to your preseed file. This can be done via a boot parameter at the beginning of the installation. For example:

    • For a network boot (PXE): Add preseed/url=http://your-server/path/to/preseed.cfg to the kernel boot command line.

    • For an ISO: You can edit the isolinux or grub bootloader configuration on the media to automatically load the preseed file.

  4. Watch it go: The installer will read the file and complete the installation without any prompts.

Example Kernel Boot Command Line

This is a common example of a kernel boot command line you might use for a network boot (PXE) setup.

auto=true preseed/url=http://<host_ip>:8000/preseed.cfg priority=critical interface=auto

Let's break down the parameters:

  • auto=true: This flag tells the installer to run in an automated, non-interactive mode.

  • preseed/url=http://<host_ip>:8000/preseed.cfg: This is the core part, specifying the URL where the installer can find the preseed.cfg file. You should replace <host_ip> with the actual IP address of your web server.

  • priority=critical: This sets the priority level of the installer questions. critical tells the installer to only ask questions if they are absolutely essential for the installation to proceed, which further automates the process.

  • interface=auto: This tells the installer to automatically configure the network interface, which is useful for a network boot scenario.

About

A comprehensive guide and examples for using preseed.cfg files to automate Debian and Ubuntu installations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published