[systemd-devel] symlinking /etc/hostname to /data/etc/hostname woes

Jérémy ROSEN jeremy.rosen at smile.fr
Mon Jul 1 07:22:42 UTC 2019


For that kind of complicated case, I would recommand mounting /data in your
initrd (i.e before the real systemd is started)

If you don't have an initrd in your system, you can replace systemd with a
simple shell script. We did something similar recently

#!/bin/sh
/bin/mount /dev/sda4 /data

exec /usrlib/systemd


Note that we "exec" systemd, not just call it from the shell script. It is
important that the real systemd is run as pid1

Le lun. 1 juil. 2019 à 08:25, Belisko Marek <marek.belisko at gmail.com> a
écrit :

> Hi,
>
> I'm working on rpi3 by using mender OTA system and for identifying
> devices I would like to have for every of it different hostname. As
> rootfs is update-able (rootA, rootB layout) so I tried to create file
> in /data/etc (which is permanent) and in /etc create symlink. When now
> boot my system I still get hostname localhost.
>
> My log is:
>
> journalctl -b | grep hostname
> Jun 28 19:18:14 localhost systemd[1]: No hostname configured.
> Jun 28 19:18:14 localhost systemd[1]: Set hostname to <localhost>.
> Jun 28 19:18:16 localhost kernel[137]: [    1.507423] systemd[1]: No
> hostname configured.
> Jun 28 19:18:16 localhost kernel[137]: [    1.507454] systemd[1]: Set
> hostname to <localhost>.
> Jun 28 19:18:16 localhost systemd-resolved[135]: Defaulting to hostname
> 'linux'.
>
> If I read sources correctly  hostname is set in early startup of
> systemd and then using systemd-hostnamed (which I've edited and added
> Requires=data.mount -> as I need to wait when /data partition is
> mounted).
>
> Also when system is booted and /data is mounted and run below I get
> strange issue:
>
> root at localhost:~# hostnamectl set-hostname 321
> Could not set property: Failed to set static hostname: Read-only file
> system
> root at localhost:~# Jul 03 17:26:01 321 systemd-hostnamed[336]: Failed
> to write static host name: Read-only file system
> Jul 03 17:26:01 321 systemd-resolved[135]: System hostname changed to
> '321'.
>
> while / and /data are both rw.
>
> Any ideas how to overcome this problem? Thanks.
>
> BR,
>
> marek
>
> --
> as simple and primitive as possible
> -------------------------------------------------
> Marek Belisko - OPEN-NANDRA
> Freelance Developer
>
> Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
> Tel: +421 915 052 184
> skype: marekwhite
> twitter: #opennandra
> web: http://open-nandra.com
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel



-- 
[image: SMILE]  <http://www.smile.eu/>

20 rue des Jardins
92600 Asnières-sur-Seine
*Jérémy ROSEN*
Architecte technique

[image: email] jeremy.rosen at smile.fr
[image: phone]  +33 6 88 25 87 42
[image: url] http://www.smile.eu

[image: Twitter] <https://twitter.com/GroupeSmile> [image: Facebook]
<https://www.facebook.com/smileopensource> [image: LinkedIn]
<https://www.linkedin.com/company/smile> [image: Github]
<https://github.com/Smile-SA>

[image: Découvrez l’univers Smile, rendez-vous sur smile.eu]
<https://www.smile.eu/fr/publications/livres-blancs/yocto?utm_source=signature&utm_medium=email&utm_campaign=signature>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190701/67c9edf7/attachment.html>


More information about the systemd-devel mailing list