-
Notifications
You must be signed in to change notification settings - Fork 0
/
mount_newroot.sh
54 lines (44 loc) · 1.32 KB
/
mount_newroot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh -eu
for SRC in /root/bin/luks_NEW*.inc ; do [ ! -s "${SRC}" ] || . "${SRC}" ; done
if [ -z "${NEWROOT:-}" ]; then
echo 'ERROR: var NEWROOT not set'
return 1 2>/dev/null || exit 1
fi
. /root/bin/luks_debian.inc
for SRC in /root/bin/luks_func*.inc ; do . "${SRC}" ; done
MOUNTBASE='/mnt/newroot'
[ -d "${MOUNTBASE}" ] || mkdir "${MOUNTBASE}"
start_fs_subdevs NEWROOT
grep -q -F -e "${MOUNTBASE} " /proc/mounts || {
echo "Mounting ${NEWROOTMOUNT} on ${MOUNTBASE}"
while mount "${NEWROOTMOUNT}" "${MOUNTBASE}" 2>/dev/null
do
:
done
}
if [ -d "${MOUNTBASE}/boot" ]; then
if [ "${1:-}" != 'noboot' ]; then
grep -q -F -e "${MOUNTBASE}/boot " /proc/mounts || {
echo "Mounting ${NEWBOOTMOUNT} on ${MOUNTBASE}/boot"
while mount "${NEWBOOTMOUNT}" "${MOUNTBASE}/boot" 2>/dev/null
do
:
done
}
grep -q -F -e "${MOUNTBASE}/boot " /proc/mounts || {
echo "Mounting ${NEWBOOTMOUNT} on ${MOUNTBASE}/boot via bind of /boot"
mount --bind /boot "${MOUNTBASE}/boot"
}
else
grep -q -F -e "${MOUNTBASE}/boot " /proc/mounts && {
echo "Unmounting ${MOUNTBASE}/boot"
while umount "${MOUNTBASE}/boot" 2>/dev/null
do
:
done
}
fi
fi
mount_sys.sh "${MOUNTBASE}"
echo "${MOUNTBASE} is set up as following..."
mount | grep -F -e "${MOUNTBASE}"