Differences between revisions 1 and 114 (spanning 113 versions)
Revision 1 as of 2004-10-05 02:52:52
Size: 2034
Editor: anonymous
Comment:
Revision 114 as of 2018-01-23 14:40:35
Size: 13463
Editor: Brian Potkin
Comment: Edited to remove superfluous spaces. (To allow copy/paste of a script to work).
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## Auto-converted by kwiki2moinmoin v2005-10-07 ## page was renamed from DebianInstallerPreseed
#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: English - [[fr/DebianInstaller/Preseed|Français]]-~
----

 . <<TableOfContents(2)>>
Line 3: Line 9:
Most of the questions asked by d-i can be preseeded by setting the answers in the debconf database. This can be used to do automatic installs. This page gathers our collective knowledge on the topic, so please add any tips you have.

There are currently two main mechanisms to preseed debconf values.
Values can be set on the installer's boot line, for example:
{{{
  linux debconf/priority=critical
}}}

The preseed udebs can be used to load a file containing values to preseed, either from the network or local media. The installation manual explains how to set this up: http://d-i.alioth.debian.org/manual/en.i386/ch04s07.html#id2511063

Note that most preseeding support has been added after rc1 of the installer.

= Preseeding language and country =
Since these questions come before the preseed udebs do their work, language and country can only be preseeded when the installer is booted, perhaps via a modified syslinux.cfg file.
Here's an example:
{{{
  languagechooser/language-name=French
  countrychooser/country-name-shortlist=France
  countrychooser/country-name=France
}}}

Apparently two values in countrychooser must be seeded (why?).

= Preseeding mirror =
If you're doing a netboot install or the like, it's nice to be able to preseed a mirror to use. Here's an example in preseed file format, that makes it use a manually entered mirror:
{{{
  d-i mirror/country string enter information manually
  d-i mirror/http/hostname string your-mirror-name-here
  d-i mirror/http/directory string /debian
  d-i mirror/suite string unstable
  #d-i mirror/http/proxy string http://10.11.12.1:3128/
}}}

= Preseeding partman =
Realistically, only the automatic partitioning choices of partman can be preseeded. To get any more control, you really want to provide a partman-auto recipe (how?). Here's one value that should work as of a few days ago:
{{{
  d-i partman/confirm boolean true
}}}
Preseeding provides a way to set answers to questions asked during the installation process, without having to manually enter the answers while the installation is running. This makes it possible to fully automate most types of installation and even offers some features not available during normal installations.

Most of the questions asked by DebianInstaller can be preseeded by setting the answers in the [[debconf]] database. The Installation Guide includes an [[http://www.debian.org/releases/stable/i386/apb.html|extensive appendix]] dedicated to preseeding. For concrete preseed files look below. Feel free to add any information that is not covered in the manual to the notes below.

= Preseeding methods =

As mentioned in the [[http://www.debian.org/releases/stable/i386/apb.html|official installation guide]], there are several ways to feed the preseed file to the installer.

== Adding the preseed file to the installer's initrd.gz ==

Installation can be fully automated by adding a preseed file to the installer ISO's initrd.gz. This method is described in detail in [[DebianInstaller/Preseed/EditIso|this wiki article]]. The downside of this method is that net installer has to be generated whenever a preseed file is modified.

== Autoloading the preseeding file from a webserver via DHCP ==

If you have control over the DHCP server on your network, this method allows fully automated installations; as demonstrated and documented at [[http://hands.com/d-i/|Hands-off]].

== Loading the preseeding file from a webserver ==

Most install methods you can interrupt early on and add a URL to a preseed file, for an almost fully automated installations. Here exemplified with the graphical installer:

 * When the graphical ''installer boot menu'' appears, press ESC
 * (Type "help" if you want view generic help)
 * Type "auto url=http://webserver/path/preseed.cfg", replacing the URL with the address to your preseed configuration file

The "auto" command launches the installation in the automated mode, where the configuration of hostname, locale and keymap are postponed so that they can be answered from the preseed file loaded from the network. You could use "install url=..." but you'd have to answer these questions manually, regardless of what you have in the preseed config. If a server path isn't specified the path 'd-i/<codename>/preseed.cfg' will be tried, for example `d-i/stretch/preseed.cfg`. Note that network configuration options (`netcfg/*`) cannot be applied via a network-loaded preseed.cfg file, as the network must be configured before the preseed file can be fetched. If network configuration options must be declared, needed options have be passed as kernel options (eg `netcfg/choose_interface=eth0`).

Note that if the preseed config is loaded over https the install environment may not recognise the certificates presented by the webserver. You can add the option "debian-installer/allow_unauthenticated_ssl=true" to bypass certificate checks.

= Default preseed files =

When creating a preseed file, you should start from a known good, default preseed file:

 * [[http://www.debian.org/releases/stable/example-preseed.txt|Preseed file example]] for [[DebianStable|Debian Stable]]

If you use a preseed file for an older, newer or otherwise different OS, you will most likely be prompted for answers at some point, even if you thought you automated everything.

= Preseeding and the installer's debconf templates =

As part of its construction the Debian Installer uses [[https://d-i.alioth.debian.org/doc/internals/ch03.html|udeb]] files. These files are similar to normal .debs and have a control section which may contain a file
called ''templates'' which, amongst other things, contains questions which
can be asked during the installation. The answers to these questions can, in many cases, be preseeded. Not all udebs have a templates file.

If you have a ''.udeb'' its templates file can be extracted using apt-extracttemplates, which is in the apt-utils package. The command

{{{
apt-extracttemplates -t $PWD file.udeb
}}}

produces two files in the same directory as file.udeb. With ''ls -l'' you should see something like

{{{
file.config.S7Fsld
file.template.4tyDFV
}}}

The terminating string is a random one and the second file is the one of interest. This contains the information necessary to preseed answers to
questions asked by the installer.

== Processing templates files ==

Let's assume you have all the available udeb files for your chosen suite (stable, testing or unstable) and are in the directory containing them. The templates files from them will be extracted by

{{{
#!/bin/bash

UDEBS=*.udeb
mkdir $PWD/templates

for i in $UDEBS
do
   apt-extracttemplates -t $PWD $i
   rm *.config* 2>/dev/null
done
}}}

This is a script to obtain all English language information from a selection of templates and put it in a single file after changing to the templates directory:

{{{
#!/bin/bash

FILES=*.template*

for f in $FILES
do
# Have titled sections for data from each template file.
TITLE=$(echo $f |cut -d"." -f1)
echo -e "\n\n\n********** $TITLE **********" >> preseed.all

# Extract data from templates and do a bit of tidying up.
sed '/^Indices-.*\.UTF/d' $f \
| sed '/^Choices-.*\.UTF-8/d' \
| awk '/^Template:/,/-.*\.UTF-8:/' \
| awk '!/-.*\.UTF-8:/' \
| sed '/^Template:/{x;p;x;}' \
>> preseed.all
done
}}}

Most of the non-question data can be eliminated with

{{{
#!/bin/bash

FILES=*.template*

for f in $FILES
do
# Have titled sections for data from each template file.
TITLE=$(echo $f |cut -d"." -f1)
echo -e "\n\n\n********** $TITLE **********" >> preseed.all

# Extract data from templates and remove text, error, title
# and note data types.
sed '/^Indices-.*\.UTF-8/d' $f \
| sed '/^Choices-.*\.UTF-8/d' \
| awk '/^Template:/,/-.*\.UTF-8:/' \
| awk '!/-.*\.UTF-8:/' \
| sed '/^Template:/{x;p;x;}' \
| sed ':a $!N;s/\nType: text/ Type: text/;ta P;D' \
| sed '/Type: text/,/^$/d' \
| sed ':a $!N;s/\nType: error/ Type: error/;ta P;D' \
| sed '/Type: error/,/^$/d' \
| sed ':a $!N;s/\nType: title/ Type: title/;ta P;D' \
| sed '/Type: title/,/^$/d' \
| sed ':a $!N;s/\nType: note/ Type: note/;ta P;D' \
| sed '/Type: note/,/^$/d' \
>> preseed.all
done
}}}

== Obtaining udeb files from a Debian archive ==

For a small handful of files it is probably convenient to download them from Debian website's [[https://www.debian.org/distrib/packages|Packages page]] (View package lists). However, it is worthwhile considering using ''apt-get'' and an archive in /etc/apt/sources.list. A suitable entry is:

{{{
deb http://httpredir.debian.org/debian stable main/debian-installer
}}}

Then

{{{
apt-get update
apt-get install <udeb_package_name>
}}}

With the previous entry as the only one in sources.list a list of available udebs can be written to a file using

{{{
apt-cache dumpavail | grep ^Package: | cut -d" " -f2 > udebpkgs
}}}

and the contents of udebpkgs downloaded with

{{{
for pkg in $(cat udebpkgs) ; do apt-get download $pkg ; done
}}}Post-processing with apt-extracttemplates and a script is undertaken as described in [[DebianInstaller/Preseed#Processing templates files|a previous section]].

== Obtaining udeb files from a Debian ISO ==

Without root privileges extraction of all the udebs used in an ISO can do done with

{{{
bsdtar -C <DESTINATION> -xf <ISO> --strip-components 4 --exclude '*.deb' /pool/main
}}}

Post-processing with apt-extracttemplates and a script is carried out [[DebianInstaller/Preseed#Processing templates files|as described earlier]].

== Obtaining deb files from a Debian ISO ==

Without root privileges extraction of all the debs used in an ISO can do done with

{{{
bsdtar -C <DESTINATION> -xf <ISO> --strip-components 4 --exclude '*.udeb' /pool/main
}}}

Change to <DESTINATION> and run the next script to extract the templates from the debs:

{{{
#!/bin/bash

DEBS=*.deb
mkdir $PWD/templates

for i in $DEBS
do
   apt-extracttemplates -t $PWD $i
   rm *.config* 2>/dev/null
done
}}}

Then process them [[DebianInstaller/Preseed#Processing templates files|with a script]].

The popularity-contest and tasksel templates are likely to find a use in preseeding choices used during the installation. For the eventual rebooted system and new installation the console-setup, exim4-config and keyboard-configuration templates could form part of the preseeding strategy.

= All templates from all .deb files =

Packages with a dependency on debconf would be expected to have a templates file. After removing the pipe symbol and duplicate entries

{{{
DEBS=$(apt-cache rdepends debconf | tr -d'| ' | uniq | grep -v ReverseDepends)
}}}

will hold a list of such debs and

{{{
apt-get download $DEBS
}}}

will put them on your machine [[DebianInstaller/Preseed#Processing templates files|to be processed]].

The rebooted system could have some non-installer packages already downloaded and configured with a late_command.

= Examples =
Post here any links you have to example preseed files. Note that using any of these files directly is not wise, as a malicious person could probably come up with values for a preseed file that makes d-i misbehave. Also, the files are downloaded over http, so are vulnerable to man-in-the-middle spoof attacks. The best way to use any preseed file is to copy it to your own local web server or media, and look it over before using it.

 * Christian Perrier's page documenting automated d-i installs in vmware, using netboot. http://people.debian.org/~bubulle/d-i/vmware-fai.html
## Broken link : * Simon Kirkby's fully automatic basic install. !Warning! will format machine without asking. http://interthingy.com/digby
 * Holger Levsen's d-i examples showing a way to preserve partitions and ssh-host-keys: http://layer-acht.org/d-i/
 * Enrico Zinis conditional partitioning hints: http://www.enricozini.org/2008/tips/d-i-conditional-partitioning/
 * Using network-console and preseeding is described on two pages, DebianInstaller/NetworkConsole and [[DebianInstaller/Remote]]
 * Phil Hands' d-i setup, that allows minimal (i.e. no exim) installs, works from CD, PXE & USB (read the HOWTO's), and allows custom configs to be specified at the boot: prompt http://hands.com/d-i/
 * DebianInstaller/AsSshClient for using d-i as a ssh terminal
 * Christian Perrier documented a D-I demo setup in DebianInstaller/BabelBox
 * Debian Administration has an article on using preseeding: http://www.debian-administration.org/articles/394
 * Filip Van Raemdonck documented modifying an iso to include the preseed file in [[DebianInstaller/Preseed/EditIso]]
 * Matt Taggart's notes and configuration, including using serial console and postfix. http://lackof.org/taggart/hacking/d-i_preseed/
 * Step by Step guide on how to integrate non-free firmware and preseed.cfg [[https://wiki.n0r1sk.com/index.php/Debian_Remaster_Netinstaller_-_Integrate_Firmware_bnx2x_and_Preseed|Remaster Netinstaller image]]
 * In debian-boot Charles Plessey [[https://lists.debian.org/debian-boot/2016/09/msg00075.html|posted]] about a [[https://people.debian.org/~plessy/debconfTemplateToHTML.hs|script]] he is using to collate debconf templates in a [[https://people.debian.org/~plessy/DebianInstallerDebconfTemplates.html|single HTML page]].
 * ShowMeBox has [[https://anonscm.debian.org/cgit/showme/|scripts]] to repackage a netinst image embedding a preseeding file.

= Notes =
 * Do not work off a {{{debconf-get-selections}}} ({{{--installer}}}) generated {{{preseed.cfg}}} but get the values from it and modify the example preseed file with them.
 * Be aware there is only one space in preseed files between subkey and value on "{{{owner key/subkey value}}}" lines.
 * Do not reboot in the {{{base-config/late_command}}} command, the installation process will start again at the start of the 2nd stage.
 * Preseeding has changed significantly in etch, preseed files for sarge will need to be updated or re-done. The largest change is the removal of base-config, which means that {{{base-config/late_command}}} and {{{base-config/early_command}}} are no longer available.
 * To install additional packages in etch, you can {{{preseed preseed/early_command}}} to run "apt-install package".
 * Look in debconf-devel(7) in the debconf-doc package for more docs about d-i and debian-installer preseed questions.
 * If your preseed value is being ignored and whilst using DEBCONF_DEBUG=5 to watch the debconf output you see "FSET blah false" it just means that a piece of code really wants that question to be seen, and such questions are not normally preseedable - the only way to avoid them is to avoid the situation that gives rise to that question being asked.

Translation(s): English - Français


Preseeding d-i

Preseeding provides a way to set answers to questions asked during the installation process, without having to manually enter the answers while the installation is running. This makes it possible to fully automate most types of installation and even offers some features not available during normal installations.

Most of the questions asked by DebianInstaller can be preseeded by setting the answers in the debconf database. The Installation Guide includes an extensive appendix dedicated to preseeding. For concrete preseed files look below. Feel free to add any information that is not covered in the manual to the notes below.

Preseeding methods

As mentioned in the official installation guide, there are several ways to feed the preseed file to the installer.

Adding the preseed file to the installer's initrd.gz

Installation can be fully automated by adding a preseed file to the installer ISO's initrd.gz. This method is described in detail in this wiki article. The downside of this method is that net installer has to be generated whenever a preseed file is modified.

Autoloading the preseeding file from a webserver via DHCP

If you have control over the DHCP server on your network, this method allows fully automated installations; as demonstrated and documented at Hands-off.

Loading the preseeding file from a webserver

Most install methods you can interrupt early on and add a URL to a preseed file, for an almost fully automated installations. Here exemplified with the graphical installer:

  • When the graphical installer boot menu appears, press ESC

  • (Type "help" if you want view generic help)
  • Type "auto url=http://webserver/path/preseed.cfg", replacing the URL with the address to your preseed configuration file

The "auto" command launches the installation in the automated mode, where the configuration of hostname, locale and keymap are postponed so that they can be answered from the preseed file loaded from the network. You could use "install url=..." but you'd have to answer these questions manually, regardless of what you have in the preseed config. If a server path isn't specified the path 'd-i/<codename>/preseed.cfg' will be tried, for example d-i/stretch/preseed.cfg. Note that network configuration options (netcfg/*) cannot be applied via a network-loaded preseed.cfg file, as the network must be configured before the preseed file can be fetched. If network configuration options must be declared, needed options have be passed as kernel options (eg netcfg/choose_interface=eth0).

Note that if the preseed config is loaded over https the install environment may not recognise the certificates presented by the webserver. You can add the option "debian-installer/allow_unauthenticated_ssl=true" to bypass certificate checks.

Default preseed files

When creating a preseed file, you should start from a known good, default preseed file:

If you use a preseed file for an older, newer or otherwise different OS, you will most likely be prompted for answers at some point, even if you thought you automated everything.

Preseeding and the installer's debconf templates

As part of its construction the Debian Installer uses udeb files. These files are similar to normal .debs and have a control section which may contain a file called templates which, amongst other things, contains questions which can be asked during the installation. The answers to these questions can, in many cases, be preseeded. Not all udebs have a templates file.

If you have a .udeb its templates file can be extracted using apt-extracttemplates, which is in the apt-utils package. The command

apt-extracttemplates -t $PWD file.udeb

produces two files in the same directory as file.udeb. With ls -l you should see something like

file.config.S7Fsld
file.template.4tyDFV

The terminating string is a random one and the second file is the one of interest. This contains the information necessary to preseed answers to questions asked by the installer.

Processing templates files

Let's assume you have all the available udeb files for your chosen suite (stable, testing or unstable) and are in the directory containing them. The templates files from them will be extracted by

UDEBS=*.udeb
mkdir $PWD/templates

for i in $UDEBS
do
   apt-extracttemplates -t $PWD $i
   rm *.config* 2>/dev/null
done

This is a script to obtain all English language information from a selection of templates and put it in a single file after changing to the templates directory:

FILES=*.template*

for f in $FILES
do
# Have titled sections for data from each template file.
TITLE=$(echo $f |cut -d"." -f1)
echo -e "\n\n\n********** $TITLE **********" >> preseed.all

# Extract data from templates and do a bit of tidying up.
sed '/^Indices-.*\.UTF/d' $f        \
| sed '/^Choices-.*\.UTF-8/d'       \
| awk '/^Template:/,/-.*\.UTF-8:/'  \
| awk '!/-.*\.UTF-8:/'              \
| sed '/^Template:/{x;p;x;}'        \
>> preseed.all
done

Most of the non-question data can be eliminated with

FILES=*.template*

for f in $FILES
do
# Have titled sections for data from each template file.
TITLE=$(echo $f |cut -d"." -f1)
echo -e "\n\n\n********** $TITLE **********" >> preseed.all

# Extract data from templates and remove text, error, title 
# and note data types.
sed '/^Indices-.*\.UTF-8/d' $f                          \
| sed '/^Choices-.*\.UTF-8/d'                           \
| awk '/^Template:/,/-.*\.UTF-8:/'                      \
| awk '!/-.*\.UTF-8:/'                                  \
| sed '/^Template:/{x;p;x;}'                            \
| sed ':a $!N;s/\nType: text/ Type: text/;ta P;D'       \
| sed '/Type: text/,/^$/d'                              \
| sed ':a $!N;s/\nType: error/ Type: error/;ta P;D'     \
| sed '/Type: error/,/^$/d'                             \
| sed ':a $!N;s/\nType: title/ Type: title/;ta P;D'     \
| sed '/Type: title/,/^$/d'                             \
| sed ':a $!N;s/\nType: note/ Type: note/;ta P;D'       \
| sed '/Type: note/,/^$/d'                              \
>> preseed.all
done

Obtaining udeb files from a Debian archive

For a small handful of files it is probably convenient to download them from Debian website's Packages page (View package lists). However, it is worthwhile considering using apt-get and an archive in /etc/apt/sources.list. A suitable entry is:

deb http://httpredir.debian.org/debian stable main/debian-installer

Then

apt-get update
apt-get install <udeb_package_name>

With the previous entry as the only one in sources.list a list of available udebs can be written to a file using

apt-cache dumpavail | grep ^Package: | cut -d" " -f2 > udebpkgs

and the contents of udebpkgs downloaded with

for pkg in $(cat udebpkgs) ; do apt-get download $pkg ; done

Post-processing with apt-extracttemplates and a script is undertaken as described in a previous section.

Obtaining udeb files from a Debian ISO

Without root privileges extraction of all the udebs used in an ISO can do done with

bsdtar -C <DESTINATION> -xf <ISO> --strip-components 4 --exclude '*.deb' /pool/main

Post-processing with apt-extracttemplates and a script is carried out as described earlier.

Obtaining deb files from a Debian ISO

Without root privileges extraction of all the debs used in an ISO can do done with

bsdtar -C <DESTINATION> -xf <ISO> --strip-components 4 --exclude '*.udeb' /pool/main

Change to <DESTINATION> and run the next script to extract the templates from the debs:

DEBS=*.deb
mkdir $PWD/templates

for i in $DEBS
do
   apt-extracttemplates -t $PWD $i
   rm *.config* 2>/dev/null
done

Then process them with a script.

The popularity-contest and tasksel templates are likely to find a use in preseeding choices used during the installation. For the eventual rebooted system and new installation the console-setup, exim4-config and keyboard-configuration templates could form part of the preseeding strategy.

All templates from all .deb files

Packages with a dependency on debconf would be expected to have a templates file. After removing the pipe symbol and duplicate entries

DEBS=$(apt-cache rdepends debconf | tr -d'| ' | uniq | grep -v ReverseDepends)

will hold a list of such debs and

apt-get download $DEBS

will put them on your machine to be processed.

The rebooted system could have some non-installer packages already downloaded and configured with a late_command.

Examples

Post here any links you have to example preseed files. Note that using any of these files directly is not wise, as a malicious person could probably come up with values for a preseed file that makes d-i misbehave. Also, the files are downloaded over http, so are vulnerable to man-in-the-middle spoof attacks. The best way to use any preseed file is to copy it to your own local web server or media, and look it over before using it.

Notes

  • Do not work off a debconf-get-selections (--installer) generated preseed.cfg but get the values from it and modify the example preseed file with them.

  • Be aware there is only one space in preseed files between subkey and value on "owner key/subkey value" lines.

  • Do not reboot in the base-config/late_command command, the installation process will start again at the start of the 2nd stage.

  • Preseeding has changed significantly in etch, preseed files for sarge will need to be updated or re-done. The largest change is the removal of base-config, which means that base-config/late_command and base-config/early_command are no longer available.

  • To install additional packages in etch, you can preseed preseed/early_command to run "apt-install package".

  • Look in debconf-devel(7) in the debconf-doc package for more docs about d-i and debian-installer preseed questions.
  • If your preseed value is being ignored and whilst using DEBCONF_DEBUG=5 to watch the debconf output you see "FSET blah false" it just means that a piece of code really wants that question to be seen, and such questions are not normally preseedable - the only way to avoid them is to avoid the situation that gives rise to that question being asked.