2 TEST_DESCRIPTION="root filesystem on LVM on encrypted partitions of a RAID-5"
4 KVERSION=${KVERSION-$(uname -r)}
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell" # udev.log-priority=debug
10 LUKSARGS=$(cat $TESTDIR/luks.txt)
12 dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1
14 echo "CLIENT TEST START: $LUKSARGS"
16 -hda $TESTDIR/root.ext2 \
17 -hdb $TESTDIR/check-success.img \
19 -net none -kernel /boot/vmlinuz-$KVERSION \
20 -append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $LUKSARGS $DEBUGFAIL" \
21 -initrd $TESTDIR/initramfs.testing
22 grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
23 echo "CLIENT TEST END: [OK]"
25 dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1
27 echo "CLIENT TEST START: Any LUKS"
29 -hda $TESTDIR/root.ext2 \
30 -hdb $TESTDIR/check-success.img \
32 -net none -kernel /boot/vmlinuz-$KVERSION \
33 -append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
34 -initrd $TESTDIR/initramfs.testing
35 grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
36 echo "CLIENT TEST END: [OK]"
38 dd if=/dev/zero of=$TESTDIR/check-success.img bs=1M count=1
40 echo "CLIENT TEST START: Wrong LUKS UUID"
42 -hda $TESTDIR/root.ext2 \
43 -hdb $TESTDIR/check-success.img \
45 -net none -kernel /boot/vmlinuz-$KVERSION \
46 -append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL rd.luks.uuid=failme" \
47 -initrd $TESTDIR/initramfs.testing
48 grep -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1
49 echo "CLIENT TEST END: [OK]"
55 # Create the blank file to use as a root filesystem
56 rm -f $TESTDIR/root.ext2
57 dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=80
60 # Create what will eventually be our root filesystem onto an overlay
62 initdir=$TESTDIR/overlay/source
63 . $basedir/dracut-functions
64 dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
65 mount dmesg ifconfig dhclient mkdir cp ping dhclient
66 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
67 [ -f ${_terminfodir}/l/linux ] && break
69 dracut_install -o ${_terminfodir}/l/linux
70 inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
71 inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
73 inst ./test-init /sbin/init
74 find_binary plymouth >/dev/null && dracut_install plymouth
75 (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
76 cp -a /etc/ld.so.conf* $initdir/etc
77 sudo ldconfig -r "$initdir"
80 # second, install the files needed to make the root filesystem
82 initdir=$TESTDIR/overlay
83 . $basedir/dracut-functions
84 dracut_install sfdisk mke2fs poweroff cp umount grep
85 inst_hook initqueue 01 ./create-root.sh
86 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
89 # create an initramfs that will create the target root filesystem.
90 # We do it this way so that we do not risk trashing the host mdraid
91 # devices, volume groups, encrypted partitions, etc.
92 $basedir/dracut -l -i $TESTDIR/overlay / \
93 -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
94 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
95 -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
96 rm -rf $TESTDIR/overlay
97 # Invoke KVM and/or QEMU to actually create the target filesystem.
98 $testdir/run-qemu -hda $TESTDIR/root.ext2 -m 256M -nographic -net none \
99 -kernel "/boot/vmlinuz-$kernel" \
100 -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
101 -initrd $TESTDIR/initramfs.makeroot || return 1
102 grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
103 cryptoUUIDS=$(grep --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2)
104 for uuid in $cryptoUUIDS; do
106 printf ' rd.luks.uuid=luks-%s ' $ID_FS_UUID
107 done > $TESTDIR/luks.txt
111 initdir=$TESTDIR/overlay
112 . $basedir/dracut-functions
113 dracut_install poweroff shutdown
114 inst_hook emergency 000 ./hard-off.sh
115 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
116 inst ./cryptroot-ask /sbin/cryptroot-ask
118 sudo $basedir/dracut -l -i $TESTDIR/overlay / \
119 -o "plymouth network" \
121 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
122 -f $TESTDIR/initramfs.testing $KVERSION || return 1
129 . $testdir/test-functions