#!/bin/bash # shellcheck disable=SC2034 TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a RAID-5" # Uncomment this to debug failures #DEBUGFAIL="rd.shell rd.udev.log-priority=debug loglevel=70 systemd.log_target=kmsg" #DEBUGFAIL="rd.break rd.shell rd.debug debug" test_run() { declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker qemu_add_drive disk_index disk_args "$TESTDIR"/raid-1.img raid1 qemu_add_drive disk_index disk_args "$TESTDIR"/raid-2.img raid2 qemu_add_drive disk_index disk_args "$TESTDIR"/raid-3.img raid3 test_marker_reset "$testdir"/run-qemu \ "${disk_args[@]}" \ -append "$TEST_KERNEL_CMDLINE root=/dev/dracut/root rd.auto rw" \ -initrd "$TESTDIR"/initramfs.testing || return 1 test_marker_check || return 1 } test_setup() { # Create what will eventually be our root filesystem onto an overlay "$DRACUT" -N -l --keep --tmpdir "$TESTDIR" \ -m "test-root" \ -f "$TESTDIR"/initramfs.root "$KVERSION" || return 1 mkdir -p "$TESTDIR"/overlay/source && mv "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.* # create an initramfs that will create the target root filesystem. # We do it this way so that we do not risk trashing the host mdraid # devices, volume groups, encrypted partitions, etc. "$DRACUT" -N -l -i "$TESTDIR"/overlay / \ -a "test-makeroot bash crypt lvm mdraid kernel-modules" \ -I "grep cryptsetup" \ -i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \ -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 rm -rf -- "$TESTDIR"/overlay # Create the blank files to use as a root filesystem declare -a disk_args=() declare -i disk_index=0 qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1 qemu_add_drive disk_index disk_args "$TESTDIR"/raid-1.img raid1 80 qemu_add_drive disk_index disk_args "$TESTDIR"/raid-2.img raid2 80 qemu_add_drive disk_index disk_args "$TESTDIR"/raid-3.img raid3 80 "$testdir"/run-qemu \ "${disk_args[@]}" \ -append "root=/dev/cannotreach rw rootfstype=ext4 quiet console=ttyS0,115200n81" \ -initrd "$TESTDIR"/initramfs.makeroot || return 1 test_marker_check dracut-root-block-created || return 1 eval "$(grep -F -a -m 1 ID_FS_UUID "$TESTDIR"/marker.img)" echo "testluks UUID=$ID_FS_UUID /etc/key" > /tmp/crypttab echo -n "test" > /tmp/key test_dracut \ -i "./cryptroot-ask.sh" "/sbin/cryptroot-ask" \ -i "/tmp/crypttab" "/etc/crypttab" \ -i "/tmp/key" "/etc/key" \ "$TESTDIR"/initramfs.testing } # shellcheck disable=SC1090 . "$testdir"/test-functions