From 4629dc3d468adcd6737cb29443cefcd87ba15971 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 26 Oct 2025 15:54:25 +0100 Subject: init: detect already mounted /dev file systems There's no point trying to remount /dev with devtmpfs if it's already a devtmpfs. Similarly, there's no point remounting it with tmpfs if it's already a ramfs or tmpfs, since the only purpose will be to make it R/W in order to create missing entries in it. --- init/init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init/init.c b/init/init.c index fb1e820..587dc13 100644 --- a/init/init.c +++ b/init/init.c @@ -2402,8 +2402,12 @@ int main(int argc, char **argv, char **envp) * we don't test the presence of /dev/console. */ if (linuxrc || !is_dev_populated()) { + char *type = get_dev_type(); // FS type of /dev + debug("init/info: /dev/console not found, rebuilding /dev.\n"); - if (mount("/dev", "/dev", "devtmpfs", MS_MGC_VAL, "size=4k,nr_inodes=4096,mode=755") == -1 && + if ((!type || !streq(type, "devtmpfs")) && + mount("/dev", "/dev", "devtmpfs", MS_MGC_VAL, "size=4k,nr_inodes=4096,mode=755") == -1 && + (!type || !streq(type, "tmpfs")) && (!type || !streq(type, "ramfs")) && mount("/dev", "/dev", "tmpfs", MS_MGC_VAL, "size=4k,nr_inodes=4096,mode=755") == -1) { debug("init/err: cannot mount /dev.\n"); } -- 2.17.5