2

I'm currently playing around with debian-installer at home (using Devuan Linux) over PXE boot and would like to have the installer ask for a hostname and domain with pre-set default value for the domain only and unsure if this is possible? The intention is that if I can learn how preseeding works I hope to bring this knowledge to my workplace in the hope we can make Ubuntu easier for our support teams to deploy, as it is very much manual at present.

To my understanding, in order for netboot to occur (and I'm hoping Devuan netboot works in much the same way as Debian as much of the documentation I've read has actually been Debian) netcfg must complete before it obtains its preseed file from TFTP which means in order to force the installer re-run the netcfg portion of setup I have to perform...

d-i preseed/early_command string kill-all-dhcp; netcfg

...before specifying...

d-i netcfg/hostname seen false
d-i netcfg/domain string network-name.int
d-i netcfg/domain seen false

...in order to get debian-installer to ask the question, but also provide a default value.

This page suggests this is true: https://www.debian.org/releases/stable/amd64/apbs05.html.en

...specifically: B.5.2. Using preseeding to change default values

It is possible to use preseeding to change the default answer for a question, but still have the question asked. To do this the seen flag must be reset to “false” after setting the value for a question.

This Reddit article suggests someone else also tried this to no avail with 'seen' set to both false and true: https://www.reddit.com/r/debian/comments/7ak9h0/debian_preseed_installation_no_dialog_for/

I also read elsewhere that debconf priority has a role to play here also. The netboot vesamenu.c32 included with the Devuan netboot files specifies 'priority=critical' on the kernel command-line, but I understand the hostname and domain dialog boxes are high priority instead, and as a result do not appear regardless unless debconf priority is set to high. Doing so, causes the installer to ask for hostname as desired, but sadly after providing one also presents a menu asking what the next step should be. I played about with setting priority to high on the kernel command-line, then having the preseed run the above kill-all-dhcp;netcfg line to reinit networking and force it to ask for a hostname, and THEN changing priority level again to critical using:

debconf debconf/priority critical 

... (as shown in the above reddit post at the top of the preseed file given) but sadly this resulted in the installer not presenting the hostname question or the domain question, and running through fully-automated install with no questions being asked.

One blog article I read (unfortunately can't find this in my list of open tabs) suggested that order of the commands in the preseed file doesn't matter, leading me to believe I can't change priority after answering the hostname question

At the moment, priority on the kernel command-line is set to critical, in preseed.cfg I specify the following relevant section:

## Locale/Keymap configuration
d-i debian-installer/locale string en_GB
d-i keyboard-configuration/xkb-keymap select gb

## Network configuration (none, just use DHCP)
d-i netcfg/choose_interface select auto

## Hostname configuration
d-i preseed/early_command string kill-all-dhcp; netcfg

debconf debconf/priority high

d-i netcfg/hostname string CHANGETHIS
d-i netcfg/hostname seen false
d-i netcfg/domain string network-name.int
d-i netcfg/domain seen false

debconf debconf/priority string critical 

I know I could resolve this by having debian-installer run a custom script at the end to change the hostname in /etc/hostname and update /etc/hosts prior to reboot, but I wanted to have the installation source untouched so any future upgrades require as little steps as possible to get working (hopefully get away with just modifying the preseed, instead of having to customise and update scripts to work with the latest OS version), plus another article I had read suggested I can only specify d-i preseed/late_command and/or d-i preseed/early_command once so I'd rather save that for a future situation where preseed really isn't able to handle something we need.

  • When you work with preseed , you must set DEBCONF_DEBUG=5 on the kernel command line . and in /var/log/syslog you will see which variable debian-installer prompt you . This can help you . – EchoMike444 Jan 4 at 17:16
0

Several hours of testing later, managed to find a working answer. Wanted to document should others come looking for an answer.

The answer is not to do any netcfg configuration in the preseed file at all, instead doing it on the kernel command line, with priority set to high and not critical.

I used the following menu.c32 / vesamenu.c32 configuration:

label customauto
    menu label ^Automated install - Custom Auto
    kernel debian-installer/amd64/linux
    append auto=true priority=high netcfg/get_hostname?= netcfg/get_domain?=internal.domain preseed/url=tftp://<ip address to tftp server>/preseed.cfg vga=788 initrd=debian-installer/amd64/initrd.gz --- quiet 

Notes from testing: Using the following on the kernel command line results in the given behaviours:

netcfg/get_hostname=hostname will set the hostname of the system to what is specified ('hosname' in this case) and no question is asked, even with priority set to 'high'.

netcfg/get_hostname?=hostname (note the ? and its position) will set a default value ('hostname' in this case), but also ask the question with your specified default value.

netcfg/get_hostname?= will pass no default value at all, and ask the question. I didn't think this was going to be valid initially, but it seems to work in my testing!

The same is for the netcfg/get_domain line, and I presume any other question, but I haven't tested other questions as this was my desired configuration.

In the preseed file, I removed all the d-i lines for netcfg, and right at the very top before anything else is specified, I set priority to critical:

d-i debconf/priority string critical

Once installation is completed, I confirmed that hostname is set correctly, /etc/hosts was also set-up correctly, and that all other settings in my preseed file were applied correctly leading me to believe this configuration is good.

This isn't entirely the answer I wanted, I wanted it all done in the preseed file as now I have to ensure that if I want to change behaviour later as needs change, I have to check two places, but I think some compromise needs to be made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.