2021-01-07 11:04:21 +00:00
|
|
|
# btrfs filesystem
|
|
|
|
|
|
|
|
> Manage btrfs filesystems.
|
2022-11-15 11:50:15 +00:00
|
|
|
> More information: <https://btrfs.readthedocs.io/en/latest/btrfs-filesystem.html>.
|
2021-01-07 11:04:21 +00:00
|
|
|
|
|
|
|
- Show filesystem usage (optionally run as root to show detailed information):
|
|
|
|
|
2025-07-20 01:28:02 +03:00
|
|
|
`btrfs {{[f|filesystem]}} {{[u|usage]}} {{path/to/btrfs_mount}}`
|
2021-01-07 11:04:21 +00:00
|
|
|
|
|
|
|
- Show usage by individual devices:
|
|
|
|
|
2025-07-20 01:28:02 +03:00
|
|
|
`sudo btrfs {{[f|filesystem]}} {{[sh|show]}} {{path/to/btrfs_mount}}`
|
2021-01-07 11:04:21 +00:00
|
|
|
|
2021-01-25 01:42:06 +00:00
|
|
|
- Defragment a single file on a btrfs filesystem (avoid while a deduplication agent is running):
|
2021-01-07 11:04:21 +00:00
|
|
|
|
2025-07-20 01:28:02 +03:00
|
|
|
`sudo btrfs {{[f|filesystem]}} {{[de|defragment]}} {{[-v|--verbose]}} {{path/to/file}}`
|
2021-01-07 11:04:21 +00:00
|
|
|
|
|
|
|
- Defragment a directory recursively (does not cross subvolume boundaries):
|
|
|
|
|
2025-07-20 01:28:02 +03:00
|
|
|
`sudo btrfs {{[f|filesystem]}} {{[de|defragment]}} {{[-v|--verbose]}} -r {{path/to/directory}}`
|
2021-01-07 11:04:21 +00:00
|
|
|
|
|
|
|
- Force syncing unwritten data blocks to disk(s):
|
|
|
|
|
2025-07-20 01:28:02 +03:00
|
|
|
`sudo btrfs {{[f|filesystem]}} {{[sy|sync]}} {{path/to/btrfs_mount}}`
|
2021-01-07 11:04:21 +00:00
|
|
|
|
|
|
|
- Summarize disk usage for the files in a directory recursively:
|
|
|
|
|
2025-07-20 01:28:02 +03:00
|
|
|
`sudo btrfs {{[f|filesystem]}} du {{[-s|--summarize]}} {{path/to/directory}}`
|
2025-05-16 20:24:49 +03:00
|
|
|
|
|
|
|
- Create a swap file:
|
|
|
|
|
2025-07-20 01:28:02 +03:00
|
|
|
`sudo btrfs {{[f|filesystem]}} {{[m|mkswapfile]}} --size {{8g}} --uuid {{clear|random|time|UUID_value}} {{path/to/swapfile}}`
|