Remove drive from soft RAID
You've got a three-way mirror there: each drive has a complete copy of all data. Assuming the drive you want to remove is /dev/sdc
, and you want to remove it from all three arrays, you'd perform the following steps for /dev/sdc1
, /dev/sdc2
, and /dev/sdc4
.
Step 1: Remove the drive from the array. You can't remove an active device from an array, so you need to mark it as failed first.
mdadm /dev/md1 --fail /dev/sdc1
mdadm /dev/md1 --remove /dev/sdc1
Step 2: Erase the RAID metadata so the kernel won't try to re-add it:
wipefs -a /dev/sdc1
Step 3: Shrink the array so it's only a two-way mirror, not a three-way mirror with a missing drive:
mdadm --grow /dev/md1 --raid-devices=2
You may need to remove the write-intent bitmap from /dev/md4
before shrinking it (the manual isn't clear on this), in which case you'd do so just before step 3 with mdadm --grow /dev/md4 --bitmap=none
, then put it back afterwards with mdadm --grow /dev/md4 --bitmap=internal
.
Related videos on Youtube
Raul
Updated on September 18, 2022Comments
-
Raul over 1 year
I have a dedicated server with 3 SSD drives in RAID 1. Output of
cat /proc/mdstat
:Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] md4 : active raid1 sdc4[2] sdb4[1] sda4[0] 106738624 blocks [3/3] [UUU] bitmap: 0/1 pages [0KB], 65536KB chunk md2 : active raid1 sdc2[2] sda2[0] sdb2[1] 5497792 blocks [3/3] [UUU] md1 : active raid1 sda1[0] sdc1[2] sdb1[1] 259008 blocks [3/3] [UUU] unused devices: <none>
¿How can a drive be safely removed from the soft raid without loosing any data? I would like to remove a drive from the array in order to reformat it and use it independently, while keeping the most important data mirrored.
-
Nobody over 6 yearsDoes this preserve the data on the disk which you remove? I.e. can you afterwards access the data which was on the RAID from the separate disk too?
-
Mark over 6 years@Nobody, if you want to read the data off the removed drive, you should skip step 2. Virtually all the data is still there after running
wipefs
(it only erases a few key bytes required for filesystem recognition), but reading it becomes an exercise in data recovery rather than just a matter of plugging the drive in.