Balance Filters

From btrfs Wiki
Revision as of 11:38, 7 May 2012 by Kdave (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

From kernel 3.3 onwards, btrfs balance can limit its action to a subset of the full filesystem, and can be used to change the replication configuration (e.g. moving data from single to RAID-1). This functionality is accessed through the -d, -m or -s options to btrfs balance start, which filter on data, metadata and system blocks respectively.

A filter has the following stucture:

type=params[,type=...]

The available types are:

profiles
Balances only block groups with the given replication profiles. Parameters are a list of profile names separated by |.
usage
Balances only block groups with usage under(?) the given size. Not certain about this
devid
Balances only block groups which have at least one chunk on the given device (by btrfs device ID -- use btrfs fi show to list device IDs)
drange
Balances only block groups which overlap with the given byte range on any device. (Use in conjunction with "devid" to filter on a specific device). The parameter is a range specified as start..end
vrange
Balances only block groups which overlap with the given byte range in the filesystem's internal virtual address space. This is the address space that most reports from btrfs in the kernel log use. The parameter is a range specified as start..end
convert
Convert each selected block group to the given profile name.
soft
(?) Takes no parameters.

Profile names, used in profiles and convert are one of: raid0, raid1, raid10, dup, single.

Examples

Convert data to raid1 after mkfs with defaults

You want to increase redundancy for data as well, with at least 2 devices you can do:

$ mkfs.btrfs /dev/sda1 /dev/sdb1
$ mount /dev/sda1 /mnt
[...]
$ btrfs fi df /mnt

output:

Data, RAID0: total=265.43GiB, used=242.94GiB
System, RAID1: total=32.00MiB, used=48.00KiB
Metadata, RAID1: total=14.00GiB, used=12.27GiB
$ btrfs fi balance start -dconvert=raid1 /mnt
$ btrfs fi df /mnt

output:

Data, RAID1: total=265.43GiB, used=242.94GiB
System, RAID1: total=32.00MiB, used=48.00KiB
Metadata, RAID1: total=14.00GiB, used=12.27GiB
Personal tools