Create read-only snapshot:
btrfs sub snap -r /path/to/source /path/to/target
Create writable snapshot:
btrfs sub snap /path/to/source /path/to/target
Push snapshot to another host:
btrfs send /path/to/snapshot | pv | ssh root@srv01.example.com "btrfs receive /path/to/snapshot"
Pull snapshot from another host:
ssh root@srv01.example.com "btrfs send /path/to/snapshot" | pv | btrfs receive /path/to/snapshot
Btrfs quota may require a lot of performance (depending on the number of files and snapshots) and should therefore be deactivated.
Enable:
btrfs quota enable /
Show:
btrfs qgroup show /
Disable:
btrfs quota disable /
If you delete a subvolume with btrfs sub delete
, you should not reboot the system until the subvolume is really gone.
You can check this with the btrfs sub sync
command.
$ btrfs sub sync /
Subvolume id 276 is gone
Disabling or enabling COW only works on 0 byte sized files.
Turn COW on files and folder:
- Off:
chattr +C file
- On:
chattr -C file
See if COW is on or off:
- For files:
lsattr filename
- For directorys:
lsattr -d directory
Set to read-only:
btrfs property set -ts /path/to/subvolume ro true
Disable read-only:
btrfs property set -ts /path/to/subvolume ro false
btrfs-cleaner
: A possible cause for a high disk I/O load are deleted or created snapshots and the recalculation of btrfs quota. Source: spinics.netbtrfs-transacti
Kernel threads (kworker
) are shown in htop
witch shift-k:
btrfs-endio-write
btrfs-endio-meta
btrfs-worker
By nature of its algorithm, btdu works correctly with compression and other btrfs filesystem features
https://github.com/CyberShadow/btdu
This tool can show you what folders have the most changed data between snapshots
https://github.com/rkapl/btsdu
apt install -y cargo
cargo install btsdu
~/.cargo/bin/btsdu -p /snapshot/20201126-0357-day /snapshot/20201127-0357-day
Nspawn will create a snapshot, chroot into it, and delete it on exit. Works for xfs and btrfs.
https://www.reddit.com/r/linux/comments/ncw7xc/btrfs_use_cases/gy88mnc/
systemd-nspawn -x -D /
compsize takes a list of files on a btrfs filesystem and measures used compression types and effective compression ratio, producing a report
https://github.com/kilobyte/compsize
Install:
apt-get -y install btrfs-compsize
Or make:
git clone https://github.com/kilobyte/compsize.git
cd compsize
make
Use:
compsize /path/to/file