[systemd-devel] Stateless system - Centos8 and overlayfs on root

Tobias Hunger tobias.hunger at gmail.com
Tue Mar 31 07:36:29 UTC 2020


Hi,

You said no data is to be stored when powered down. What do you need
the overlay for then? Just mount to a tmpfs as '/' and centos as
'/usr', which is something that systemd supports out of the box. You
will need at least some files in /etc for this to work, and I just
have the initrd untar some file that I store on the /usr partition
into / to get everything into place.

You can also set up the root filesystem as an overlayfs in the initrd
if you want to go down that route.

https://gitlab.com/cleanroom/cleanroom/-/blob/master/cleanroom/commands/create_initrd.py
has the code I use to create an initrd for my systems (using
mkinitcpio from arch linux, but I am sure similar things are possible
with dracut).

Check lines 111 and following for a systemd unit that extracts a
tarball in the initrd before switching over to the real root.

I use simple filesystem images (containing an EFI, a squashfs for root
and a dm-verity partition for the root) in my setup. The contents of
the EFI partition is copied to the system EFI partition for this to
work. The other two partitions can be used in several forms:
 * dd-ing them all onto separate partitions (works out of the box;-)
 * dd-ing them into separate LVM volumes (lines 132 following in the
script linked above)
 * dropping the image file with a certain name into a folder (lines
152 following and 168 following)

I am pretty sure you can hook into the same places as I do for the
image file magic to make your overlayfs work... but then Fedora is
probably using dracut, so things might be a bit different. But then
dracut apparently also uses systemd in the back, so the boot up
process should be somewhat similar.

Best Regards,
Tobias

PS: Feel free to drop me a mail if you have questions about this topic
that you think are not appropriate for the wider audience on the
mailing list.


More information about the systemd-devel mailing list