Skip to content

Commit bddffed

Browse files
davidcassanyLaszloGombos
authored andcommitted
fix(overlayfs): split overlayfs mount in two steps
This commit splits the creation of required overlayfs underlaying directories and the actual overlayfs mount. This way it is still possible to mount the overlayfs with the generated sysroot.mount that dmsquash-live creates. The overlayfs tree is created in a pre-mount hook so it is executed before sysroot.mount is started. Otherwise sysroot.mount starts and fails before mount hooks are executed. Signed-off-by: David Cassany <[email protected]>
1 parent 1c762c0 commit bddffed

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

modules.d/90overlayfs/module-setup.sh

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ installkernel() {
1515

1616
install() {
1717
inst_hook mount 01 "$moddir/mount-overlayfs.sh"
18+
inst_hook pre-mount 01 "$moddir/prepare-overlayfs.sh"
1819
}

modules.d/90overlayfs/mount-overlayfs.sh

-13
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,11 @@
33
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
44

55
getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes"
6-
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
76
getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
87

98
ROOTFLAGS="$(getarg rootflags)"
109

1110
if [ -n "$overlayfs" ]; then
12-
if ! [ -e /run/rootfsbase ]; then
13-
mkdir -m 0755 -p /run/rootfsbase
14-
mount --bind "$NEWROOT" /run/rootfsbase
15-
fi
16-
17-
mkdir -m 0755 -p /run/overlayfs
18-
mkdir -m 0755 -p /run/ovlwork
19-
if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
20-
ovlfsdir=$(readlink /run/overlayfs)
21-
info "Resetting the OverlayFS overlay directory."
22-
rm -r -- "${ovlfsdir:?}"/* "${ovlfsdir:?}"/.* > /dev/null 2>&1
23-
fi
2411
if [ -n "$readonly_overlay" ] && [ -h /run/overlayfs-r ]; then
2512
ovlfs=lowerdir=/run/overlayfs-r:/run/rootfsbase
2613
else
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
4+
5+
getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes"
6+
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
7+
8+
if [ -n "$overlayfs" ]; then
9+
if ! [ -e /run/rootfsbase ]; then
10+
mkdir -m 0755 -p /run/rootfsbase
11+
mount --bind "$NEWROOT" /run/rootfsbase
12+
fi
13+
14+
mkdir -m 0755 -p /run/overlayfs
15+
mkdir -m 0755 -p /run/ovlwork
16+
if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
17+
ovlfsdir=$(readlink /run/overlayfs)
18+
info "Resetting the OverlayFS overlay directory."
19+
rm -r -- "${ovlfsdir:?}"/* "${ovlfsdir:?}"/.* > /dev/null 2>&1
20+
fi
21+
fi

0 commit comments

Comments
 (0)