FS#36264 - [systemd] Add /etc/hostname to initcpio hook

Attached to Project: Arch Linux
Opened by Gerardo Exequiel Pozzi (djgera) - Wednesday, 24 July 2013, 16:34 GMT
Last edited by Dave Reisner (falconindy) - Tuesday, 13 August 2013, 16:46 GMT
Task Type Bug Report
Category Packages: Testing
Status Closed
Assigned To Dave Reisner (falconindy)
Tom Gundersen (tomegun)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description: Add /etc/hostname to initcpio hook otherwise all things are logged to journal with default "localhost"

--
add_file /etc/hostname
--

Example:
Jul 24 13:25:10 localhost kernel: Linux version 3.10.2-1-ARCH (tobias@T-POWA-LX)...

Example (fixed):
Jul 24 13:30:35 archbase kernel: Linux version 3.10.2-1-ARCH (tobias@T-POWA-LX)...

Additional info:
systemd-206-1

This task depends upon

Closed by  Dave Reisner (falconindy)
Tuesday, 13 August 2013, 16:46 GMT
Reason for closing:  Won't fix
Additional comments about closing:  See discussion in comments. Not really anything to do here.
Comment by Dave Reisner (falconindy) - Wednesday, 24 July 2013, 17:07 GMT
Nah, this only affects the initramfs. After the switch_root, the real hostname picks up and the journal logs with the real hostname.

...snipped...
Jul 24 12:07:27 localhost kernel: ata2.00: configured for MWDMA2
Jul 24 12:07:27 localhost kernel: scsi 1:0:0:0: CD-ROM QEMU QEMU DVD-ROM 1.5. PQ: 0 ANSI: 5
Jul 24 12:07:27 localhost systemd[1]: Started Cleanup udevd DB.
Jul 24 12:07:27 localhost systemd[1]: Starting Switch Root.
Jul 24 12:07:27 localhost systemd[1]: Reached target Switch Root.
Jul 24 12:07:27 localhost systemd[1]: Starting Switch Root...
Jul 24 12:07:27 localhost systemd[1]: Switching root.
Jul 24 12:07:27 localhost systemd-journal[53]: Journal stopped
Jul 24 12:07:27 beatbox systemd-journal[135]: Runtime journal is using 184.0K (max 49.9M, leaving 74.8M of free 498.5M, current limit 49.9M).
Jul 24 12:07:27 beatbox systemd-journal[135]: Runtime journal is using 188.0K (max 49.9M, leaving 74.8M of free 498.5M, current limit 49.9M).
Jul 24 12:07:27 beatbox systemd-journald[53]: Received SIGTERM
Jul 24 12:07:27 beatbox kernel: FS-Cache: Loaded
Jul 24 12:07:27 beatbox systemd-journal[135]: Journal started
Jul 24 12:07:27 beatbox systemd-cgroups-agent[119]: Failed to get D-Bus connection: Failed to connect to socket /run/systemd/private: No such file or directory
Jul 24 12:07:27 beatbox systemd[1]: systemd 206 running in system mode. (+PAM -LIBWRAP -AUDIT -SELINUX -IMA -SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ)
Jul 24 12:07:27 beatbox systemd[1]: Detected virtualization 'kvm'.
Jul 24 12:07:27 beatbox systemd[1]: Set hostname to <beatbox>.
...snipped...

If this is going to be fixed, I think the right thing to do is give early userspace a static hostname of "initramfs".
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 24 July 2013, 17:21 GMT
Yes that is I wanted to say. Later, hostname is re-set correctly. But this is not consistent...
Comment by Dave Reisner (falconindy) - Wednesday, 24 July 2013, 17:27 GMT
But you aren't guaranteed consistency as the initramfs is not guaranteed to be used on only a single machine...
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 24 July 2013, 17:33 GMT
True and good point, but with the same argument, you can have different configs, or even differents systemd versions and make things even worse :P
Comment by Tom Gundersen (tomegun) - Wednesday, 24 July 2013, 17:54 GMT
@djgera: I don't follow. Initramfs and real root should be independent, having different config/ version should be a supported case (not any combination of course, but within reason).
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 24 July 2013, 18:24 GMT
OK I understand. Anyway "should be independent", sounds good, but is not true at all. We know, in this new systemd age where systemd lives in both real-root-dev and rootfs and any difference in version can be bad. Other point are of dependency is LKM...

If no /etc/hostname is added I agree in setting up at least "initramfs" or in bad words commonly used "initrd" (to be consistent in how systemd calls initramfs)
Comment by Tom Gundersen (tomegun) - Wednesday, 24 July 2013, 20:45 GMT
@djgera: what I meant is that if there is a problem with different versions, we should consider it a bug.

As to a default hostname in the initrd: I don't have anything against it, but I'm not sure I see the benefit either...? Anyway, maybe this should be done in systemd (if it should be done at all). I.e., if in the initrd and no hostname is set, set it to "initrd", or something like that?

Loading...