I am installing Debian Wheezy (netinstall) in VirtualBox using preseed.cfg.

I tried both d-i netcfg/get_hostname string somehost and d-i netcfg/get_hostname string somehost, but in both cases the host gets set as "debian". I tried both at the same time but still the host is set as "debian".

Excerpt from Debian's guide about preconfiguration file:

If you want to force a hostname, regardless of what either the DHCP server returns or what the reverse DNS entry for the IP is, uncommentand adjust the following line

d-i netcfg/hostname string somehost

Is this a bug or am I just unlucky?

  • Trying d-i netcfg/get_hostname string somehost twice doesn't really make sense. Should the question be updated with one occurance being d-i netcfg/hostname string somehost? In which case it would probably answer itself...
    – sampi
    Commented Mar 23, 2023 at 15:26

4 Answers 4


If you are netbooting (with PXE and friends), the hostname is set up before fetching the preseed file, so the hostname should be set on the kernel command-line like this :

hostname=myhostname domain=mydomain

From the introduction of the appendix B (on preseeding) of the debian-installer manual :

An important difference between the preseeding methods is the point at which the preconfiguration file is loaded and processed. For initrd preseeding this is right at the start of the installation, before the first question is even asked. For file preseeding this is after the CD or CD image has been loaded. For network preseeding it is only after the network has been configured.

  • While the answer was more true when posted, the use of aliases for hostname and domain is broken. Use the long form netcfg/get_hostname=unassigned-hostname netcfg/get_domain=unassigned-domain instead. Please see bugs.debian.org/1031643 for details. To actually solve the original posters problem though, netcfg/hostname=myhostname netcfg/domain=mydomain is likely the right arguments.
    – sampi
    Commented Mar 23, 2023 at 15:30
  • Fixed with debian.org/devel/debian-installer/News/2023/20230428 Commented May 1, 2023 at 10:46

Not a solution but a workaround

I too have faced a similar issue and I worked around it by setting the host name after installation via the following lines added at the end of my pressed.cfg:

d-i pressed/late_command string\
    in-target /bin/bash -c 'echo desired_name > /etc/hostname'

The in-target is necessary so that the / refers to the target filesystem (that will eventually become your root filesystem) that usually appears as /target during installation.

  • 1
    I've also used this but with a slight modification so that the hostname is automatically set from a DNS lookup: d-i pressed/late_command string in-target /bin/bash -c 'echo $(dig +short -x $(facter ipaddress)) | sed -e \'s/\.$//\' > /etc/hostname'. This uses "facter" from puppetlabs to get the IP address but you could do something similar using ip addr and sed. Commented May 27, 2015 at 13:58

It's debian-installer limitation. By the time you fetch your preseed config file from network, netcfg has already done it's job and is gone, so it won't refetch values.

somewhat offical kludge is to use in your preseed.cfg line:

d-i preseed/run string http://example.net/d-i/jessie/preseed.sh

and in that preseed.sh then specify:

kill-all-dhcp; netcfg

That way, when network is established and preseed.cfg is fetched, preseed.sh will also be fetch and run, so it will restart netcfg which will then read all preseed values for netcfg/* and configure them correctly (/etc/hostsname, /etc/hosts, /etc/network/interfaces if you're setting static IP configuration via preseed etc)

  • 4
    You can do this without a separate file: d-i preseed/early_command string kill-all-dhcp; netcfg in your preseed file is enough. Tested with Stretch in an automated netinstall. Commented Dec 17, 2017 at 19:57

I found that this problem went away when I removed priority=critical from the arguments I was passing-in to the kernel at the net install command line (via the pxelinux.cfg directory entries).

I assume this means that the question which asks the hostname has been given a priority which is lower than 'critical', and so gets populated with the default answer.

If you do make this change, you may find that you have to preseed some other lower-than-critical answers for other questions later on in the install process...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .