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
First step is removing the drive with errors simply by typing:
sudo btrfs device remove /dev/sdX /mnt/YYYYYY
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.
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:
- Use the replace command.
- 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