btrfs/install.sh

raw link view readme
1 parted -s /dev/sdb mklabel gpt
2 parted -s /dev/sdb mkpart primary 1MiB 100%
3
4 partprobe
5
6
7 # Natural LVM
8
9 mkdir /var/log/mongologs
10 mkfs.btrfs /dev/sdb1
11
12 #+ cow disabled for /var/log/mongologs
13 echo "`blkid | grep sdb1 | awk '{ print $2 }'` /var/log/mongologs btrfs defaults,nodatacow 0 0" >> /etc/fstab
14
15 mount /var/log/mongologs
16
17 dd if=/dev/zero of=/var/log/mongologs/big-file.whatever bs=1M count=1024
18
19 btrfs device add /dev/sdc /var/log/mongologs
20 # VIEW DISTRIBUTION BEFORE AND AFTER BALANCE WITH: btrfs filesystem show /var/log/mongologs
21 btrfs balance start -d -m /var/log/mongologs
22
23
24 # RAID
25
26 mkdir /var/lib/mongodb
27
28 mkfs.btrfs -m raid1 -d raid1 /dev/sdd /dev/sde
29
30 # NOTE: it's sdd, not sdd1
31 echo "`blkid | grep sdd | awk '{ print $2 }'` /var/lib/mongodb btrfs defaults,noatime 0 0" >> /etc/fstab
32
33 mount /var/lib/mongodb
34
35
36 #+ disable cow on one file
37 touch /var/lib/mongodb/some-random-file.txt
38 sudo chattr -C /var/lib/mongodb/some-random-file.txt
39
40
41 wget https://linux.azure.david.betz.space/raw/btrfs/repair.sh -O /root/repair.sh
42 chmod +x /root/repair.sh
43