btrfs/install.sh

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