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 mount.usrflags=subvol=usr:mine:x86_64:1,compress=lzo,ro 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. TODO: * 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, Tobias
From 5fcc8322e9cee1f76454bcdf5538640606691356 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <[email protected]> Date: Sun, 22 Mar 2015 01:10:40 +0100 Subject: [PATCH] fstab-generator: Support root on tmpfs This allows for stateless systems. --- src/fstab-generator/fstab-generator.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index ccc7c6e..6b9719b 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -145,6 +145,10 @@ static bool mount_in_initrd(struct mntent *me) { streq(me->mnt_dir, "/usr"); } +static bool type_is_tmpfs(char *type) { + return !isempty(type) && streq(type, "tmpfs"); +} + static int add_mount( const char *what, const char *where, @@ -388,13 +392,19 @@ static int add_root_mount(void) { _cleanup_free_ char *what = NULL; const char *opts; + if (type_is_tmpfs(arg_root_fstype)) { + /* normalize what to mount to tmpfs */ + if (free_and_strdup(&arg_root_what, "tmpfs") < 0) + return log_oom(); + } + if (isempty(arg_root_what)) { log_debug("Could not find a root= entry on the kernel command line."); return 0; } what = fstab_node_to_udev_node(arg_root_what); - if (!path_is_absolute(what)) { + if (!path_is_absolute(what) && !type_is_tmpfs(what)) { log_debug("Skipping entry what=%s where=/sysroot type=%s", what, strna(arg_root_fstype)); return 0; } -- 2.3.3
_______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
