13

I'm using Ubuntu 10.04 and have the /home directory setup as a BTRFS RAID 1 with two 2TB drives.

I'd like to make the /home directory just a single drive; how do I safely go about doing this?

Jamie
  • 1,274
  • 7
  • 22
  • 39

2 Answers2

15

Update: December 2020

The functionality of btrfs continues to evolve over time. The delete command is now an alias for the remove command which produces different results. Today, you would run the following commands:

btrfs balance start -f -sconvert=single -mconvert=single -dconvert=single <mount>
btrfs device remove <drive> <mount>

The first command converts all data from a mirrored setup to a single-copy setup. This effectively makes the RAID1 into a JBOD setup. The -f option is required to tell the filesystem to really reduce the resiliency of the data.

Once this completes, the second command removes the device from the JBOD. The filesystem will move any data from the removed device to the other device.

Original Answer

According to this btrfs wiki, you remove a device from a btrfs RAID, by issuing the command:

btrfs device delete <drive> <mount>

This is an online command, so for you, it would be (while /home is mounted):

btrfs device delete <drive> /home
hrunting
  • 943
  • 4
  • 7
  • I don't have "`btrfs`". I've got: `btrfsck`, `btrfs-convert`, `btrfsctl`, `btrfs-debug-tree`, `btrfs-image`, `btrfs-show`, `btrfstune`, and `btrfs-vol`. I'll have to dig a bit. – Jamie Feb 07 '13 at 02:30
  • 1
    You're going to want to use `btrfs-vol -r /home` then, I think. I'm not sure if that can be done online or not. – hrunting Feb 07 '13 at 02:38
  • as of 2020, there is no command `btrfs device delete` , and the command `btrfs device remove` will not convert raid1 to raid0 – am70 Dec 19 '20 at 11:14
  • @am70 Thanks for the comment. I provided an updated answer. – hrunting Dec 21 '20 at 01:28
  • 3
    WARNING: This procedure is NOT for removing a failing hdd from a btrfs RAID1 with two drives, you may loose your data. – Fravadona Apr 09 '21 at 08:56
  • 1
    I would recommend `btrfs balance start -f -sconvert=dup -mconvert=dup -dconvert=single ` – am70 Mar 14 '22 at 09:05
  • @hrunting I just posted a similar question. Maybe you could elaborate on what to do when you a have a RAID6 array? https://serverfault.com/q/1100148/77770 – Nathan May 04 '22 at 14:28
  • @Nathan You cannot turn an individual drive in a RAID6 array into a standalone device and expect to do much with the data. The reason it works in the RAID1 setup above is that each drive in the RAID contains a copy of the data. In a RAID6 setup, the drives each contain only part of the data. The data is also chunked, so its representation on disk is not the same as it would be if it was a non-RAID filesystem. – hrunting May 17 '22 at 16:38
2

Thank you for the update @hrunting!

However the re-balance using "single" profile did not work for me on Ubuntu 20.04.2 LTS. I needed:

btrfs balance start -dconvert=raid0 -mconvert=raid0 -sconvert=raid0 -f <mount>
btrfs device remove <dev/partition> <mount>

to get rid of pesky RAID1 metadata/system and allow removal.

And as always, folks: back up your data to an independent physical media before attempting these - there's a good chance you will lose it all in this evolution. I am a big fan of:

 btrfs send -f <bkupFile> <subvol>
 btrfs receive -f <bkupFile> <newsubvol>
Frobozz
  • 163
  • 8