change "while read x" to cope with EOF without newline
[dracut.git] / test / TEST-40-NBD / create-root.sh
blob391279e4261b3ffc5d0c58213ce11f132db7e167
1 #!/bin/sh
2 # don't let udev and this script step on eachother's toes
3 for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
4 > "/etc/udev/rules.d/$x"
5 done
6 rm -f -- /etc/lvm/lvm.conf
7 udevadm control --reload
8 echo -n test >keyfile
9 cryptsetup -q luksFormat /dev/sdb /keyfile
10 echo "The passphrase is test"
11 cryptsetup luksOpen /dev/sdb dracut_crypt_test </keyfile && \
12 lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test && \
13 lvm vgcreate dracut /dev/mapper/dracut_crypt_test && \
14 lvm lvcreate -l 100%FREE -n root dracut && \
15 lvm vgchange -ay && \
16 mke2fs -L dracut -j /dev/dracut/root && \
17 /sbin/tune2fs -e continue /dev/dracut/root && \
18 mkdir -p /sysroot && \
19 mount /dev/dracut/root /sysroot && \
20 cp -a -t /sysroot /source/* && \
21 umount /sysroot
22 sleep 1
23 lvm lvchange -a n /dev/dracut/root
24 udevadm settle
25 cryptsetup luksClose /dev/mapper/dracut_crypt_test
26 udevadm settle
27 sleep 1
28 eval $(udevadm info --query=env --name=/dev/sdb|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
29 { echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } >/dev/sda
30 poweroff -f