diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-11-10 03:34:34 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-11-10 03:34:34 +0900 |
| commit | 4bfb952d92859ecbee1e2d2c16cabff9deba16a2 (patch) | |
| tree | 2188fedf0820aa1b20da9555f821e80e3294d7f6 /cmd/earlyinit | |
| parent | 4d08ed505bcc90760833d28b1a0e40850fcdcd63 (diff) | |
cmd/earlyinit: work around pivot_root limitation
The rootfs (initial ramfs) cannot be pivot_root()ed. This change works
around that limitation by making / a bind mount of the rootfs.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/earlyinit')
| -rw-r--r-- | cmd/earlyinit/main.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/earlyinit/main.go b/cmd/earlyinit/main.go index 2f1eebef..42a8a9ca 100644 --- a/cmd/earlyinit/main.go +++ b/cmd/earlyinit/main.go @@ -153,6 +153,24 @@ func main() { msg := message.New(log.Default()) msg.SwapVerbose(slices.Contains(flags, flagVerbose)) + mustSyscall("bind root", Mount( + "/", + "/dev", + "", + MS_BIND|MS_REC, + "", + )) + must(os.Chdir("/dev")) + mustSyscall("move root", Mount( + "/dev", + "/", + "", + MS_MOVE, + "", + )) + mustSyscall("change root", Chroot(".")) + must(os.Chdir("/")) + mustSyscall("mount devtmpfs", Mount( "devtmpfs", "/dev/", |
