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