Bug 76102 - hostnamectl set-hostname destroys /etc/machine-info
Summary: hostnamectl set-hostname destroys /etc/machine-info
Status: RESOLVED NOTABUG
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium minor
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-13 08:09 UTC by Brian "Redbeard" Harrington
Modified: 2014-03-13 19:08 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Brian "Redbeard" Harrington 2014-03-13 08:09:25 UTC
While doing some work in trying ensure hostnames get set correctly on CoreOS I found that running hostnamectl set-hostname would destroy the file /etc/machine-info.

In this case the hostname "host-10-0-0-7" is the hostname assigned via DHCP.  The file /etc/machine-info was created by hand and the system was subsequently rebooted.


[bharrington@leviathan-alticon-net coreos]$ ssh 192.168.1.202
Warning: Permanently added '192.168.1.202' (RSA) to the list of known hosts.
Last login: Thu Mar 13 00:55:57 UTC 2014 from 192.168.1.63 on pts/1
   ______                ____  _____
  / ____/___  ________  / __ \/ ___/
 / /   / __ \/ ___/ _ \/ / / /\__ \
/ /___/ /_/ / /  /  __/ /_/ /___/ /
\____/\____/_/   \___/\____//____/
core@host-10-0-0-7 ~ $ 
core@host-10-0-0-7 ~ $ 
core@host-10-0-0-7 ~ $ 
core@host-10-0-0-7 ~ $ cat /etc/machine-info 
PRETTY_HOSTNAME=coreos-2.coreos.lab
core@host-10-0-0-7 ~ $ sudo hostnamectl set-hostname coreos-1.coreos.lab
core@host-10-0-0-7 ~ $ cat /etc/machine-info 
cat: /etc/machine-info: No such file or directory
core@host-10-0-0-7 ~ $ hostname
coreos-1.coreos.lab
core@host-10-0-0-7 ~ $ cat /etc/hostname 
coreos-1.coreos.lab
Comment 1 Lennart Poettering 2014-03-13 19:08:18 UTC
"systemctl set-hostname" sets all three hostnames by default. If you want to set only the pretty, or only the transient, or only the static one use switches like --pretty, --transient, --static. You can even combine them...

"systemctl set-hostname" will set all three names, then detect that there's no point in keeping the pretty name in place if it is char-for-char identical with the static one, and simply removes the file since there's nothing else in there. 

So, this is intended operation. And explained in the man page...


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.