setting the hostname is not persistent accross reboots
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snappy |
Fix Released
|
Undecided
|
James Hunt |
Bug Description
Setting the hostname works fine, /etc/hostanme is update but after a reboot "hostname" output the wrong value "localhost". /etc/hostname is still correct.
Might be that something (systemd?) read /etc/hostname too early, i.e. before the writable paths are merged.
Steps from Daniel Watkins to reproduce:
"""
$ kvm -m 512 -redir :8090::80 -redir :8022::22 <image> &
$ ssh-copy-id -p 8022 localhost ubuntu@localhost
...
$ ssh -p 8022 ubuntu@localhost hostname
localhost.
$ ssh -p 8022 ubuntu@localhost cat /etc/hostname
localhost.
$ echo test | ssh -p 8022 ubuntu@localhost sudo tee /etc/hostname
test
$ ssh -p 8022 ubuntu@localhost sudo hostname -F /etc/hostname
$ ssh -p 8022 ubuntu@localhost hostname
test
$ ssh -p 8022 ubuntu@localhost sudo reboot
sudo: unable to resolve host test
$ ssh -p 8022 ubuntu@localhost hostname
localhost.
$ ssh -p 8022 ubuntu@localhost cat /etc/hostname
test
"""
Related branches
- Martin Pitt: Approve
-
Diff: 53 lines (+26/-0)4 files modifieddebian/changelog (+6/-0)
debian/install (+1/-0)
debian/links (+1/-0)
lib/systemd/system/snappy-set-hostname.service (+18/-0)
Changed in snappy-ubuntu: | |
assignee: | nobody → James Hunt (jamesodhunt) |
Changed in snappy-ubuntu: | |
status: | New → In Progress |
Changed in snappy-ubuntu: | |
status: | In Progress → Fix Committed |
Changed in snappy-ubuntu: | |
status: | Fix Committed → Fix Released |
affects: | snappy-ubuntu → snappy |
My theory for this is behavior is: system- data/etc/ writable/ hostname
- /etc/hostname is a overlay in /writable/
- on boot our initramfs hook prepares the /etc/fstab that contains the mount for /etc/hostname but does not mount it (this is for systemd) so /etc/hostname contains "localhost"
- when systemd runs it calls hostname_setup() in main.c:1563, the olverlay is not mounted yet so it uses the old "localhost"
- and then runs into its main loop where it executes the units to mount the overlay