0

So, I started getting filesystem errors on my 4-drive btrfs RAID10 array, and btrfsck is unsuccessful in repairing them (goes into an infinite loop producing the same output for days on end).

The great majority of the data is still readable, so rebuilding the filesystem seems to be the most sensible way forward.

Given that there are no spare drives on hand, the plan so far looks like something along the lines of:

  1. Drop redundancy and "convert" RAID10 to RAID0, freeing up two drives;
  2. Format the newly-freed drives anew;
  3. Copy over readable data from the old filesystem to the new one (rsync / btrfs send | btrfs receive);
  4. Nuke the old filesystem;
  5. Add the old drives to and rebalance the new filesystem, getting it back to RAID10.

The question is how to do the first step. As I understand, btrfs device delete is not suitable here because it will keep trying to satisfy the RAID1 profile. And, how to find which two drives can be removed to minimize the amount of data shuffling it will need to do?

2

To convert from RAID10 to RAID0:

  1. Run man btrfs-balance to become familiar with the command that will do the bulk of the work. There are some kernel-version-specific caveats, and also caveats related to whether you're using mixed chunks or not.
  2. Use btrfs balance start -mconvert=raid0 -dconvert=raid0 /path to convert the filesystem's meta-data and data (system chunks will convert too). As the manual states, stripping conversions require a lot of free space on each drive, so you may want to convert the meta-data and data separately.
  3. Use btrfs device delete /dev/somedevice to remove the device(s) in question.

As for identifying which drives to remove based on usage, you can use btrfs fi usage /path

  • Welp, this worked all the way until the balance crashed due to the filesystem being, you know, corrupted. Perhaps I'll need to skip step 1 and continue with copying from a degraded filesystem. Thanks for the tip with fi usage! – Vladimir Panteleev Jul 22 '18 at 0:32
  • Oh, I thought btrfs fi usage /path was some command I didn't know about which showed how and on which devices a file's data is stored. As it is, fi usage does not provide any enlightenment as to which devices can be removed - all devices show up in the same way. – Vladimir Panteleev Jul 24 '18 at 15:59

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.