Btrfs Cheat Sheet ๐
Welcome to the Btrfs Cheat Sheet! This guide is designed to provide you with quick access to the most common Btrfs commands and best practices. Btrfs (B-tree file system) is powerful and versatile, perfect for managing modern storage architectures. ๐
Table of Contents ๐
- Creating Subvolumes
- Snapshots
- Restoring Snapshots
- Balancing
- Checking and Repairing
- Usage and Quotas
- Defragmentation
- Miscellaneous Commands
Creating Subvolumes ๐
Subvolumes are like dynamically resizable partitions of the filesystem.
Create a subvolume:
sudo btrfs subvolume create /path/to/new_subvolume
List all subvolumes:
sudo btrfs subvolume list /
Snapshots ๐ธ
Snapshots are read-only copies of subvolumes at a particular point in time.
Create a snapshot:
sudo btrfs subvolume snapshot /path/to/subvolume /path/to/snapshot
Delete a snapshot:
sudo btrfs subvolume delete /path/to/snapshot
Restoring Snapshots โณ
You can revert to any previous state captured by a snapshot.
Revert changes using a snapshot:
sudo snapper -c root undochange snapshot_number..current
Balancing ๐
Balancing helps to optimize the distribution of data across the filesystem.
Start a balance operation:
sudo btrfs balance start /
Checking and Repairing ๐ ๐ฉน
Ensure the integrity of your filesystem with these commands.
Check the filesystem (without making changes):
sudo btrfs check /dev/deviceName
Repair the filesystem:
sudo btrfs check --repair /dev/deviceName
Usage and Quotas ๐พ
Manage disk space effectively with quotas and usage insights.
Show disk usage:
sudo btrfs filesystem df /
Enable quotas:
sudo btrfs quota enable /
Defragmentation ๐งน
Improves performance by organizing data more efficiently (not recommended for SSDs).
Defragment a directory:
sudo btrfs filesystem defragment /path/to/directory
Miscellaneous Commands ๐งฐ
Some additional commands that are useful for day-to-day management.
Show filesystem information:
sudo btrfs filesystem show
Resize a subvolume:
sudo btrfs filesystem resize max /path/to/subvolume
Thank you for using this Btrfs Cheat Sheet! Remember to back up your data regularly and test any major changes in a safe environment. ๐