dracut-systemd/dracut-initqueue: only start service if really needed
[dracut.git] / test / TEST-12-RAID-DEG / create-root.sh
blob7b9a17179cff2fd4f53fdf5be758120b0fbfe0d8
1 #!/bin/sh
2 # don't let udev and this script step on eachother's toes
4 trap 'poweroff -f' EXIT
6 for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
7 > "/etc/udev/rules.d/$x"
8 done
9 rm -f -- /etc/lvm/lvm.conf
10 udevadm control --reload
11 # save a partition at the beginning for future flagging purposes
12 sfdisk /dev/sda <<EOF
13 ,5M
14 ,10M
15 ,10M
16 ,10M
17 EOF
18 udevadm settle
19 mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
20 # wait for the array to finish initailizing, otherwise this sometimes fails
21 # randomly.
22 mdadm -W /dev/md0
23 echo -n test >keyfile
24 cryptsetup -q luksFormat /dev/md0 /keyfile
25 echo "The passphrase is test"
26 set -e
27 cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile
28 lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
29 lvm vgcreate dracut /dev/mapper/dracut_crypt_test
30 lvm lvcreate -l 100%FREE -n root dracut
31 lvm vgchange -ay
32 mke2fs -L root /dev/dracut/root
33 mkdir -p /sysroot
34 mount /dev/dracut/root /sysroot
35 cp -a -t /sysroot /source/*
36 mkdir /sysroot/run
37 umount /sysroot
38 lvm lvchange -a n /dev/dracut/root
39 udevadm settle
40 cryptsetup luksClose /dev/mapper/dracut_crypt_test
41 udevadm settle
42 mdadm -W /dev/md0 || :
43 mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid
44 . /tmp/mduuid
45 eval $(udevadm info --query=env --name=/dev/md0|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
46 { echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID; echo "ID_FS_UUID=$ID_FS_UUID";} > /dev/sda1