[Bug 1046405] Re: hostname.conf should prefer kernel cmdline 'hostname=' to contents of /etc/hostname

Scott Moser smoser at ubuntu.com
Wed Sep 5 16:03:13 UTC 2012

You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to hostname in Ubuntu.

  hostname.conf should prefer kernel cmdline 'hostname=' to contents of

Status in “hostname” package in Ubuntu:

Bug description:
  It would be nice if /etc/init/hostname.conf allowed the kernel cmdline
  to override the value in /etc/hostname.  This is useful in the netboot
  case where the kernel cmdline can be controlled on a per MAC basis,
  but the filesystem is read-only.

  At this point I'm looking for input on possible fallout of a change
  like this.

  Here is the suggested /etc/init/hostname.conf:
  # This task is run on startup to set the system hostname from /etc/hostname,
  # falling back to "localhost" if that file is not readable or is empty and
  # no hostname has yet been set.

  description     "set system hostname"

  start on startup

    { read cmdline < /proc/cmdline || : } >/dev/null 2>&1
    if hn="${cmdline#*hostname=}" && [ "$hn" != "${cmdline}" ]; then
       hn="${hn%% *}"
       echo "setting hostname ${hn}" >/dev/console
       exec hostname "${hn}"
    exec hostname -b -F /etc/hostname
  end script

  ProblemType: Bug
  DistroRelease: Ubuntu 12.10
  Package: hostname 3.11ubuntu1
  ProcVersionSignature: Ubuntu 3.5.0-13.14-generic 3.5.3
  Uname: Linux 3.5.0-13-generic x86_64
  ApportVersion: 2.5.1-0ubuntu4
  Architecture: amd64
  Date: Wed Sep  5 11:53:36 2012
  EcryptfsInUse: Yes
  InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
   PATH=(custom, user)
  SourcePackage: hostname
  UpgradeStatus: Upgraded to quantal on 2011-11-07 (303 days ago)

To manage notifications about this bug go to:

More information about the foundations-bugs mailing list