2 TEST_DESCRIPTION
="root filesystem on an encrypted LVM PV on a degraded RAID-5"
4 KVERSION
=${KVERSION-$(uname -r)}
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell rd.break rd.debug"
8 #DEBUGFAIL="rd.shell rd.break=pre-mount udev.log-priority=debug"
9 #DEBUGFAIL="rd.shell rd.udev.log-priority=debug loglevel=70 systemd.log_target=kmsg"
10 #DEBUGFAIL="rd.shell loglevel=70 systemd.log_target=kmsg"
13 echo "CLIENT TEST START: $@"
14 cp --sparse=always
--reflink=auto
$TESTDIR/disk2.img
$TESTDIR/disk2.img.new
15 cp --sparse=always
--reflink=auto
$TESTDIR/disk3.img
$TESTDIR/disk3.img.new
18 -hda $TESTDIR/root.ext2
-m 256M
-nographic -smp 2 \
19 -hdc $TESTDIR/disk2.img.new \
20 -hdd $TESTDIR/disk3.img.new \
21 -net none
-kernel /boot
/vmlinuz-
$KVERSION \
22 -append "$* root=LABEL=root rw rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \
23 -initrd $TESTDIR/initramfs.testing
24 if ! grep -F -m 1 -q dracut-root-block-success
$TESTDIR/root.ext2
; then
25 echo "CLIENT TEST END: $@ [FAIL]"
29 sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' $TESTDIR/root.ext2
30 echo "CLIENT TEST END: $@ [OK]"
35 eval $
(grep -F --binary-files=text
-m 1 MD_UUID
$TESTDIR/root.ext2
)
36 echo "MD_UUID=$MD_UUID"
37 read LUKS_UUID
< $TESTDIR/luksuuid
39 client_run failme
&& return 1
40 client_run rd.auto ||
return 1
43 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=$MD_UUID rd.md.conf
=0 rd.lvm.vg
=dracut ||
return 1
45 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=failme rd.md.conf
=0 rd.lvm.vg
=dracut failme
&& return 1
47 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=$MD_UUID rd.lvm
=0 failme
&& return 1
48 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=$MD_UUID rd.lvm
=0 rd.auto
=1 failme
&& return 1
49 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=$MD_UUID rd.lvm.vg
=failme failme
&& return 1
50 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=$MD_UUID rd.lvm.vg
=dracut ||
return 1
51 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=$MD_UUID rd.lvm.lv
=dracut
/failme failme
&& return 1
52 client_run rd.luks.uuid
=$LUKS_UUID rd.md.uuid
=$MD_UUID rd.lvm.lv
=dracut
/root ||
return 1
58 # Create the blank file to use as a root filesystem
59 rm -f -- $TESTDIR/root.ext2
60 dd if=/dev
/null of
=$TESTDIR/root.ext2 bs
=1M seek
=40
61 dd if=/dev
/null of
=$TESTDIR/disk1.img bs
=1M seek
=20
62 dd if=/dev
/null of
=$TESTDIR/disk2.img bs
=1M seek
=20
63 dd if=/dev
/null of
=$TESTDIR/disk3.img bs
=1M seek
=20
66 # Create what will eventually be our root filesystem onto an overlay
68 export initdir
=$TESTDIR/overlay
/source
69 .
$basedir/dracut-functions.sh
72 mkdir
-p -- dev sys proc etc var
/run tmp
73 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
74 for i
in bin sbin lib lib64
; do
78 inst_multiple sh df free
ls shutdown poweroff stty
cat ps
ln ip route \
79 mount dmesg ifconfig dhclient mkdir
cp ping dhclient
80 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
81 [ -f ${_terminfodir}/l
/linux
] && break
83 inst_multiple
-o ${_terminfodir}/l
/linux
84 inst
"$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
85 inst
"$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
87 inst_simple
/etc
/os-release
88 inst .
/test-init.sh
/sbin
/init
89 find_binary plymouth
>/dev
/null
&& inst_multiple plymouth
90 cp -a /etc
/ld.so.conf
* $initdir/etc
91 sudo ldconfig
-r "$initdir"
94 # second, install the files needed to make the root filesystem
96 export initdir
=$TESTDIR/overlay
97 .
$basedir/dracut-functions.sh
98 inst_multiple sfdisk mke2fs poweroff
cp umount
dd grep
99 inst_hook initqueue
01 .
/create-root.sh
100 inst_hook initqueue
/finished
01 .
/finished-false.sh
101 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
104 # create an initramfs that will create the target root filesystem.
105 # We do it this way so that we do not risk trashing the host mdraid
106 # devices, volume groups, encrypted partitions, etc.
107 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
108 -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
109 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
110 --no-hostonly-cmdline -N \
111 -f $TESTDIR/initramfs.makeroot
$KVERSION ||
return 1
112 rm -rf -- $TESTDIR/overlay
113 # Invoke KVM and/or QEMU to actually create the target filesystem.
115 -hda $TESTDIR/root.ext2 \
116 -hdb $TESTDIR/disk1.img \
117 -hdc $TESTDIR/disk2.img \
118 -hdd $TESTDIR/disk3.img \
119 -m 256M
-smp 2 -nographic -net none \
120 -kernel "/boot/vmlinuz-$kernel" \
121 -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
122 -initrd $TESTDIR/initramfs.makeroot ||
return 1
124 grep -F -m 1 -q dracut-root-block-created
$TESTDIR/root.ext2 ||
return 1
125 eval $
(grep -F --binary-files=text
-m 1 MD_UUID
$TESTDIR/root.ext2
)
126 eval $
(grep -F -a -m 1 ID_FS_UUID
$TESTDIR/root.ext2
)
127 echo $ID_FS_UUID > $TESTDIR/luksuuid
130 export initdir
=$TESTDIR/overlay
131 .
$basedir/dracut-functions.sh
132 inst_multiple poweroff shutdown
133 inst_hook emergency
000 .
/hard-off.sh
134 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
135 inst .
/cryptroot-ask.sh
/sbin
/cryptroot-ask
136 mkdir
-p $initdir/etc
137 echo "ARRAY /dev/md0 level=raid5 num-devices=3 UUID=$MD_UUID" > $initdir/etc
/mdadm.conf
138 echo "luks-$ID_FS_UUID UUID=$ID_FS_UUID /etc/key" > $initdir/etc
/crypttab
139 echo -n test > $initdir/etc
/key
142 sudo
$basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
143 -o "plymouth network kernel-network-modules" \
145 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
146 --no-hostonly-cmdline -N \
147 -f $TESTDIR/initramfs.testing
$KVERSION ||
return 1
154 .
$testdir/test-functions