meta data for this page
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
linux:fs:btrfs:maintenance [2020/06/02 19:34] – created niziak | linux:fs:btrfs:maintenance [2025/01/03 07:52] (current) – niziak | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== BTRFS Maintenance scripts ====== | ====== BTRFS Maintenance scripts ====== | ||
+ | ===== btrfsmaintenance ===== | ||
+ | <code bash> | ||
+ | apt install btrfsmaintenance | ||
+ | </ | ||
+ | |||
+ | <file sh / | ||
+ | BTRFS_TRIM_PERIOD=" | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | systemctl restart btrfsmaintenance-refresh | ||
+ | |||
+ | #systemctl enable btrfs-scrub.timer btrfs-trim.timer | ||
+ | #systemctl start btrfs-trim.service | ||
+ | #systemctl start btrfs-scrub.service | ||
+ | </ | ||
+ | ===== Defragment ===== | ||
+ | From [[https:// | ||
+ | |||
+ | Find the most fragmented files on your System: | ||
+ | |||
+ | <code bash> | ||
+ | find / -xdev -type f| xargs filefrag 2>/ | ||
+ | </ | ||
+ | |||
+ | You should review this list. If there is something with 10000+ extends, it is a candidate to be flagged as nodatacow. In my case, I have discovered that the fail2ban sqlite database was using 170k extends which is a lot! | ||
+ | |||
+ | <code bash> | ||
+ | find / -xdev -type f| xargs filefrag 2>/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Headline ===== | ||
+ | |||
+ | <file bash / | ||
+ | #!/bin/bash | ||
+ | [[ ! -d $1 ]] && { echo Please pass mountpoint as first argument >&2 ; | ||
+ | exit 1 ; } | ||
+ | |||
+ | while read x i x g x x l x p | ||
+ | do | ||
+ | volName[i]=$p | ||
+ | done < <(btrfs subvolume list $1) | ||
+ | |||
+ | while read g r e | ||
+ | do | ||
+ | [[ -z $name ]] && echo -e " | ||
+ | group=${g## | ||
+ | [[ ! -z ${volName[group]} ]] && name=${volName[group]} || name=' | ||
+ | echo $name $g `numfmt --to=iec $r` `numfmt --to=iec $e` | ||
+ | done < <(btrfs qgroup show --raw $1 | tail -n+3) | column -t | ||
+ | </ | ||
Line 8: | Line 60: | ||
To solve '' | To solve '' | ||
- | <file bash / | + | <file bash / |
#!/bin/bash | #!/bin/bash | ||
Line 29: | Line 81: | ||
<file cron crontab> | <file cron crontab> | ||
- | @daily / | + | @daily / |
</ | </ | ||