Skip to content

Commit

Permalink
fix(overlayfs): split overlayfs mount in two steps (bsc#1219778)
Browse files Browse the repository at this point in the history
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 <dcassany@suse.com>
(cherry picked from commit bddffed)
  • Loading branch information
davidcassany authored and aafeijoo-suse committed Feb 9, 2024
1 parent c5d6b38 commit 0c23141
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions modules.d/90overlayfs/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ installkernel() {

install() {
inst_hook mount 01 "$moddir/mount-overlayfs.sh"
inst_hook pre-mount 01 "$moddir/prepare-overlayfs.sh"
}
13 changes: 0 additions & 13 deletions modules.d/90overlayfs/mount-overlayfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,11 @@
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh

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

ROOTFLAGS="$(getarg rootflags)"

if [ -n "$overlayfs" ]; then
if ! [ -e /run/rootfsbase ]; then
mkdir -m 0755 -p /run/rootfsbase
mount --bind "$NEWROOT" /run/rootfsbase
fi

mkdir -m 0755 -p /run/overlayfs
mkdir -m 0755 -p /run/ovlwork
if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
ovlfsdir=$(readlink /run/overlayfs)
info "Resetting the OverlayFS overlay directory."
rm -r -- "${ovlfsdir:?}"/* "${ovlfsdir:?}"/.* > /dev/null 2>&1
fi
if [ -n "$readonly_overlay" ] && [ -h /run/overlayfs-r ]; then
ovlfs=lowerdir=/run/overlayfs-r:/run/rootfsbase
else
Expand Down
21 changes: 21 additions & 0 deletions modules.d/90overlayfs/prepare-overlayfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh

getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes"
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"

if [ -n "$overlayfs" ]; then
if ! [ -e /run/rootfsbase ]; then
mkdir -m 0755 -p /run/rootfsbase
mount --bind "$NEWROOT" /run/rootfsbase
fi

mkdir -m 0755 -p /run/overlayfs
mkdir -m 0755 -p /run/ovlwork
if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
ovlfsdir=$(readlink /run/overlayfs)
info "Resetting the OverlayFS overlay directory."
rm -r -- "${ovlfsdir:?}"/* "${ovlfsdir:?}"/.* > /dev/null 2>&1
fi
fi

0 comments on commit 0c23141

Please sign in to comment.