lvm-xfs/install.sh

raw link view readme
1 create ()
2 {
3 # OR USE parted -s /dev/sd$1 mklabel gpt
4 parted -s /dev/sd$1 mklabel msdos
5 parted -s /dev/sd$1 mkpart primary 1MiB 100%
6 parted -s /dev/sd$1 set 1 lvm on
7 }
8
9 create b
10 create c
11 create d
12 create e
13
14 partprobe
15
16 pvcreate /dev/sd[b-d]1
17
18 vgcreate vg_core /dev/sdb1 /dev/sdc1 /dev/sdd1
19
20 lvcreate -L 20G vg_core -n lv_mongologs
21 lvcreate -l +50%FREE vg_core -n lv_mongodb
22
23 mkfs.xfs /dev/vg_core/lv_mongologs
24 mkfs.xfs /dev/vg_core/lv_mongodb
25
26 mkdir /var/log/mongologs
27 mkdir /var/lib/mongodb
28
29 echo "$(xfs_admin -u /dev/vg_core/lv_mongologs | sed "s/ //g") /var/log/mongologs xfs defaults,noatime 0 0" >> /etc/fstab
30 echo "$(xfs_admin -u /dev/vg_core/lv_mongodb | sed "s/ //g") /var/lib/mongodb xfs defaults,noatime 0 0" >> /etc/fstab
31
32 mount -a
33
34
35 # add some space to lv_mongologs
36
37 lvextend -L +10G /dev/vg_core/lv_mongologs
38
39 xfs_growfs /dev/vg_core/lv_mongologs
40
41
42 # use rest of space (previously was 50%) for lv_mongo
43
44 lvextend -l +100%FREE /dev/vg_core/lv_mongodb
45
46 xfs_growfs /dev/vg_core/lv_mongodb
47
48
49 # add disk and use it all
50
51 pvcreate /dev/sde1
52
53 vgextend /dev/vg_core /dev/sde1
54
55 lvextend -l +100%FREE /dev/vg_core/lv_mongodb
56
57 xfs_growfs /dev/vg_core/lv_mongodb
58
59 wget https://linux.azure.david.betz.space/raw/lvm-xfs/repair.sh -O /root/repair.sh
60 chmod +x /root/repair.sh
61
62 wget https://linux.azure.david.betz.space/raw/lvm-xfs/backup-restore.sh -O /root/backup-restore.sh
63 chmod +x /root/backup-restore.sh
64