[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: change hostname without rebooting [SOLVED]



On 11/24/12, Tom H <tomh0665@gmail.com> wrote:
> On Sat, Nov 24, 2012 at 1:04 AM, Zenaan Harkness <zen@freedbms.net> wrote:
>> # Me, wonders why systemd-hostnamed does not run, google says it should:
>>
>> $ echo $PATH
>> /usr/lib/postgresql/8.3/bin:/home/justa/bin:/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/usr/bin:/bin:/usr/games
>>
>> $ dpkg -L systemd|grep hostnamed
>> /lib/systemd/system/systemd-hostnamed.service
>> /lib/systemd/systemd-hostnamed
>>
>> $ cd /lib/systemd/
>>
>> $ file systemd-hostnamed
>> systemd-hostnamed: ELF 64-bit LSB executable, x86-64, version 1
>> (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26,
>> BuildID[sha1]=0x4447f9b433f2bd71e603d2b9060b1196edc64048, stripped
>>
>> $ ./systemd-hostnamed
>> Warning: nss-myhostname is not installed. Changing the local hostname
>> might make it unresolveable. Please install nss-myhostname!
>> Failed to register name on bus: Access denied
>>
>> OK, so now we have another /sbin type directory called /lib/systemd
>> ... should I avoid adding this to my path, as in, is systemd-hostnamed
>> supposed to be wrapped by /bin/hostname, and for now it's not? Or are
>> these commands additional /sbin type commands that we will need now
>> and again?
>>
>> Should systemd-hostnamed actually work for live-changing the hostname?
>> If so, should systemd package suggest or recommend "nss-myhostnamed"
>> aka debian's libnss-myhostname ??
>
> Having executables in "/lib/systemd" probably breaks the FHS,
> AFAIR/AFAIU, but Debian also has executables in, at least, "/lib/init"
> and "/lib/udev".
>
> Upstream systemd uses "/usr/lib/systemd" and that's allowed by the FHS
> for executables not meant to be called by users. Before Fedora's
> "usrmove" change, it probably used "/lib/systemd" but I don't have an
> F-16 install to check.
>
> Why can't you change the hostname with "hostname <new-host-name>" and

I did this,

> change the hostname in "/etc/{hostname,hosts,mailname}" if you want
> the change to survive a reboot?

and this too,

> I wouldn't worry, on Debian, about nss-myhostname/libnss-myhostname
> because there's a line in "/etc/hosts" to resolve the hostname to
> "127.0.1.1" when dhcp's used.

and my /etc/hosts contains, amongst other static assignments, this:
127.0.0.1      localhost lo

BUT, it did not contain an entry for my new hostname... testing ...
added as alias, so now:
127.0.0.1      localhost lo my-new-hostname

BINGO! Now xterms start quickly again! It seems like unnecessary
process startup fragility to me... at least it timed out after 10 or
15s, and not 2m to 5m like systemd mount and now sshfs to
target-system-with-systemd-mount timeout issues I'm still having.

Thank you!

> nss-myhostname allows you to have a two-line "/etc/hosts" mapping
> localhost to "127.0.0.1" and "::1". If you have a dhcp-supplied
> address, your hostname's mapped to "127.0.0.2" (on Fedora; maybe it's
> patched on Debian to map to "127.0.1.1", no idea) and if you have a
> static address your hostname's mapped to that address.


Reply to: