Skip to content

Commit

Permalink
feat(overlayfs): add a new module called overlayfs
Browse files Browse the repository at this point in the history
Also split ovlfs variable with two different meaning.
  • Loading branch information
LaszloGombos authored and aafeijoo-suse committed Nov 7, 2022
1 parent 8caaad4 commit 40dd5c9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ multipath:
nvdimm:
- modules.d/90nvdimm/*

overlayfs:
- modules.d/90overlayfs/*

ppcmac:
- modules.d/90ppcmac/*

Expand Down
3 changes: 0 additions & 3 deletions modules.d/90dmsquash-live/dmsquash-live-genrules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions modules.d/90dmsquash-live/dmsquash-live-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions modules.d/90dmsquash-live/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]" "/etc/systemd/system/[email protected]"
Expand Down
18 changes: 18 additions & 0 deletions modules.d/90overlayfs/module-setup.sh
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/TEST-16-DMSQUASH/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 4 additions & 0 deletions test/TEST-20-NFS/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 40dd5c9

Please sign in to comment.