From: Ismael Luceno <ismael@iodev.co.uk>
To: linux-kernel@vger.kernel.org
Cc: Ismael Luceno <ismael@iodev.co.uk>,
Ismael Luceno <iluceno@suse.de>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and
infrastructure))
Subject: [PATCH 2/8] init: mount devtmpfs before the root filesystem
Date: Mon, 16 Nov 2026 23:43:18 +0100 [thread overview]
Message-ID: <20261116224316.11237-12-ismael@iodev.co.uk> (raw)
In-Reply-To: <20261116224316.11237-10-ismael@iodev.co.uk>
devtmpfs is mounted after the root filesystem, which leaves the root
mount with no /dev nodes to look devices up by. A filesystem that has
to open block devices other than the one it was given has nothing to
open them by, and without an initrd there is no userspace around to
create the nodes either.
Mount it on the initial root before the root filesystem is mounted, so
the root filesystem can resolve device paths. This is what lets a
multi-device btrfs root assemble itself with no initrd to run the
device scanner.
This mount is on the initial root and goes away with it at the pivot,
so the existing mount after mount_root() is kept: that is the one that
ends up in the new root.
This is only needed by the btrfs root device scan, so it is done only when
CONFIG_BTRFS_ROOT_SCAN is set; without it boot is unchanged.
Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
Signed-off-by: Ismael Luceno <iluceno@suse.de>
---
init/do_mounts.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/init/do_mounts.c b/init/do_mounts.c
index b088021b1546..febcc37f9128 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -480,6 +480,20 @@ #define CIFSROOT_RETRY_MAX 5
if (root_wait)
wait_for_root(saved_root_name);
+
+ /*
+ * Mount devtmpfs before the root filesystem, so that the filesystem
+ * mounting it can look devices up by path. A multi-device btrfs root
+ * needs this: it has to open its other devices to assemble the
+ * filesystem, and there is no userspace around to create the nodes.
+ *
+ * This one is on the initial root and goes away with it below; the
+ * mount after mount_root() is the one that sticks around. Only the
+ * btrfs root device scan needs it.
+ */
+ if (IS_ENABLED(CONFIG_BTRFS_ROOT_SCAN))
+ devtmpfs_mount();
+
mount_root(saved_root_name);
devtmpfs_mount();
next prev parent reply other threads:[~2026-11-16 22:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 22:43 [PATCH 0/8] btrfs: assemble a multi-device root filesystem without an initrd Ismael Luceno
2026-11-16 22:43 ` [PATCH 1/8] btrfs: add config options for the root device scan Ismael Luceno
2026-11-16 22:43 ` Ismael Luceno [this message]
2026-11-16 22:43 ` [PATCH 3/8] init: let filesystems ask whether they are mounting the root device Ismael Luceno
2026-11-17 7:41 ` kernel test robot
2026-11-16 22:43 ` [PATCH 4/8] btrfs: add a helper to scan all block devices Ismael Luceno
2026-11-17 13:10 ` kernel test robot
2026-11-16 22:43 ` [PATCH 5/8] btrfs: wait for the root filesystem to have all its devices Ismael Luceno
2026-11-18 1:19 ` kernel test robot
2026-11-16 22:43 ` [PATCH 6/8] Documentation: btrfs: document waiting for the root filesystem devices Ismael Luceno
2026-11-16 22:43 ` [PATCH 7/8] init: let a filesystem resolve a root device by UUID or label Ismael Luceno
2026-11-16 22:43 ` [PATCH 8/8] btrfs: resolve root=UUID= and root=LABEL= Ismael Luceno
2026-11-16 23:41 ` [PATCH 0/8] btrfs: assemble a multi-device root filesystem without an initrd Qu Wenruo
2026-11-17 17:36 ` Ismael Luceno
2026-11-17 20:00 ` Qu Wenruo
2026-11-18 12:07 ` Ismael Luceno
2026-11-18 20:33 ` Qu Wenruo
2026-11-20 12:13 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116224316.11237-12-ismael@iodev.co.uk \
--to=ismael@iodev.co.uk \
--cc=brauner@kernel.org \
--cc=iluceno@suse.de \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®