patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Demi Marie Obenour <demiobenour@gmail.com>
To: Spectrum OS Development <devel@spectrum-os.org>
Cc: Demi Marie Obenour <demiobenour@gmail.com>, Alyssa Ross <hi@alyssa.is>
Subject: [PATCH 1/3] host/initramfs: Use util-linux switch_root
Date: Sun, 14 Sep 2025 20:18:58 -0400	[thread overview]
Message-ID: <20250914-util-linux-switch-root-v1-1-9cf9349cbca3@gmail.com> (raw)
In-Reply-To: <20250914-util-linux-switch-root-v1-0-9cf9349cbca3@gmail.com>

Busybox switch_root doesn't move /proc, /dev, and /sys mounts, whereas
the switch_root from util-linux does.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
 host/initramfs/default.nix | 3 ++-
 host/initramfs/etc/init    | 4 ----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix
index 1123feacc7533abaf079d84b04a269f784eb43b5..28378da220bb61a51e58b8b25846097f08746f5f 100644
--- a/host/initramfs/default.nix
+++ b/host/initramfs/default.nix
@@ -43,6 +43,7 @@ let
         CONFIG_MODINFO n
         CONFIG_MODPROBE n
         CONFIG_RMMOD n
+        CONFIG_SWITCH_ROOT n
       '';
     })
   ];
@@ -56,7 +57,7 @@ let
     # TODO: this is a hack and we should just build the util-linux
     # programs we want.
     # https://lore.kernel.org/util-linux/87zgrl6ufb.fsf@alyssa.is/
-    cp ${util-linuxMinimal}/bin/{findfs,lsblk} $out/bin
+    cp ${util-linuxMinimal}/bin/{findfs,lsblk,switch_root} $out/bin
   '';
 
   microcode = runCommand "microcode.cpio" {
diff --git a/host/initramfs/etc/init b/host/initramfs/etc/init
index 719488741b6d31564c2c17c0e41f15d16b1c0a08..b3c5b7fbcf45e9646cf0404bc44dac58aa2dfe24 100755
--- a/host/initramfs/etc/init
+++ b/host/initramfs/etc/init
@@ -45,9 +45,5 @@ background { rm /dev/rootfs /dev/verity }
 if { mount /dev/mapper/root-verity /mnt/root }
 wait { $mdevd_pid }
 
-if { mount --move /proc /mnt/root/proc }
-if { mount --move /sys /mnt/root/sys }
-if { mount --move /dev /mnt/root/dev }
-
 switch_root /mnt/root
 /etc/init

-- 
2.51.0


  reply	other threads:[~2025-09-15  0:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15  0:18 [PATCH 0/3] Minor improvements to the Spectrum OS boot process Demi Marie Obenour
2025-09-15  0:18 ` Demi Marie Obenour [this message]
2025-09-17 11:44   ` [PATCH 1/3] host/initramfs: Use util-linux switch_root Alyssa Ross
2025-09-18  2:39     ` Demi Marie Obenour
2025-09-19  9:12       ` Alyssa Ross
2025-09-18 19:41     ` Demi Marie Obenour
2025-09-15  0:18 ` [PATCH 2/3] Add /dev/fd and /dev/std* Demi Marie Obenour
2025-09-17 11:29   ` Alyssa Ross
2025-09-15  0:19 ` [PATCH 3/3] host/rootfs: Avoid redundant mounts of /proc and /sys Demi Marie Obenour
2025-09-17 11:31   ` Alyssa Ross
2025-09-18  2:42     ` Demi Marie Obenour
2025-09-19  9:16       ` Alyssa Ross
2025-09-18 19:45 ` [PATCH v2] Add /dev/fd and /dev/std* Demi Marie Obenour
2025-09-19  9:29   ` Alyssa Ross

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=20250914-util-linux-switch-root-v1-1-9cf9349cbca3@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    --cc=hi@alyssa.is \
    /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.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).