Skip to content

Commit 8caaad4

Browse files
LaszloGombosaafeijoo-suse
authored andcommitted
fix(dmsquash-live): add support for NFS
Move overlayfs mount out into its own dedicated file so that we can call into it directly for NFS support. Add a new test case for overlayfs on top of NFS.
1 parent 11eef2c commit 8caaad4

File tree

6 files changed

+48
-16
lines changed

6 files changed

+48
-16
lines changed

modules.d/90dmsquash-live/dmsquash-live-genrules.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ case "$root" in
1515
/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "${root#live:}"
1616
fi
1717
;;
18+
nfs*)
19+
cp /sbin/mount-overlayfs "$hookdir/mount/99-mount-overlayfs.sh"
20+
;;
1821
esac

modules.d/90dmsquash-live/dmsquash-live-root.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -425,22 +425,8 @@ if [ -n "$overlayfs" ]; then
425425
else
426426
ln -sf /run/initramfs/live /run/rootfsbase
427427
fi
428-
mkdir -m 0755 -p /run/overlayfs
429-
mkdir -m 0755 -p /run/ovlwork
430-
if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
431-
ovlfs=$(readlink /run/overlayfs)
432-
info "Resetting the OverlayFS overlay directory."
433-
rm -r -- "${ovlfs:?}"/* "${ovlfs:?}"/.* > /dev/null 2>&1
434-
fi
435-
if [ -n "$readonly_overlay" ] && [ -h /run/overlayfs-r ]; then
436-
ovlfs=lowerdir=/run/overlayfs-r:/run/rootfsbase
437-
else
438-
ovlfs=lowerdir=/run/rootfsbase
439-
fi
440428
if [ -z "$DRACUT_SYSTEMD" ]; then
441-
printf 'mount -t overlay LiveOS_rootfs -o%s,%s %s\n' "$ROOTFLAGS" \
442-
"$ovlfs",upperdir=/run/overlayfs,workdir=/run/ovlwork \
443-
"$NEWROOT" > "$hookdir"/mount/01-$$-live.sh
429+
ln -sf /sbin/mount-overlayfs "$hookdir"/mount/01-$$-live.sh
444430
fi
445431
else
446432
if [ -z "$DRACUT_SYSTEMD" ]; then

modules.d/90dmsquash-live/module-setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ install() {
3131
inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
3232
inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
3333
inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan"
34+
inst_script "$moddir/mount-overlayfs.sh" "/sbin/mount-overlayfs"
3435
if dracut_module_included "systemd-initrd"; then
3536
inst_script "$moddir/dmsquash-generator.sh" "$systemdutildir"/system-generators/dracut-dmsquash-generator
3637
inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
4+
5+
PATH=/usr/sbin:/usr/bin:/sbin:/bin
6+
7+
getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes"
8+
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
9+
getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
10+
11+
ROOTFLAGS="$(getarg rootflags)"
12+
13+
if [ -n "$overlayfs" ]; then
14+
if ! [ -e /run/rootfsbase ]; then
15+
mkdir -m 0755 -p /run/rootfsbase
16+
mount --bind "$NEWROOT" /run/rootfsbase
17+
fi
18+
19+
mkdir -m 0755 -p /run/overlayfs
20+
mkdir -m 0755 -p /run/ovlwork
21+
if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then
22+
ovlfs=$(readlink /run/overlayfs)
23+
info "Resetting the OverlayFS overlay directory."
24+
rm -r -- "${ovlfs:?}"/* "${ovlfs:?}"/.* > /dev/null 2>&1
25+
fi
26+
if [ -n "$readonly_overlay" ] && [ -h /run/overlayfs-r ]; then
27+
ovlfs=lowerdir=/run/overlayfs-r:/run/rootfsbase
28+
else
29+
ovlfs=lowerdir=/run/rootfsbase
30+
fi
31+
32+
if ! strstr "$(cat /proc/mounts)" LiveOS_rootfs; then
33+
mount -t overlay LiveOS_rootfs -o "$ROOTFLAGS,$ovlfs",upperdir=/run/overlayfs,workdir=/run/ovlwork "$NEWROOT"
34+
fi
35+
fi

modules.d/90dmsquash-live/parse-dmsquash-live.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ case "$liveroot" in
3939
live:/*.[Ii][Mm][Gg] | /*.[Ii][Mm][Gg])
4040
[ -f "${root#live:}" ] && rootok=1
4141
;;
42+
live:nfs*)
43+
rootok=1
44+
;;
4245
esac
4346

4447
[ "$rootok" = "1" ] || return 1

test/TEST-20-NFS/test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ test_nfsv3() {
181181
client_test "NFSv3 root=dhcp DHCP proto:IP:path,options" 52:54:00:12:34:07 \
182182
"root=dhcp" 192.168.50.3 wsize=4096 || return 1
183183

184+
client_test "NFSv3 Overlayfs root=nfs:..." 52:54:00:12:34:04 \
185+
"root=nfs:192.168.50.1:/nfs/client rd.live.image rd.live.overlay.overlayfs=1" \
186+
192.168.50.1 -wsize=4096 || return 1
187+
184188
return 0
185189
}
186190

@@ -400,7 +404,7 @@ test_setup() {
400404
# Make client's dracut image
401405
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
402406
-o "plymouth dash ${OMIT_NETWORK}" \
403-
-a "debug watchdog ${USE_NETWORK}" \
407+
-a "dmsquash-live debug watchdog ${USE_NETWORK}" \
404408
--no-hostonly-cmdline -N \
405409
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
406410

0 commit comments

Comments
 (0)