btrfs
Here’s a clean Markdown version of your document:
# Btrfs Management
## File System Management
| Command | Command | Description Description | |
|---------|-------------|
|
`mkfs.btrfs /dev/sdX` | | Create a new Btrfs filesystem |
|
| | `mount /dev/sdX /mnt` | | Mount Btrfs filesystem |
|
| | `umount /mnt` | | Unmount filesystem |
|
| | `btrfs filesystem show` | | Show Btrfs filesystems |
|
| | `btrfs filesystem df /mnt` | | Show space usage |
|
| | `btrfs filesystem usage /mnt` | | Detailed space usage |
|
---
##
RAID Management
| Command | Command | Description Description | |
|---------|-------------|
|
`mkfs.btrfs -d raid1 -m raid1 /dev/sdb /dev/sdc` | | Create RAID1 (mirror) |
|
| | `mkfs.btrfs -d raid0 -m raid0 /dev/sdb /dev/sdc` | | Create RAID0 (striping) |
|
| | `mkfs.btrfs -d raid10 -m raid10 /dev/sdb /dev/sdc /dev/sdd /dev/sde` | | Create RAID10 |
|
| | `btrfs device add /dev/sdd /mnt` | | Add device to filesystem |
|
| | `btrfs device remove /dev/sdc /mnt` | | Remove device from filesystem |
|
| | `btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt` | | Convert existing FS to RAID1 |
|
| | `btrfs balance start /mnt` | | Rebalance data across devices |
|
| | `btrfs device stats /mnt` | | Show device stats |
|
---
##
Subvolume Management
| Command | Command | Description Description | |
|---------|-------------|
|
`btrfs subvolume create /mnt/data` | | Create subvolume |
|
| | `btrfs subvolume list /mnt` | | List subvolumes |
|
| | `btrfs subvolume delete /mnt/data` | | Delete subvolume |
|
| | `btrfs subvolume snapshot /mnt/data /mnt/data-snap` | | Snapshot a subvolume |
|
| | `btrfs subvolume snapshot -r /mnt/data /mnt/data-ro` | | Create readonly snapshot |
|
---
##
Snapshots
Snapshots
| Command | Description Command | |
Description | |---------|-------------|
|
`btrfs subvolume snapshot /mnt/data /mnt/data-snap` | | Create snapshot |
|
| | `btrfs subvolume delete /mnt/data-snap` | | Delete snapshot |
|
| `btrfs send /mnt/data-snap (pipe)| btrfs receive /mnt/backup` | | Send snapshot to another FS |
|
---
##
Scrub & Check
| Command | Command | Description Description | |
|---------|-------------|
|
`btrfs scrub start /mnt` | | Start scrub on mounted FS |
|
| | `btrfs scrub status /mnt` | | Show scrub status |
|
| | `btrfs scrub cancel /mnt` | | Cancel scrub |
|
| | `btrfs check /dev/sdX` | | Check filesystem (offline) |
|
| | `btrfs rescue super-recover /dev/sdX` | | Try to recover superblock |
|
---
##
Resize
Resize
| Command | Description Command | |
Description | |---------|-------------|
|
`btrfs filesystem resize +10G /mnt` | | Grow FS by 10G |
|
| | `btrfs filesystem resize -5G /mnt` | | Shrink FS by 5G |
|
| | `btrfs filesystem resize max /mnt` | | Use full device size |
|
---
##
Example Workflows
### Create RAID1 (mirror) with 2 disks:
disks
```bash
mkfs.btrfs -d raid1 -m raid1 /dev/sdb /dev/sdc
mount /dev/sdb /mnt
Add new disk to pool and rebalance into RAID1:RAID1
btrfs device add /dev/sdd /mnt
btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt
Create snapshot and restore:restore
btrfs subvolume snapshot /mnt/data /mnt/data-snap
btrfs subvolume delete /mnt/data
btrfs subvolume snapshot /mnt/data-snap /mnt/data
qgroups
Qgroups
commandCommand |
descritpionDescription |
| btrfs qgroup show -re /mnt/btrfs\_volumebtrfs_volume |
shows | Shows limits of the volume |
| btrfs qgroup limit 3T /mnt/btrfs\_subvolumebtrfs_subvolume |
sets | Sets limit for this subvolume |
Mount Options
| Option |
Description |
`compress=zstd`zstd |
ZapneEnable kompresicompression (doporučené:recommended: zstd) |
`compress=lzo`lzo |
Komprese LZO compression (rychlá,fast, méněless efektivní)efficient) |
`compress-force=zstd`zstd |
VynutíForce kompresicompression všechfor datall data |
`autodefrag`autodefrag |
AutomatickáAuto defragmentacedefragmentation přion zápisuwrite |
`ssd`ssd |
OptimalizaceOptimize profor SSD (obvykleusually se detekuje automaticky)auto-detected) |
`ssd_spread`ssd_spread |
AlternativníAlternative strategieSSD zápisuwrite nastrategy |
space_cache=v2 |
Faster mount via allocation cache |
discard=async |
Asynchronous TRIM for SSD |
`space_cache=v2`noatime |
RychlejšíDisable mountaccess díkytime cache alokací (novější verze)updates |
`discard=async`nodatacow |
AsynchronníDisable TRIM pro SSDCopy-on-Write |
`noatime` |
Nezapisuje access time (lepší výkon) |
`nodatacow` |
Vypne Copy-on-Write pro daný mount/subvolume |
`subvol=` |
Mount konkrétníhospecific subvolume |
`subvolid=` |
Mount podleby subvolume ID subvolume |
Example fstab entry:
/dev/sdb /mnt btrfs defaults,compress=zstd,autodefrag,ssd,discard=async 0 0