From 1e9b2e4fdd8d04e3fbfadbc0b92dc138c819c221 Mon Sep 17 00:00:00 2001 From: Michal Sekletar Date: Wed, 25 Oct 2023 13:17:18 +0200 Subject: [PATCH] fstab-generator: drop nofail and noauto options for critical mounts Setting nofail for /usr mount doesn't make sense because without /usr we can't really boot. However, having the flag set might cause races in initrd where we could try to switchroot into rootfs before /usr is actually mounted. Let's just ignore it so that we always have proper mount unit ordering for /sysroot/usr mount. --- src/fstab-generator/fstab-generator.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 5a5c05df0c2..7617f2b2a5f 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -853,7 +853,7 @@ static int parse_fstab_one( bool accept_root, /* This takes an effect only when prefix_sysroot is true. */ bool use_swap_enabled) { - _cleanup_free_ char *what = NULL, *where = NULL; + _cleanup_free_ char *what = NULL, *where = NULL, *opts = NULL; MountPointFlags flags; bool is_swap, where_changed; int r; @@ -936,6 +936,17 @@ static int parse_fstab_one( mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET : SPECIAL_LOCAL_FS_TARGET; + /* nofail or noauto don't make sense for critical filesystems we must mount in initrd. */ + if ((is_sysroot || is_sysroot_usr) && ((flags & (MOUNT_NOFAIL|MOUNT_NOAUTO)) != 0)) { + flags &= ~(MOUNT_NOFAIL|MOUNT_NOAUTO); + r = fstab_filter_options(options, "noauto\0nofail\0", NULL, NULL, NULL, &opts); + if (r < 0) + return r; + + log_debug("'noauto' and 'nofail' options are ignored for /sysroot/ and /sysroot/usr/ mounts."); + options = opts; + } + r = add_mount(source, arg_dest, what,