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

Belisko Marek marek.belisko at gmail.com
Mon Jul 1 19:42:26 UTC 2019


On Mon, Jul 1, 2019 at 9:48 AM Lennart Poettering
<lennart at poettering.net> wrote:
>
> On Mo, 01.07.19 08:25, Belisko Marek (marek.belisko at gmail.com) wrote:
>
> > 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.
>
> Two issues: /etc/hostname is read very early during boot, before PID 1
> starts the first other userspace program. This means you'd have to
> mount that fs from the initrd already, to be applied.
>
> hostnamed and friends live in a sandbox these days, that prohibit
> write access outside of /etc, and read access to various other
> dirs. If you play such symlink games, you have to turn that off. See
> the systemd-hostnamed.service service file, specifically
> ProtectSystem= and similar options.
>
> That all said, instead of introducing /data and keeping the whole of
> the OS read-only, I'd recommend to instead operate with a read-only
> /usr only, combined with a writable / that comes up in the initrd
> already and is automatically populated on first boot. i.e. keep /etc
> and everything else as empty as possible, and store only the stuff in
> it actually needed. systemd itself is all set up for this mode, and is
> happy if there's no configuration in /etc around. Some distros are not
> that happy with such a set up however, they require some bits in /etc
> existing. Ideally distros would be fixed to not require that and be
> happy with /etc entirely empty, but until then you can use
> tmpfiles.d/'s "C" lines copy in basic necessary configuration into
> /etc from /usr/share/factory/.
OK thanks for valuable info.
>
> Lennart
>
> --
> Lennart Poettering, Berlin

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


More information about the systemd-devel mailing list