]> Raphaƫl G. Git Repositories - distgen/blob - lib/device.sh
Switch to single btrfs data device
[distgen] / lib / device.sh
1 #! /bin/sh -e
2
3 # Handle both devices
4 for i in ${SDA} ${SDB}; do
5 # Create empty file of 8GB
6 dd if=/dev/zero of=${i} bs=$((8192*1024)) count=1024
7 # Create partition table
8 #XXX: we generate gpt table
9 cat << EOF | gdisk ${i}
10 o
11 Y
12 n
13 1
14 2048
15 +2M
16 ef02
17 n
18 2
19
20 +256M
21 fd00
22 n
23 3
24
25 +2G
26 8200
27 n
28 4
29
30
31 fd00
32 w
33 Y
34 EOF
35 # Add it with partition scan
36 losetup -f -P ${i}
37 done
38
39 # Create raids
40 #XXX: grub2 support standard linux raid1 device
41 #mdadm --create /dev/md/${MDBOOT} --level=1 --metadata=0.90 --homehost=${NETHOSTNAME} --name=${MDBOOT} --assume-clean --raid-devices=2 ${LOOPA}p2 ${LOOPB}p2
42 mdadm --create /dev/md/${MDBOOT} --level=1 --metadata=default --homehost=${NETHOSTNAME} --name=${MDBOOT} --assume-clean --raid-devices=2 ${LOOPA}p2 ${LOOPB}p2
43 mdadm --create /dev/md/${MDDATA} --level=1 --metadata=default --homehost=${NETHOSTNAME} --name=${MDDATA} --assume-clean --raid-devices=2 ${LOOPA}p4 ${LOOPB}p4
44
45 # Create slash luks partition
46 #XXX: low iter time, should need around 100000 minimum
47 echo -n $LUKSPASSWORD | cryptsetup -c aes-xts-plain64 -h sha512 -s 512 --iter-time 2000 --use-urandom --uuid ${LUKSDATAUUID} -d - --batch-mode luksFormat /dev/md/${MDDATA}
48
49 # Open luks partition
50 echo -n $LUKSPASSWORD | cryptsetup -d - --batch-mode luksOpen /dev/md/${MDDATA} ${DATANAME}