-
Notifications
You must be signed in to change notification settings - Fork 0
/
mount.sh
38 lines (28 loc) · 1018 Bytes
/
mount.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
#!/usr/bin/env sh
DISK_IMAGE=disk-rk1.img
MOUNT_POINT=./mnt
DEVICE=$(losetup -f)
losetup "${DEVICE}" "${DISK_IMAGE}"
BOOT=$(fdisk -l "${DEVICE}" | grep "${DEVICE}" | sed -n 2p | awk '{print $1}')
VOLUME=$(fdisk -l "${DEVICE}" | grep "${DEVICE}" | sed -n 3p | awk '{print $1}')
echo "BOOT: ${BOOT}"
echo "VOLUME: ${VOLUME}"
partprobe "${DEVICE}"
lvscan
lvchange -ay /dev/mapper/rk1-root
lvchange -ay /dev/mapper/rk1-var
lvchange -ay /dev/mapper/rk1-tmp
lvchange -ay /dev/mapper/rk1-home
mount /dev/mapper/rk1-root "${MOUNT_POINT}"
mkdir -p "${MOUNT_POINT}/tmp"
mkdir -p "${MOUNT_POINT}/var"
mkdir -p "${MOUNT_POINT}/home"
mkdir -p "${MOUNT_POINT}/boot"
mount "${BOOT}" "${MOUNT_POINT}/boot/boot"
mount /dev/mapper/rk1-tmp "${MOUNT_POINT}/tmp"
mount /dev/mapper/rk1-var "${MOUNT_POINT}/var"
mount /dev/mapper/rk1-home "${MOUNT_POINT}/home"
mount --bind /dev "${MOUNT_POINT}/dev"
mount --bind /dev/pts "${MOUNT_POINT}/dev/pts"
mount /proc "${MOUNT_POINT}/proc" -t proc
mount --bind /sys "${MOUNT_POINT}/sys"