IT 4100 : File Systems and Storage Technologies

BTRFS


BTRFS

What is COW

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.


BTRFS (subvolumes) (from manpage)

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 commands (viewing information)

BTRFS (formatting)

BTRFS subvolumes

BTRFS snapshots

Then if you break something, you can unmount the volume and copy over your snapshot to the old one.


BTRFS (snapper)

Utility to help manage snapshots.


BTRFS (snapper)

AWS Demo commands (after adding some volumes to ec2 instance)

    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