-
Notifications
You must be signed in to change notification settings - Fork 7
/
mount_overlay_squash
executable file
·76 lines (55 loc) · 1.22 KB
/
mount_overlay_squash
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
## hyphop ##
. ./,config
grep squashfs /proc/filesystems 1>/dev/null || modprobe squashfs
grep squashfs /proc/filesystems 1>/dev/null || {
echo "[e] not have squashfs"
exit 1
}
ovlmod=""
for v in overlayfs overlay aufs; do
[ -d /sys/module/$v ] || {
modprobe $v 2>/dev/null
}
[ -d /sys/module/$v ] && {
ovlmod=$v
break
}
done
#override mode
#ovlmod=aufs
echo "[i] used $ovlmod" >&2
p=$PWD
p=.
[ -d $src ] || mkdir $src
#sfs=$src.squashfs
sfs=$squash_src
ro_level=$p/$src.ro
rw_level=$p/$src.rw
[ -d $ro_level ] || mkdir $ro_level
[ -d $rw_level ] || mkdir $rw_level
work_dir=$p/$src
mount -o ro $sfs $ro_level
case $ovlmod in
overlay)
mount -t overlay overlay -o lowerdir=$ro_level,upperdir=$rw_level,workdir=$work_dir \
$work_dir
break
;;
overlayfs)
mount -t overlayfs -o lowerdir=$ro_level,upperdir=$rw_level \
none $work_dir
break
;;
aufs)
mount -t aufs -o br:$rw_level:$ro_level \
none $work_dir
break
;;
esac
grep $work_dir /proc/mounts | grep $ovlmod 1>/dev/null || {
echo "[e] working dir "$work_dir" not mounted as overlay"
exit 1
}
echo "[i] working dir $work_dir mounted as overlay RO: $ro_level RW: $rw_level"
## OK