Btrfs

From PvdMWiki
Jump to: navigation, search
  • list available devices
btrfs device scan
  • list available filesystems
btrfs filesystem show
  • create volume
mkfs.btrfs /dev/sdX
  • stripe across devices (mirror metadata + stripe data)
mkfs.btrfs /dev/sda /dev/sdb /dev/sdc
  • stripe across devices (stripe metadata + stripe data)
mkfs.btrfs -m raid0 /dev/sda /dev/sdb /dev/sdc
  • mirror across devices (mirror metadata + mirror data)
mkfs.btrfs -m raid10 -d raid10 /dev/sda /dev/sdb /dev/sdc
  • create subvolume
btrfs subvolume create /mnt/nonsense

where /mnt is the mountpoint of the btrfs volume

  • list subvolumes
btrfs subvolume list /mnt 
  • create snapshot
mkdir /mnt/snapshots
btrfs subvolume snapshot /mnt/nonsense /mnt/snapshots/vrijdag
  • add a new device
btrfs device add /dev/sda8 /mnt
  • remove a device
btrfs delete /dev/sdb /mnt
  • free space:
btrfs fi df /
  • show snapshots
snapper list
  • delete all snapshots
for i in {1..20000}; do snapper delete $i; done

2015:

  • balance om ruimte vrij te maken:
btrfs balance start /tmp/bla

als geen ruimte vrij:

btrfs balance start -musage=50 -dusage=50 /tmp/bla
btrfs fi show /tmp/bla
btrfs fi df /tmp/bla

Onderhoud:

btrfs scrub is used to scrub a btrfs filesystem, which will read all data and metadata blocks from all devices and verify checksums. Automatically repair corrupted blocks if there’s a correct copy available.

btrfs scrub start -B /tmp/bla
fstrim /tmp/bla


for conventiaonal HD's:

btrfs filesystem defragment /tmp/mnt/bla

recursief een directory:

btrfs filesystem defragment -r /tmp/mnt/bla