5

Somehow I goofed creating my BTRFS filesystem and ended up with RAID0 instead of RAID1. However I only noticed this after adding 274GB of data (I know, what a moron):

Total devices 2 FS bytes used 136.12GiB
        devid    1 size 465.76GiB used 137.03GiB path /dev/sdb
        devid    2 size 465.76GiB used 137.03GiB path /dev/sdc

I would like a method of A: Confirming that this is indeed RAID0 (I'm sure it is, but I haven't found a command that outputted that explicitly, and I would like to check next time before adding data). And B: If possible, redistributing the data to RAID1.

3

When making a btrfs filesystem across multiple devices, the default is to use RAID0 for data, and RAID1 for metadata. If you want to change this you can pass arguments to the mkfs command to change RAID level of data (-d) and metadata (-m):

mkfs.btrfs -d raid1 -m raid1 /dev/sda /dev/sdb

To confirm what RAID level is being used on an existing filesystem, you can use the btrfs utility:

$ btrfs fi df /mountpoint
Data, RAID1: total=15.00GiB, used=14.65GiB
System, RAID1: total=8.00MiB, used=16.00KiB
Metadata, RAID1: total=1.00GiB, used=15.59MiB

The example output shows RAID1 used for both data and metadata. Running btrfs fi usage /mountpoint will provide more detail.

You can convert an existing filesystem to a different RAID level by passing arguments to the balance command.

btrfs balance start -dconvert=raid1 -mconvert=raid1 /mountpoint

A balance writes all data to the filesystem again, and adding arguments will cause the data to be converted as it is rewritten. This may take a while, you can run btrfs balance status /mountpoint to see the status. Once it finishes, you can confirm that all data was converted as expected with btrfs fi df. Data written during a balance may still use the old format so a second balance may be needed.

Utilities such as the regular df command or btrfs fi show do not take RAID settings into account, as that is done by btrfs itself. These tools only show the total amount allocated by btrfs on the disks, they don't know what format btrfs is using for the data. This also means sharing via SAMBA or other tools will not account for RAID. For more info, see the btrfs FAQ.

2

OK let this server as a monument to my utter failure.

To confirm RAID config: btrfs fi df /mountpoint

It turns out that I didn't goof, Windows somehow reports twice the data (and twice the space) when you connect to a btrfs RAID1 fs via SAMBA.

If you perhaps did make the error I thought I made when setting up your BTRFS filesystem then this may help, although fortunately I didn't have to try it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.