Ahoj,
when I reboot my computer, it (sometimes? -- at least in interactive startup the hostname was set correctly at least once) fails to set the correct hostname, and instead has "archlinux" set as hostname.
I use OpenRC as init system.
In
/etc/hostname I have my desired hostname, and doing a
/etc/init.d/hostname restart does set my hostname.
The init script
hostname is started automatically at boot.
The output of
rc-update:
NetworkManager | boot
acpid | boot
agetty.tty1 | default
agetty.tty2 | default
agetty.tty3 | default
agetty.tty4 | default
agetty.tty5 | default
agetty.tty6 | default
alsasound | boot
binfmt | boot
bootmisc | boot
cgroups | sysinit
cupsd | default
dbus | default
devfs | sysinit
dmesg | sysinit
dovecot | default
dropbear | default
elogind | boot
fcron | default
fsck | boot
gpm | boot
hostname | boot
hwclock | boot
keymaps | boot
killprocs | shutdown
kmod-static-nodes | sysinit
local | default nonetwork
localmount | boot
loopback | boot
metalog | boot
modules | boot
mount-ro | shutdown
mtab | boot
net.lo | boot
netmount | default
opensysusers | boot
opentmpfiles-dev | sysinit
opentmpfiles-setup | boot
postfix | default
procfs | boot
root | boot
save-keymaps | boot
save-termencoding | boot
savecache | shutdown
sddm | default
seedrng | boot
swap | boot
sysctl | boot
sysfs | sysinit
termencoding | boot
udev | sysinit
udev-trigger | sysinit
uksmd | default
grep . /etc/rc.conf | grep -v '^#' (i.e. lines that have non-commented out content):
rc_parallel="NO"
rc_interactive="YES"
rc_shell=/usr/bin/sulogin
rc_depend_strict="NO"
rc_logger="NO"
rc_log_path="/var/log/rc.log"
rc_verbose=no
rc_start_wait=0
rc_crashed_stop=NO
rc_crashed_start=YES
rc_nocolor=NO
unicode="YES"
rc_tty_number=12
After I discovered this, I also tried to set hostname already in the initcpio; for this I added the
hostdata hook, but it did not resolve the issue, the hostname after system boot is not my desired hostname but
archlinux.
I did a
grep -r archlinux /etc | grep -v pacman.d/mirrorlist-arch, and it does not show anything suspicious.
I discovered that there is also a file
/etc/conf.d/hostname, it contains
# Hostname fallback if /etc/hostname does not exist
hostname="localhost"
and should not play a role since
/etc/hostname exists.
What might be the issue here?
Regards!
Post your 'uname -a'.
I think I have solved this.
My
/etc/hostname was a symlink to another directory on the same mountpoint (
/etc/hostname ->
/usr/local/etc/hostname, deliberately done by myself), and after I now made it a regular file the hostname is set at bootup. Seems that
/etc/hostname is only partially supported. Would be interesting where it breaks that
/etc/hostname is a symlink within the same mountpoint.
I step back, this seems not to be the solution, I have for testing reasons resorted back to my symlink and now the hostname is also correctly set. And as I remember it was not always that "archlinux" was the hostname, only sometimes, so an erratic behaviour. I have to watch it further ...
If you use OpenRC, then editing
/etc/hostname might be not enough. You should add
hostname="your-host-name"
in the
/etc/conf.d/hostname file. This is the file which is read by the hostname service from runlevel boot.
OK, but this file explicitly has a comment saying
# Hostname fallback if /etc/hostname does not exist
Also, there I have set
hostname="localhost"
and I never observe that "localhost" is my hostname, so
this file seems not to play a role.
Anyway, I will test and write something else (which is neither "localhost", nor my desired hostname, nor "archlinux", in there, just in case that "localhost" is handled specially and the file is indeed playing a role) in there and we will see.
Anyway, strange that I get "archlinux" while I am on an artix system. (I have the packages
artix-archlinux-support and
lib32-artix-archlinux-support installed, though. But they do not seem to install any relevant files according to
pacman -Ql.)
EDIT:Hostname "archlinux" might come from my kernel. I have installed the package
home_post-factum_kernels_Arch/linux-pf-silvermont and use that kernel, until I come to compile my own.
And
zgrep HOSTNAME /proc/config.gz shows
CONFIG_DEFAULT_HOSTNAME="archlinux".
Just for completeness, I want to refer to this post (https://forum.artixlinux.org/index.php/topic,5739.msg35982.html#msg35982) where I had another strange issue which was due to manual over-mount of
/run:
I suspect that this is also here the case. I have not observed wrongly set hostname since then. So I mark as "solved".
That's why I asked you to post your 'uname -a', you'd have saved lots of time, had you responded.