0

Can someone explain to me the steps i have to take to replace a disk in a raid5 btrfs stetup? I' have a setup with 8*3tb disks and one disk displays smart errors. I have a replacement disk of the same size but want to know how i can safely replace the broken disk

1

First step is removing the drive with errors simply by typing:

sudo btrfs device remove /dev/sdX /mnt/YYYYYY

where X is drive which we want to remove and YYY is path. It will take some time because btrfs utility will try to read all data from disk and place them somewhere else safely. After this command you can disconnect disk and connect new one. Adding new disk is done by:

sudo btrfs device add /dev/sdX /mnt/YYYYYY

Also after this commands it is recommended to do balancing:

sudo btrfs balance start /dev/sdX /mnt/YYYYYY

That's all. This is safest way to change disks. There is more dangerous way but it will save time. I don't recommend this but you can disconnect the disk immediately and after booting remove missing information of disconnected disk:

sudo btrfs device remove missing /mnt/YYYYYY

And then add disk and rebalance.

  • How about adding a new disk first, then removing the old one? In a case where there's so much data it wouldn't fit into N-1 disks, working (temporarily) with N+1 disks seems the right way. What are the reasons (if any) to prefer removing first? – Kamil Maciorowski Oct 6 '17 at 5:49
  • I think removing and rebuilding is the standard way of doingf it – Journeyman Geek Oct 6 '17 at 5:58
  • I don't know about BTRFS, but RAID 5 implies one disk's worth of redundancy... Is it necessary to "move data somewhere else"? – Attie Oct 18 '17 at 20:59
0

You can't use the btrfs remove command in this case because there would be only two devices remaining and you need at least three for RAID5. So there are two options:

  1. Use the replace command.
  2. Add the new drive first and then remove the old drive.

To replace the drive run this:

sudo btrfs replace start -B /dev/old_drive /dev/new_drive /mnt/YYYYYY

The -B flag makes the command run in the foreground. See the man page for details https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-replace

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.