Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Hostname set to "archlinux" after boot, despite /etc/hostname and initscript. (Read 624 times) previous topic - next topic
0 Members and 7 Guests are viewing this topic.

Hostname set to "archlinux" after boot, despite /etc/hostname and initscript.

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:
Code: [Select]
       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):
Code: [Select]
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
Code: [Select]
# 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!


Re: Hostname set to "archlinux" after boot, despite /etc/hostname and initscript.

Reply #2
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.

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.

What might be the issue here?

Regards!
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.

Re: Hostname set to "archlinux" after boot, despite /etc/hostname and initscript.

Reply #3
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.

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.

What might be the issue here?

Regards!
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 ...

Re: Hostname set to "archlinux" after boot, despite /etc/hostname and initscript.

Reply #4
If you use OpenRC, then editing /etc/hostname might be not enough. You should add
Code: [Select]
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.

Re: Hostname set to "archlinux" after boot, despite /etc/hostname and initscript.

Reply #5
If you use OpenRC, then editing /etc/hostname might be not enough. You should add
Code: [Select]
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

Code: [Select]
# Hostname fallback if /etc/hostname does not exist

Also, there I have set
Code: [Select]
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".

Re: Hostname set to "archlinux" after boot, despite /etc/hostname and initscript.

Reply #6
Just for completeness, I want to refer to this post where I had another strange issue which was due to manual over-mount of /run:

Turned out that I manually mounted some temporary filesystem at /run, not having recognised that the init scripts already mount a tmpfs there.

So there is a time where /run gets over-mounted and so the old content hidden. And this broke things.
Regards!

I suspect that this is also here the case. I have not observed wrongly set hostname since then. So I mark as "solved".

Re: Hostname set to "archlinux" after boot, despite /etc/hostname and initscript.

Reply #7
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".
That's why I asked you to post your 'uname -a', you'd have saved lots of time, had you responded.