Skip to main content
Topic: hostname and shutdown (Read 2339 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

hostname and shutdown

After some updates a few days back I noticed the hostname was not set, the XFCE terminal prompt and title said unknown hex hex instead of the hostname. Setting it with sudo hostname name worked, but it didn't persist over reboots. I tried /etc/conf.d/hostname, /etc/openrc/conf.d/hostname from the Arch and gentoo OpenRC wiki pages with no luck. Putting just the hostname name in /etc/hostname worked though. I don't know how the hostname got lost in the first place really. There was an /etc/hostname.pacsave in existence though. Perhaps I missed some info message during the upgrade.
While rebooting and trying various things I found if I didn't manually set the hostname first, when I hit the shutdown option in the XFCE desktop it wouldn't work, and if I tried it again I got an error message. sudo poweroff in a terminal would shut the OS down correctly, but sudo shutdown -Ph now brought down the OS but then hung at the last bit without powering off the computer, so I had to press and hold the power button to finally switch it off.
It all seems to be back working normally now though, this is with only the ck kernel installed now, although I don't know if that is related. So there isn't a problem any more, but I thought you might be interested.

Re: hostname and shutdown

Reply #1
Hello,
I had same problem after i migrated from Manjaro-openrc.
But for me some other configs were also missing... most noticeable was /etc/locale which caused errors with text encoding...

I recommend you to check other configs too, also there were .pacsave files...

 


Re: hostname and shutdown

Reply #4
I think hostname is by default activated as a boot level service, personally I've never had to activate it manually.

Re: hostname and shutdown

Reply #5
i checked and it is.. still 2 month ago i had a problem that the hostname was not set and i had a problem when i suspend my laptop and woke it and connected to another Network ... I think network manager changed hostname or something ot X and bash did not recognize the hostname set by openrc... everything started to work after i set the hostaname in /etc/hostname.
I think it is much safer to set it in /etc/hostname because some of programs can use this file and they have no idea that openrc exist...
Maybe i am wrong but this is what i experienced in my own...

Re: hostname and shutdown

Reply #6
Adding a bit more detail:
"OpenRC can set the host name either from /etc/hostname or from /etc/conf.d/hostname"
I think I had an existing /etc/conf.d/hostname but it didn't work any more after this update, although it had been working before. I hadn't updated for at least a couple of weeks before this I should clarify here, although I had updated a few times after converting from Manjaro without seeing this problem. As well as updating I removed a few unused items to save on downloads, like Firefox and it's dependencies so there were a few additional things going on to confuse the issue perhaps, but I couldn't see anything that was potentially relevant when I reviewed these. When I looked at the OpenRC source code and the hostname command source code, hostname just used some library calls to set things with the kernel, so didn't seem like it could cause problems like this.
OpenRC seemed to use this variable which I think is probably set at build time, perhaps by a configure option. Perhaps that has changed, or I was still running with some Manjaro package or conf file that hadn't been replaced until the latest round of updates?
init.d/hostname.in
read h x <@SYSCONFDIR@/hostname
source="from @SYSCONFDIR@/hostname"

And that seemed to default to /etc
mk/sys.mk
34:SYSCONFDIR?=      ${PREFIX}/etc

So I thought, aha, must give it a try with /etc/hostname and it worked then. But perhaps it is only XFCE that needs /etc/hostname? However, without /etc/hostname the hostname command returned nothing until it was set manually, so it couldn't have been set at boot unless it got unset again, which I suppose is also possible.