]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
feat(overlayfs): add a new module called overlayfs
authorLaszlo Gombos <laszlo.gombos@gmail.com>
Wed, 19 Oct 2022 21:50:08 +0000 (21:50 +0000)
committerAntonio Álvarez Feijoo <antonio.feijoo@suse.com>
Mon, 7 Nov 2022 14:51:45 +0000 (15:51 +0100)
Also split ovlfs variable with two different meaning.

.github/labeler.yml
modules.d/90dmsquash-live/dmsquash-live-genrules.sh
modules.d/90dmsquash-live/dmsquash-live-root.sh
modules.d/90dmsquash-live/module-setup.sh
modules.d/90overlayfs/module-setup.sh [new file with mode: 0755]
modules.d/90overlayfs/mount-overlayfs.sh [moved from modules.d/90dmsquash-live/mount-overlayfs.sh with 88% similarity]
test/TEST-16-DMSQUASH/test.sh
test/TEST-20-NFS/test.sh

index 1c787a58883d5de8de360a9e788ea21b7dcfc5c4..fe69b8093f073ecdbbda91a91b66c15371eabf7c 100644 (file)
@@ -141,6 +141,9 @@ multipath:
 nvdimm:
   - modules.d/90nvdimm/*
 
+overlayfs:
+  - modules.d/90overlayfs/*
+
 ppcmac:
   - modules.d/90ppcmac/*
 
index afd9924f9d2c8927a67a750711fb4a2eba92d1d2..8c7cad8fe86433891f2b9fcda469e825e4011135 100755 (executable)
@@ -15,7 +15,4 @@ case "$root" in
             /sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "${root#live:}"
         fi
         ;;
-    nfs*)
-        cp /sbin/mount-overlayfs "$hookdir/mount/99-mount-overlayfs.sh"
-        ;;
 esac
index 9ace8f7057e1f67f63598d8a700db32cd894748c..17dfbc7331aac49b44578b7677516286a159e1e5 100755 (executable)
@@ -425,9 +425,6 @@ if [ -n "$overlayfs" ]; then
     else
         ln -sf /run/initramfs/live /run/rootfsbase
     fi
-    if [ -z "$DRACUT_SYSTEMD" ]; then
-        ln -sf /sbin/mount-overlayfs "$hookdir"/mount/01-$$-live.sh
-    fi
 else
     if [ -z "$DRACUT_SYSTEMD" ]; then
         [ -n "$ROOTFLAGS" ] && ROOTFLAGS="-o $ROOTFLAGS"
index 98c2afcf1a687667e7e10c3630837250c1524867..b905e3dde0d3a3b9b0903515bfe0974566c426f9 100755 (executable)
@@ -11,13 +11,13 @@ check() {
 depends() {
     # if dmsetup is not installed, then we cannot support fedora/red hat
     # style live images
-    echo dm rootfs-block img-lib
+    echo dm rootfs-block img-lib overlayfs
     return 0
 }
 
 # called by dracut
 installkernel() {
-    instmods squashfs loop iso9660 overlay
+    instmods squashfs loop iso9660
 }
 
 # called by dracut
@@ -31,7 +31,6 @@ install() {
     inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
     inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
     inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan"
-    inst_script "$moddir/mount-overlayfs.sh" "/sbin/mount-overlayfs"
     if dracut_module_included "systemd-initrd"; then
         inst_script "$moddir/dmsquash-generator.sh" "$systemdutildir"/system-generators/dracut-dmsquash-generator
         inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service"
diff --git a/modules.d/90overlayfs/module-setup.sh b/modules.d/90overlayfs/module-setup.sh
new file mode 100755 (executable)
index 0000000..27aa7cf
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+check() {
+    [[ $hostonly ]] && return 1
+    return 255
+}
+
+depends() {
+    echo base
+}
+
+installkernel() {
+    instmods overlay
+}
+
+install() {
+    inst_hook mount 01 "$moddir/mount-overlayfs.sh"
+}
similarity index 88%
rename from modules.d/90dmsquash-live/mount-overlayfs.sh
rename to modules.d/90overlayfs/mount-overlayfs.sh
index fb27656699a8a16a07cb0173f802a5f1962eca63..7e2da1a804e673f9eca80e446e850af4114a9794 100755 (executable)
@@ -2,8 +2,6 @@
 
 type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
 
-PATH=/usr/sbin:/usr/bin:/sbin:/bin
-
 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=""
@@ -19,9 +17,9 @@ if [ -n "$overlayfs" ]; then
     mkdir -m 0755 -p /run/overlayfs
     mkdir -m 0755 -p /run/ovlwork
     if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
-        ovlfs=$(readlink /run/overlayfs)
+        ovlfsdir=$(readlink /run/overlayfs)
         info "Resetting the OverlayFS overlay directory."
-        rm -r -- "${ovlfs:?}"/* "${ovlfs:?}"/.* > /dev/null 2>&1
+        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
index 3e88859bae6b0725dd4f601962df6d7b2a7f9270..33ef5aaf9a825e85e440344a496012c213cc0cf6 100755 (executable)
@@ -17,6 +17,12 @@ test_run() {
     qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
     qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
 
+    "$testdir"/run-qemu \
+        "${disk_args[@]}" \
+        -boot order=d \
+        -append "rd.live.overlay.overlayfs=1 root=LABEL=dracut console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \
+        -initrd "$TESTDIR"/initramfs.testing
+
     "$testdir"/run-qemu \
         "${disk_args[@]}" \
         -boot order=d \
index 81e5710e7fca5134eee99844f2e324e4363bde56..b513cbea00b3aefb55b0b46b8a3cbf5e8d0c84fd 100755 (executable)
@@ -182,6 +182,10 @@ test_nfsv3() {
         "root=dhcp" 192.168.50.3 wsize=4096 || return 1
 
     client_test "NFSv3 Overlayfs root=nfs:..." 52:54:00:12:34:04 \
+        "root=nfs:192.168.50.1:/nfs/client rd.live.overlay.overlayfs=1" \
+        192.168.50.1 -wsize=4096 || return 1
+
+    client_test "NFSv3 Live Overlayfs root=nfs:..." 52:54:00:12:34:04 \
         "root=nfs:192.168.50.1:/nfs/client rd.live.image rd.live.overlay.overlayfs=1" \
         192.168.50.1 -wsize=4096 || return 1