A COW – copy on write – filesystem is extra-careful with writing your data. When you make a change to a file, the old data are not overwritten. Instead, the filesystem allocates new blocks for the new data, and only the changed data are given a new allocation.
A subvolume is a part of filesystem with its own and independent file/directory hierarchy. Subvolumes can share file extents. A snapshot is also subvolume, but with a given initial content of the original subvolume.
Note: A subvolume in btrfs is not like an LVM logical volume, which is block-level snapshot while btrfs subvolumes are file extent-based.
A subvolume in btrfs can be accessed in two ways:
btrfs filesystem df /
btrfs device usage /
btrfs filesystem show /
btrfs subvolume list /
mkfs.btrfs -L butters /dev/sdb12
mkfs.btrfs -d raid0 -L mydata /dev/sdc /dev/sdd
btrfs subvolume create /mnt/svol
mount -o subvol=test /dev/sda21 /mnt/test
#subvol, not subvolumebtrfs subvolume snapshot /mnt/test /mnt/snap
Then if you break something, you can unmount the volume and copy over your snapshot to the old one.
cp -r mntbtrfs/snapshots/test mntbtrfs/test
and remountUtility to help manage snapshots.
snapper list-configs
, orls -l /etc/snapper/configs/
snapper -c configname create-config /path/to/subvolume
snapper -c test create-config /mnt/test
snapper -c root create-config /
snapper -c config delete-config
snapper -c config create --description foo
snapper -c config delete N
# will delete snapshot number N mkfs.btrfs -L testfs /dev/xvdf -f
mount /dev/xvdf /mnt/
df
btrfs filesystem show /mnt
cd /mnt
fallocate -l 726M garbaged
md5sum garbaged
df -h
btrfs filesystem df /mnt
btrfs device add -f /dev/xvdg /mnt
btrfs device add -f /dev/xvdh /mnt
btrfs device add -f /dev/xvdi /mnt
btrfs filesystem df /mnt
btrfs balance start /mnt
btrfs filesystem show /mnt
btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt
btrfs filesystem show /mnt
md5sum garbaged