diff options
author | Andrew Cady <d@jerkface.net> | 2018-06-16 02:15:00 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2018-06-16 02:15:00 -0400 |
commit | 4c73ae45859d784e8123f372068ac96e635d841f (patch) | |
tree | 5d9dc8e467d1fd56824020320348cd3517318f3a | |
parent | 1735f15a8c61400d92e46b9a2472ba8070c81107 (diff) |
Move unknown mountpoints before booting
If there are mountpoints outside of /root, which `run-init` does not
have in its whitelist, then `run-init` will refuse to boot and will
crash the kernel instead (process 1 will exit).
-rw-r--r-- | src/initrd/btrfs-create.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh index 567ad97..f47dfaf 100644 --- a/src/initrd/btrfs-create.sh +++ b/src/initrd/btrfs-create.sh | |||
@@ -71,6 +71,19 @@ init_samizdat() | |||
71 | initialize_root_filesystem || return | 71 | initialize_root_filesystem || return |
72 | } | 72 | } |
73 | 73 | ||
74 | movemounts() | ||
75 | { | ||
76 | # Move mounted filesystems to the future root filesystem | ||
77 | while read dev mp rest; do | ||
78 | case "$mp" in | ||
79 | /root/*|/root|/|/proc|/dev|/dev/pts|/sys|/run) continue ;; | ||
80 | *) target=/root/$mp ;; | ||
81 | esac | ||
82 | mkdir -p "$target" | ||
83 | mount -n -o move "$mp" "$target" | ||
84 | done </proc/mounts | ||
85 | } | ||
86 | |||
74 | samizdat_movemounts() | 87 | samizdat_movemounts() |
75 | { | 88 | { |
76 | local imgfile="$1" mountpoint | 89 | local imgfile="$1" mountpoint |
@@ -83,6 +96,7 @@ samizdat_movemounts() | |||
83 | mkdir /root/cdrom | 96 | mkdir /root/cdrom |
84 | mount -o move /cdrom /root/cdrom | 97 | mount -o move /cdrom /root/cdrom |
85 | umount /plaintext | 98 | umount /plaintext |
99 | movemounts | ||
86 | true | 100 | true |
87 | } | 101 | } |
88 | 102 | ||