-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmount_oldroot.sh
46 lines (36 loc) · 1.13 KB
/
mount_oldroot.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
#!/bin/sh -eu
for SRC in /root/bin/luks_OLD*.inc ; do [ ! -s "${SRC}" ] || . "${SRC}" ; done
if [ -z "${OLDROOT:-}" ]; then
echo 'ERROR: var OLDROOT 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/oldroot'
[ -d "${MOUNTBASE}" ] || mkdir "${MOUNTBASE}"
start_fs_subdevs OLDROOT
grep -q -F -e "${MOUNTBASE} " /proc/mounts || {
echo "Mounting ${OLDROOTMOUNT} on ${MOUNTBASE}"
while mount "${OLDROOTMOUNT}" "${MOUNTBASE}" 2>/dev/null
do
:
done
}
if [ "${1:-}" = 'all' ]; then
if [ -n "${OLDBOOT:-}" ]; then
grep -q -F -e "${MOUNTBASE}/boot " /proc/mounts || {
echo "Mounting ${OLDBOOTMOUNT} on ${MOUNTBASE}/boot"
while mount "${OLDBOOTMOUNT}" "${MOUNTBASE}/boot" 2>/dev/null
do
:
done
}
grep -q -F -e "${MOUNTBASE}/boot " /proc/mounts || {
echo "Mounting ${OLDBOOTMOUNT} on ${MOUNTBASE}/boot via bind of /boot"
mount --bind /boot "${MOUNTBASE}/boot"
}
fi
mount_sys.sh "${MOUNTBASE}"
fi
echo "${MOUNTBASE} is set up as following..."
mount | grep -F -e "${MOUNTBASE}"