3 # shellcheck disable=SC2034
4 TEST_DESCRIPTION
="live root on a squash filesystem"
6 # Uncomment these to debug failures
7 #DEBUGFAIL="rd.shell rd.debug rd.live.debug loglevel=7"
10 declare -a disk_args
=()
11 declare -i disk_index
=0
12 qemu_add_drive_args disk_index disk_args
"$TESTDIR"/marker.img marker
13 qemu_add_drive_args disk_index disk_args
"$TESTDIR"/root.img root
16 if modprobe
--dry-run ntfs3
&> /dev
/null
&& command -v mkfs.ntfs
&> /dev
/null
; then
17 qemu_add_drive_args disk_index disk_args
"$TESTDIR"/root_ntfs.img root_ntfs
24 -append "rd.live.overlay.overlayfs=1 root=live:/dev/disk/by-label/dracut console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \
25 -initrd "$TESTDIR"/initramfs.testing
27 test_marker_check ||
return 1
33 -append "rd.live.image 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" \
34 -initrd "$TESTDIR"/initramfs.testing
36 test_marker_check ||
return 1
42 -append "rd.live.image rd.live.overlay.overlayfs=1 rd.live.dir=testdir root=LABEL=dracut console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \
43 -initrd "$TESTDIR"/initramfs.testing
45 test_marker_check ||
return 1
47 # Run the NTFS test only if mkfs.ntfs is available
48 if modprobe
--dry-run ntfs3
&> /dev
/null
&& command -v mkfs.ntfs
&> /dev
/null
; then
49 dd if=/dev
/zero of
="$TESTDIR"/marker.img bs
=1MiB count
=1
53 -append "rd.live.image rd.live.overlay.overlayfs=1 rd.live.dir=testdir root=LABEL=dracut_ntfs console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \
54 -initrd "$TESTDIR"/initramfs.testing
56 test_marker_check ||
return 1
60 rootPartitions
=$
(sfdisk
-d "$TESTDIR"/root.img |
grep -c 'root\.img[0-9]')
61 [ "$rootPartitions" -eq 1 ] ||
return 1
66 -append "rd.live.image rd.live.overlay.overlayfs=1 rd.live.overlay=LABEL=persist rd.live.dir=testdir root=LABEL=dracut console=ttyS0,115200n81 quiet selinux=0 rd.info rd.shell=0 panic=1 oops=panic softlockup_panic=1 $DEBUGFAIL" \
67 -initrd "$TESTDIR"/initramfs.testing-autooverlay
69 rootPartitions
=$
(sfdisk
-d "$TESTDIR"/root.img |
grep -c 'root\.img[0-9]')
70 [ "$rootPartitions" -eq 2 ] ||
return 1
73 # Ensure that this test works when run with the `V=1` parameter, which runs the script with `set -o pipefail`.
76 # Verify that the string "dracut-autooverlay-success" occurs in the second partition in the image file.
77 dd if="$TESTDIR"/root.img bs
=1MiB skip
=80 status
=none \
78 |
grep -U --binary-files=binary
-F -m 1 -q dracut-autooverlay-success
83 # Create what will eventually be our root filesystem onto an overlay
84 "$basedir"/dracut.sh
-l --keep --tmpdir "$TESTDIR" \
86 -i .
/test-init.sh
/sbin
/init \
87 -i "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh" \
88 -i "${basedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh" \
89 --no-hostonly --no-hostonly-cmdline --nomdadmconf --nohardlink \
90 -f "$TESTDIR"/initramfs.root
"$KVERSION" ||
return 1
91 mkdir
-p "$TESTDIR"/overlay
/source && mv "$TESTDIR"/dracut.
*/initramfs
/* "$TESTDIR"/overlay
/source && rm -rf "$TESTDIR"/dracut.
*
93 # second, install the files needed to make the root filesystem
94 # create an initramfs that will create the target root filesystem.
95 # We do it this way so that we do not risk trashing the host mdraid
96 # devices, volume groups, encrypted partitions, etc.
97 "$basedir"/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
98 --modules "test-makeroot" \
99 --install "sfdisk mkfs.ext4 mkfs.ntfs mksquashfs" \
101 --include .
/create-root.sh
/lib
/dracut
/hooks
/initqueue
/01-create-root.sh \
102 --no-hostonly --no-hostonly-cmdline --no-early-microcode --nofscks --nomdadmconf --nohardlink --nostrip \
103 --force "$TESTDIR"/initramfs.makeroot
"$KVERSION" ||
return 1
104 rm -rf -- "$TESTDIR"/overlay
106 # Create the blank file to use as a root filesystem
107 declare -a disk_args
=()
108 declare -i disk_index
=0
109 qemu_add_drive_args disk_index disk_args
"$TESTDIR"/marker.img marker
1
110 qemu_add_drive_args disk_index disk_args
"$TESTDIR"/root.img root
160
113 if modprobe
--dry-run ntfs3
&> /dev
/null
&& command -v mkfs.ntfs
&> /dev
/null
; then
114 dd if=/dev
/zero of
="$TESTDIR"/root_ntfs.img bs
=1MiB count
=160
115 qemu_add_drive_args disk_index disk_args
"$TESTDIR"/root_ntfs.img root_ntfs
118 # Invoke KVM and/or QEMU to actually create the target filesystem.
119 "$testdir"/run-qemu \
121 -append "root=/dev/dracut/root rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \
122 -initrd "$TESTDIR"/initramfs.makeroot ||
return 1
124 if ! test_marker_check dracut-root-block-created
; then
125 echo "Could not create root filesystem"
129 # mount NTFS with ntfs3 driver inside the generated initramfs
130 cat > /tmp
/ntfs3.rules
<< 'EOF'
131 SUBSYSTEM
=="block", ENV
{ID_FS_TYPE
}=="ntfs", ENV
{ID_FS_TYPE
}="ntfs3"
134 "$basedir"/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
135 --modules "test dash dmsquash-live qemu" \
137 --drivers "ext4 ntfs3 sd_mod" \
138 --install "mkfs.ext4" \
139 --include /tmp
/ntfs3.rules
/lib
/udev
/rules.d
/ntfs3.rules \
140 --no-hostonly --no-hostonly-cmdline \
141 --force "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
143 "$basedir"/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
144 --modules "test dmsquash-live-autooverlay qemu" \
146 --drivers "ext4 sd_mod" \
147 --install "mkfs.ext4" \
148 --no-hostonly --no-hostonly-cmdline \
149 --force "$TESTDIR"/initramfs.testing-autooverlay
"$KVERSION" ||
return 1
151 rm -rf -- "$TESTDIR"/overlay
154 # shellcheck disable=SC1090
155 .
"$testdir"/test-functions