raid-crypto-lvm/install.sh

raw link view readme
1 n
2 p
3 1
4
5
6 t
7 fd
8 w
9 EOF
10
11 sfdisk -d /dev/sdb > /var/partition-table
12 sfdisk /dev/sdc < /var/partition-table
13 sfdisk /dev/sdd < /var/partition-table
14 sfdisk /dev/sde < /var/partition-table
15
16 partprobe
17
18 yum install mdadm cryptsetup -y
19
20 mdadm --create /dev/md0 --level=10 --chunk=4 --raid-devices=4 /dev/sd[b-e]1
21
22 mdadm --detail --scan --verbose >> /etc/mdadm.conf
23
24 modprobe dm-crypt
25
26 echo -n "diskpassword" > /root/keyfile
27
28 cryptsetup luksFormat /dev/md0 -q --key-file /root/keyfile
29
30 cryptsetup luksOpen /dev/md0 encdisk --key-file /root/keyfile
31
32 pvcreate /dev/mapper/encdisk
33
34 vgcreate vg_core /dev/mapper/encdisk
35
36 lvcreate --size 20G vg_core -n lv_mongologs
37 lvcreate -l +100%FREE vg_core -n lv_mongo
38
39 mkfs.xfs /dev/vg_core/lv_mongologs
40 mkfs.xfs /dev/vg_core/lv_mongo
41
42 mkdir /var/log/mongodb
43 mkdir /var/lib/mongo
44
45 cat > /etc/crypttab <<\EOF
46 encdisk /dev/md0 /root/keyfile
47 echo
48 EOF
49
50 echo "$(xfs_admin -u /dev/vg_core/lv_mongologs | sed "s/ //g") /var/log/mongodb xfs defaults,noatime 0 0" >> /etc/fstab
51 echo "$(xfs_admin -u /dev/vg_core/lv_mongo | sed "s/ //g") /var/lib/mongo xfs defaults,noatime 0 0" >> /etc/fstab
52
53 mount -a
54