[systemd-devel] [PATCH] fstab-generator: Support root on tmpfs

Tobias Hunger tobias.hunger at gmail.com
Sat Mar 21 16:57:23 PDT 2015

Hello everybody, Hi Harald and Zbyszek,

I hope you two do not mind me sending directly to you, but you seem to
be generally interested in the area I am touching here:-)

I am currently experimenting with a stateless system on real hardware.
I am using arch here, with systemd in the initrd, but this patch
should be applicable to other systemd-in-initrd based systems on other
distros as well.

The idea is to have a tmpfs on / and then to mount /usr from a btrfs
snapshot as Lennart suggested. To do that I am currently passing the
following command line to the kernel via gummiboot:

rootfstype=tmpfs root=tmpfs mount.usrfstype=btrfs mount.usr=/dev/sdaX

Unfortunately that fails in systemd 219.

fstab-generator examines the kernel command line and tries to generate
units for /sysroot (the place that will later be the "real" root) and
/sysroot/usr. Since the root flag in the command line is not a device
it will skip creating sysroot.mount, even though it does happily
proceed to create sysroot-usr.mount for me.

So this has me end up with a *directory* "/sysroot" (nothing mounted
here) which has another subdir "usr" in it. /sysroot/usr has the usr
snapshot mounted as expected.

Such a setup does blow up rather nicely when systemd then tries to
switch root to /sysroot :-)

So the attached patch makes fstab-generator able to handle tmpfs for
root. I left out similar code for mount.usr*, simply because I do not
see where that could possibly make sense.


* Rebase to latest master branch. I am a bit behind and was not able
to update all day
   long today. Sending now anyway, mostly to find out whether the
general approach
   seems sensible.

* I get a warning during boot with this setup: tmpfs is apparently not
a device that
   something is able to fsck. I still need to figure out how to fix
this warning (any
   ideas?), but that seems mostly harmless.

* The system does not boot after initrd-switch-root. Not sure why, but
it seems there
   are some services that get started before /etc is populated. I will
need to tweak
   that a bit, but that is stuff for other patches:-) Alternatively I
might just want to populate
   /sysroot/etc right inside the initrd after /sysroot/usr is mounted.

Best Regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fstab-generator-Support-root-on-tmpfs.patch
Type: text/x-patch
Size: 1719 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150322/cf435795/attachment.bin>

More information about the systemd-devel mailing list