From: Laszlo Gombos Date: Sat, 17 Dec 2022 01:00:28 +0000 (+0000) Subject: test(DMSQUASH): add test for NTFS X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=995ac6f887e7cb5f8bdf2d636ed3b3e715691db4;p=thirdparty%2Fdracut.git test(DMSQUASH): add test for NTFS Add a test case for mounting the root filesystem from a squashfs image file that is store on an NTFS drive. The test case is using ntfs3 module to mount the NTFS drive. --- diff --git a/test/TEST-16-DMSQUASH/create-root.sh b/test/TEST-16-DMSQUASH/create-root.sh index d0e409e91..f17b22f9c 100755 --- a/test/TEST-16-DMSQUASH/create-root.sh +++ b/test/TEST-16-DMSQUASH/create-root.sh @@ -26,6 +26,16 @@ mkdir -p /root/run /root/testdir cp -a -t /root /source/* echo "Creating squashfs" mksquashfs /source /root/testdir/rootfs.img -quiet + +# Copy rootfs.img to the NTFS drive if exists +if [ -e "/dev/disk/by-id/ata-disk_root_ntfs" ]; then + mkfs.ntfs -F -L dracut_ntfs /dev/disk/by-id/ata-disk_root_ntfs + mkdir -p /root_ntfs + mount -t ntfs3 /dev/disk/by-id/ata-disk_root_ntfs /root_ntfs + mkdir -p /root_ntfs/run /root_ntfs/testdir + cp /root/testdir/rootfs.img /root_ntfs/testdir/rootfs.img +fi + umount /root echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker poweroff -f diff --git a/test/TEST-16-DMSQUASH/test.sh b/test/TEST-16-DMSQUASH/test.sh index 1535386d9..af9440172 100755 --- a/test/TEST-16-DMSQUASH/test.sh +++ b/test/TEST-16-DMSQUASH/test.sh @@ -12,6 +12,11 @@ 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 + # NTFS drive + if modprobe --dry-run ntfs3 &> /dev/null && command -v mkfs.ntfs &> /dev/null; then + qemu_add_drive_args disk_index disk_args "$TESTDIR"/root_ntfs.img root_ntfs + fi + test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ @@ -39,6 +44,18 @@ test_run() { test_marker_check || return 1 + # Run the NTFS test only if mkfs.ntfs is available + if modprobe --dry-run ntfs3 &> /dev/null && command -v mkfs.ntfs &> /dev/null; then + dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1 + "$testdir"/run-qemu \ + "${disk_args[@]}" \ + -boot order=d \ + -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" \ + -initrd "$TESTDIR"/initramfs.testing + + test_marker_check || return 1 + fi + test_marker_reset rootPartitions=$(sfdisk -d "$TESTDIR"/root.img | grep -c 'root\.img[0-9]') [ "$rootPartitions" -eq 1 ] || return 1 @@ -79,7 +96,8 @@ test_setup() { # devices, volume groups, encrypted partitions, etc. "$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \ --modules "test-makeroot" \ - --install "sfdisk mkfs.ext4 mksquashfs" \ + --install "sfdisk mkfs.ext4 mkfs.ntfs mksquashfs" \ + --drivers "ntfs3" \ --include ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ --no-hostonly --no-hostonly-cmdline --no-early-microcode --nofscks --nomdadmconf --nohardlink --nostrip \ --force "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 @@ -91,6 +109,12 @@ test_setup() { qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker 1 qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root 160 + # NTFS drive + if modprobe --dry-run ntfs3 &> /dev/null && command -v mkfs.ntfs &> /dev/null; then + dd if=/dev/zero of="$TESTDIR"/root_ntfs.img bs=1MiB count=160 + qemu_add_drive_args disk_index disk_args "$TESTDIR"/root_ntfs.img root_ntfs + fi + # Invoke KVM and/or QEMU to actually create the target filesystem. "$testdir"/run-qemu \ "${disk_args[@]}" \ @@ -102,11 +126,17 @@ test_setup() { return 1 fi + # mount NTFS with ntfs3 driver inside the generated initramfs + cat > /tmp/ntfs3.rules << 'EOF' +SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="ntfs", ENV{ID_FS_TYPE}="ntfs3" +EOF + "$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \ --modules "test dash dmsquash-live qemu" \ --omit "rngd" \ - --drivers "ext4 sd_mod" \ + --drivers "ext4 ntfs3 sd_mod" \ --install "mkfs.ext4" \ + --include /tmp/ntfs3.rules /lib/udev/rules.d/ntfs3.rules \ --no-hostonly --no-hostonly-cmdline \ --force "$TESTDIR"/initramfs.testing "$KVERSION" || return 1