master
md 75 lines 3.18 KB
Rendered Raw
1 ### Understand the alert
2
3 The `btrfs_system` alert monitors the percentage of used Btrfs system space. If you receive this alert, it means that your Btrfs system space usage has reached a critical level and could potentially cause issues on your system.
4
5 ### Troubleshoot the alert
6
7 **Important**: Data is priceless. Before you perform any action, make sure that you have taken any necessary backup steps. Netdata is not liable for any loss or corruption of any data, database, or software.
8
9 1. Add more physical space
10
11 Adding a new disk always depends on your infrastructure, disk RAID configuration, encryption, etc. To add a new disk to a filesystem:
12
13 - Determine which disk you want to add and in which path:
14 ```
15 root@netdata~ # btrfs device add -f /dev/<new_disk> <path>
16 ```
17 - If you get an error that the drive is already mounted, you might have to unmount:
18 ```
19 root@netdata~ # btrfs device add -f /dev/<new_disk> <path>
20 ```
21 - See the newly added disk:
22 ```
23 root@netdata~ # btrfs filesystem show
24 Label: none uuid: d6b9d7bc-5978-2677-ac2e-0e68204b2c7b
25 Total devices 2 FS bytes used 192.00KiB
26 devid 1 size 10.01GiB used 536.00MiB path /dev/sda1
27 devid 2 size 10.01GiB used 0.00B path /dev/sdb
28 ```
29 - Balance the system to make use of the new drive:
30 ```
31 root@netdata~ # btrfs filesystem balance <path>
32 ```
33
34 2. Delete snapshots
35
36 You can identify and delete snapshots that you no longer need.
37
38 - Find the snapshots for a specific path:
39 ```
40 root@netdata~ # sudo btrfs subvolume list -s <path>
41 ```
42 - Delete a snapshot that you do not need any more:
43 ```
44 root@netdata~ # btrfs subvolume delete <path>/@some_dir-snapshot-test
45 ```
46
47 3. Enable a compression mechanism
48
49 - Apply compression to existing files. This command will re-compress the `mount/point` path, with the `zstd` compression algorithm:
50 ```
51 root@netdata # btrfs filesystem defragment -r -v -czstd /mount/point
52 ```
53
54 4. Enable a deduplication mechanism
55
56 Tools dedicated to deduplicate a Btrfs formatted partition include duperemove, bees, and dduper. These projects are 3rd party, and it is strongly suggested that you check their status before you decide to use them.
57
58 - [duperemove](https://github.com/markfasheh/duperemove)
59 - [bees](https://github.com/Zygo/bees)
60 - [dduper](https://github.com/lakshmipathi/dduper)
61
62 5. Perform a balance
63
64 Especially in a Btrfs with multiple disks, data/metadata might be unevenly allocated into the disks.
65
66 ```
67 root@netdata # btrfs balance start -musage=10 -dusage=10 -susage=50 /mount/point
68 ```
69
70 > This command will attempt to relocate data/metdata/system-data in empty or near-empty chunks (at most X% used, in this example), allowing the space to be reclaimed and reassigned between data and metadata. If the balance command ends with "Done, had to relocate 0 out of XX chunks", then you need to increase the "dusage/musage" percentage parameter until at least some chunks are relocated.
71
72 ### Useful resources
73
74 1. [The Btrfs filesystem on Arch Linux website](https://wiki.archlinux.org/title/btrfs)
75 2. [The Btrfs filesystem on kernel.org website](https://btrfs.wiki.kernel.org)