]> Raphaƫl G. Git Repositories - distgen/blob - lib/device.sh
Initial import
[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 then fake mbr compat one
9 cat << EOF | fdisk ${i}
10 g
11 n
12 1
13 2048
14 +256M
15 t
16 29
17 n
18 2
19 526336
20 +4G
21 t
22 2
23 29
24 n
25 3
26 8914944
27 +2G
28 t
29 3
30 19
31 n
32 4
33 13109248
34 16777182
35 t
36 4
37 29
38 x
39 A
40 1
41 M
42 r
43 d
44 n
45 p
46 1
47 2048
48 +256M
49 t
50 fd
51 n
52 p
53 2
54 526336
55 +4G
56 t
57 2
58 fd
59 n
60 p
61 3
62 8914944
63 +2G
64 t
65 3
66 82
67 n
68 p
69 13109248
70 16777182
71 t
72 4
73 fd
74 a
75 1
76 p
77 x
78 M
79 r
80 p
81 w
82 EOF
83 # Add it with partition scan
84 losetup -f -P ${i}
85 done
86
87 # Create raids
88 mdadm --create /dev/md/${MDBOOT} --level=1 --metadata=0.90 --homehost=${NETHOSTNAME} --name=${MDBOOT} --assume-clean --raid-devices=2 ${LOOPA}p1 ${LOOPB}p1
89 mdadm --create /dev/md/${MDSLASH} --level=1 --metadata=default --homehost=${NETHOSTNAME} --name=${MDSLASH} --assume-clean --raid-devices=2 ${LOOPA}p2 ${LOOPB}p2
90 mdadm --create /dev/md/${MDDATA} --level=1 --metadata=default --homehost=${NETHOSTNAME} --name=${MDDATA} --assume-clean --raid-devices=2 ${LOOPA}p4 ${LOOPB}p4
91
92 # Create slash luks partition
93 #XXX: low iter time, should need around 100000 minimum
94 echo -n $LUKSPASSWORD | cryptsetup -c aes-xts-plain64 -h sha512 -s 512 --iter-time 2000 --use-urandom --uuid ${LUKSSLASHUUID} -d - --batch-mode luksFormat /dev/md/${MDSLASH}
95
96 # Open luks partition
97 echo -n $LUKSPASSWORD | cryptsetup -d - --batch-mode luksOpen /dev/md/${MDSLASH} ${SLASHNAME}
98
99 # Create data luks partition
100 #XXX: low iter time, should need around 100000 minimum
101 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}
102
103 # Open luks partition
104 echo -n $LUKSPASSWORD | cryptsetup -d - --batch-mode luksOpen /dev/md/${MDDATA} ${DATANAME}
105