diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:54:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 13:54:25 +0000 |
commit | 9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a (patch) | |
tree | 2efb72864cc69e174c9c5ee33efb88a5f1553b48 /modules.d/90overlayfs | |
parent | Initial commit. (diff) | |
download | dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.tar.xz dracut-9cb1c4df7b9ce1a9ad1312621b0f2b16a94fba3a.zip |
Adding upstream version 060+5.upstream/060+5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | modules.d/90overlayfs/module-setup.sh | 19 | ||||
-rwxr-xr-x | modules.d/90overlayfs/mount-overlayfs.sh | 20 | ||||
-rwxr-xr-x | modules.d/90overlayfs/prepare-overlayfs.sh | 21 |
3 files changed, 60 insertions, 0 deletions
diff --git a/modules.d/90overlayfs/module-setup.sh b/modules.d/90overlayfs/module-setup.sh new file mode 100755 index 0000000..893e2dc --- /dev/null +++ b/modules.d/90overlayfs/module-setup.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +check() { + [[ $hostonly ]] && return 1 + return 255 +} + +depends() { + echo base +} + +installkernel() { + instmods overlay +} + +install() { + inst_hook mount 01 "$moddir/mount-overlayfs.sh" + inst_hook pre-mount 01 "$moddir/prepare-overlayfs.sh" +} diff --git a/modules.d/90overlayfs/mount-overlayfs.sh b/modules.d/90overlayfs/mount-overlayfs.sh new file mode 100755 index 0000000..e1d23fb --- /dev/null +++ b/modules.d/90overlayfs/mount-overlayfs.sh @@ -0,0 +1,20 @@ +#!/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.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay="" + +ROOTFLAGS="$(getarg rootflags)" + +if [ -n "$overlayfs" ]; then + if [ -n "$readonly_overlay" ] && [ -h /run/overlayfs-r ]; then + ovlfs=lowerdir=/run/overlayfs-r:/run/rootfsbase + else + ovlfs=lowerdir=/run/rootfsbase + fi + + if ! strstr "$(cat /proc/mounts)" LiveOS_rootfs; then + mount -t overlay LiveOS_rootfs -o "$ROOTFLAGS,$ovlfs",upperdir=/run/overlayfs,workdir=/run/ovlwork "$NEWROOT" + fi +fi diff --git a/modules.d/90overlayfs/prepare-overlayfs.sh b/modules.d/90overlayfs/prepare-overlayfs.sh new file mode 100755 index 0000000..87bcc19 --- /dev/null +++ b/modules.d/90overlayfs/prepare-overlayfs.sh @@ -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 |