-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11-umount-image.bash
More file actions
executable file
·50 lines (39 loc) · 1.25 KB
/
11-umount-image.bash
File metadata and controls
executable file
·50 lines (39 loc) · 1.25 KB
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
#!/bin/bash
#
# Unmounts an existing KVM Image
#
# Note: This script uses 'sudo'.
#
#
if [ -z UB_CONFIGURED ]; then
lerror "Please execute 'guest.bash' to configure the environment first."
false || die "UBE000"
fi
# Initialise some helpers
. ${UB_HOME}/functions.bash
(cd ${UB_HOME}
(cd ${U_RELEASE}-${U_ARCH}-bootstrap
linfo "Unmounting the image."
sync
# There could be errors but when things are messed it is best try
# and unwind everything and check the final mount status.
echo "Errors encountered during unmount process will be displayed here:" > ERRORS.txt
linfo "Unmount vm /dev"
sudo umount ${VM_ROOT}/dev 2>> ERRORS.txt
linfo "Unmount vm /proc"
sudo umount ${VM_ROOT}/proc 2>> ERRORS.txt
linfo "Unmount vm /mnt/mirror"
sudo umount ${VM_ROOT}/mnt/mirror 2>> ERRORS.txt
linfo "Unmount vm /boot"
sudo umount /dev/mapper/loop5p1 2>> ERRORS.txt
linfo "Unmount vm /"
sync
sudo umount /dev/mapper/loop5p2 2>> ERRORS.txt
linfo "Release the loop."
sudo kpartx -d /dev/loop5 2>> ERRORS.txt
sudo losetup -d /dev/loop5 2>> ERRORS.txt
linfo "Checking for mount points containing: ${VM_ROOT}"
cat ERRORS.txt
mount -l | grep ${VM_ROOT} && die "UBE028"
linfo "Unmounted."
))