dracut-systemd/dracut-initqueue: only start service if really needed
[dracut.git] / test / TEST-14-IMSM / create-root.sh
blobf637ec8835332f014e836dab9111011349ef9a70
1 #!/bin/sh
2 # don't let udev and this script step on eachother's toes
3 for x in 61-dmraid-imsm.rules 64-md-raid.rules 65-md-incremental-imsm.rules 65-md-incremental.rules 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
4 rm -f -- "/etc/udev/rules.d/$x"
5 done
6 rm -f -- /etc/lvm/lvm.conf
8 udevadm control --reload
9 # dmraid does not want symlinks in --disk "..."
10 if [ -e /dev/hda ] ; then
11 echo y|dmraid -f isw -C Test0 --type 1 --disk "/dev/hdb /dev/hdc"
12 else
13 echo y|dmraid -f isw -C Test0 --type 1 --disk "/dev/sdb /dev/sdc"
15 udevadm settle
17 SETS=$(dmraid -c -s)
18 # scan and activate all DM RAIDS
19 for s in $SETS; do
20 dmraid -ay -i -p --rm_partitions "$s"
21 [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s"
22 done
24 udevadm settle
25 sleep 1
26 udevadm settle
28 sfdisk -g /dev/mapper/isw*Test0
29 # save a partition at the beginning for future flagging purposes
30 sfdisk --no-reread /dev/mapper/isw*Test0 <<EOF
31 ,4M
32 ,20M
33 ,20M
34 ,20M
35 EOF
37 udevadm settle
38 dmraid -a n
39 udevadm settle
41 SETS=$(dmraid -c -s -i)
42 # scan and activate all DM RAIDS
43 for s in $SETS; do
44 dmraid -ay -i -p --rm_partitions "$s"
45 [ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s"
46 done
48 udevadm settle
50 mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 \
51 /dev/mapper/isw*p2 \
52 /dev/mapper/isw*p3 \
53 /dev/mapper/isw*p4
55 # wait for the array to finish initailizing, otherwise this sometimes fails
56 # randomly.
57 mdadm -W /dev/md0
58 lvm pvcreate -ff -y /dev/md0
59 lvm vgcreate dracut /dev/md0 && \
60 lvm lvcreate -l 100%FREE -n root dracut && \
61 lvm vgchange -ay && \
62 mke2fs -L root /dev/dracut/root && \
63 mkdir -p /sysroot && \
64 mount /dev/dracut/root /sysroot && \
65 cp -a -t /sysroot /source/* && \
66 umount /sysroot && \
67 lvm lvchange -a n /dev/dracut/root && \
68 udevadm settle
69 mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid
70 . /tmp/mduuid
71 echo "MD_UUID=$MD_UUID"
72 { echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID;} > /dev/sda
73 mdadm --wait-clean /dev/md0
74 poweroff -f