summaryrefslogtreecommitdiffstats
path: root/debian/90overlay-root
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:54:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:54:25 +0000
commit613b5479a576e8b54bc261055d341466fa57a937 (patch)
tree4e8f56ead3c83759cf5c9005d350926275370f66 /debian/90overlay-root
parentAdding upstream version 060+5. (diff)
downloaddracut-613b5479a576e8b54bc261055d341466fa57a937.tar.xz
dracut-613b5479a576e8b54bc261055d341466fa57a937.zip
Adding debian version 060+5-1.debian/060+5-1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/90overlay-root')
-rw-r--r--debian/90overlay-root/README14
-rw-r--r--debian/90overlay-root/module-setup.sh20
-rw-r--r--debian/90overlay-root/overlay-mount.sh39
3 files changed, 73 insertions, 0 deletions
diff --git a/debian/90overlay-root/README b/debian/90overlay-root/README
new file mode 100644
index 0000000..aa14275
--- /dev/null
+++ b/debian/90overlay-root/README
@@ -0,0 +1,14 @@
+dracut rootfs overlayfs module
+
+Make any rootfs ro, but writable via overlayfs.
+This is convenient, if for example using an ro-nfs-mount.
+
+Add the parameter "rootovl" to the kernel, to activate this feature
+
+This happens pre-pivot. Therefore the final root file system is already
+mounted. It will be set ro, and turned into an overlayfs mount with an
+underlying tmpfs.
+
+The original root and the tmpfs will be mounted at /live/image and
+/live/cow in the final rootfs.
+
diff --git a/debian/90overlay-root/module-setup.sh b/debian/90overlay-root/module-setup.sh
new file mode 100644
index 0000000..ae009f4
--- /dev/null
+++ b/debian/90overlay-root/module-setup.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+check() {
+ # do not add modules if the kernel does not have overlayfs support
+ [ -d /lib/modules/$kernel/kernel/fs/overlayfs ] || return 1
+}
+
+depends() {
+ # We do not depend on any modules - just some root
+ return 0
+}
+
+# called by dracut
+installkernel() {
+ hostonly='' instmods overlay
+}
+
+install() {
+ inst_hook pre-pivot 10 "$moddir/overlay-mount.sh"
+}
diff --git a/debian/90overlay-root/overlay-mount.sh b/debian/90overlay-root/overlay-mount.sh
new file mode 100644
index 0000000..27d0312
--- /dev/null
+++ b/debian/90overlay-root/overlay-mount.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# make a read-only nfsroot writeable by using overlayfs
+# the nfsroot is already mounted to $NEWROOT
+# add the parameter rootovl to the kernel, to activate this feature
+
+. /lib/dracut-lib.sh
+
+if ! getargbool 0 rootovl ; then
+ return
+fi
+
+modprobe overlay
+
+# a little bit tuning
+mount -o remount,nolock,noatime $NEWROOT
+
+# Move root
+# --move does not always work. Google >mount move "wrong fs"< for
+# details
+mkdir -p /live/image
+mount --bind $NEWROOT /live/image
+umount $NEWROOT
+
+# Create tmpfs
+mkdir /cow
+mount -n -t tmpfs -o mode=0755 tmpfs /cow
+mkdir /cow/work /cow/rw
+
+# Merge both to new Filesystem
+mount -t overlay -o noatime,lowerdir=/live/image,upperdir=/cow/rw,workdir=/cow/work,default_permissions overlay $NEWROOT
+
+# Let filesystems survive pivot
+mkdir -p $NEWROOT/live/cow
+mkdir -p $NEWROOT/live/image
+mount --bind /cow/rw $NEWROOT/live/cow
+umount /cow
+mount --bind /live/image $NEWROOT/live/image
+umount /live/image