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:
The available types are:
- Balances only block groups with the given replication profiles. Parameters are a list of profile names separated by |.
- Balances only block groups with usage under the given percentage.
- 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)
- 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
- 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 each selected block group to the given profile name.
- 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
- 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.
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
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
Data, RAID1: total=265.43GiB, used=242.94GiB System, RAID1: total=32.00MiB, used=48.00KiB Metadata, RAID1: total=14.00GiB, used=12.27GiB