Balance Filters

From btrfs Wiki
Revision as of 11:46, 11 May 2012 by Ierdnah (Talk | contribs)

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 percentage.
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. Only has meaning when converting between profiles.
When doing convert from one profile to another if soft mode is on
restriper won't touch chunks that already have the profile we are
converting to. This is useful if e.g. half of the FS was converted
earlier.
The soft mode switch is (like every other filter) per-type. This means
that we can convert for example meta chunks the "hard" way while
converting data chunks selectively with soft switch.


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=409.50MB, used=0.00
Data: total=8.00MB, used=0.00
System, RAID1: total=8.00MB, used=4.00KB
System: total=4.00MB, used=0.00
Metadata, RAID1: total=204.75MB, used=24.00KB
Metadata: total=8.00MB, used=0.00
$ btrfs fi balance start -dconvert=raid1 /mnt
$ btrfs fi df /mnt

output:

Data, RAID1: total=819.12MB, used=128.00KB
System, RAID1: total=8.00MB, used=4.00KB
System: total=4.00MB, used=0.00
Metadata, RAID1: total=460.75MB, used=24.00KB
Metadata: total=8.00MB, used=0.00

For more example read this email: patch

Personal tools