]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-10-RAID/test.sh
new parameter option names with "rd.*" namespace
[thirdparty/dracut.git] / test / TEST-10-RAID / test.sh
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on an encrypted LVM PV on a RAID-5"
3
4 KVERSION=${KVERSION-$(uname -r)}
5
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell"
8
9 test_run() {
10 $testdir/run-qemu -hda root.ext2 -m 256M -nographic \
11 -net none -kernel /boot/vmlinuz-$KVERSION \
12 -append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
13 -initrd initramfs.testing
14 grep -m 1 -q dracut-root-block-success root.ext2 || return 1
15 }
16
17 test_setup() {
18 # Create the blank file to use as a root filesystem
19 dd if=/dev/zero of=root.ext2 bs=1M count=40
20
21 kernel=$KVERSION
22 # Create what will eventually be our root filesystem onto an overlay
23 (
24 initdir=overlay/source
25 . $basedir/dracut-functions
26 dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
27 /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
28 inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
29 inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
30 dracut_install grep
31 inst ./test-init /sbin/init
32 find_binary plymouth >/dev/null && dracut_install plymouth
33 (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
34 cp -a /etc/ld.so.conf* $initdir/etc
35 sudo ldconfig -r "$initdir"
36 )
37
38 # second, install the files needed to make the root filesystem
39 (
40 initdir=overlay
41 . $basedir/dracut-functions
42 dracut_install sfdisk mke2fs poweroff cp umount
43 inst_simple ./create-root.sh /initqueue/01create-root.sh
44 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
45 )
46
47 # create an initramfs that will create the target root filesystem.
48 # We do it this way so that we do not risk trashing the host mdraid
49 # devices, volume groups, encrypted partitions, etc.
50 $basedir/dracut -l -i overlay / \
51 -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
52 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
53 --nomdadmconf \
54 -f initramfs.makeroot $KVERSION || return 1
55 rm -rf overlay
56 # Invoke KVM and/or QEMU to actually create the target filesystem.
57 $testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
58 -kernel "/boot/vmlinuz-$kernel" \
59 -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
60 -initrd initramfs.makeroot || return 1
61 grep -m 1 -q dracut-root-block-created root.ext2 || return 1
62 (
63 initdir=overlay
64 . $basedir/dracut-functions
65 dracut_install poweroff shutdown
66 inst_simple ./hard-off.sh /emergency/01hard-off.sh
67 inst ./cryptroot-ask /sbin/cryptroot-ask
68 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
69 )
70 sudo $basedir/dracut -l -i overlay / \
71 -o "plymouth network" \
72 -a "debug" \
73 -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
74 -f initramfs.testing $KVERSION || return 1
75 }
76
77 test_cleanup() {
78 rm -fr overlay mnt
79 rm -f root.ext2 initramfs.makeroot initramfs.testing
80 }
81
82 . $testdir/test-functions