Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I currently have a 500GB x5 RAID-5 array in Fedora Linux using mdadm. One of the disks went bad and I'm going to move all the disks and data to a new array. However can I reduce the size of the array in the mean time down to 4 disks to prevent the unthinkable of another disk failing? I'd need to do it without re-creating the array because I currently have no storage space large enough to hold the data.

share|improve this question
5  
Backup - RAID is not an alternative to backups ^^ –  Oskar Duveborn Nov 30 '09 at 2:50

3 Answers 3

No, you can't decrease the number of devices in a RAID array using mdadm.

From mdadm(8):

GROW MODE

The GROW mode is used for changing the size or shape of an active array. For this to work, the kernel must support the necessary change. Various types of growth are being added during 2.6 development, including restructuring a raid5 array to have more active devices.

Currently the only support available is to

[...]

  • increase the "raid-devices" attribute of RAID1, RAID5, and RAID6.

Verify your backups are OK, then rebuild the array from scratch with the appropriate number of disks and restore from backup onto the array.

share|improve this answer

As womble said, you can't drop a disk and shrink a RAID.

There are probably some things you should know about RAID. First, RAID 5 is no longer considered a good practice for large drives or large arrays. The reason is that the liklihood of a read error from one of the drives when replacing a failed drive becomes a lot closer to 1:1 with the larger / more numerous drives. Best practices are now RAID 6, which provides two parity drives, or RAID 10, which gives better performance, but slightly less fault tolerance (you can lose 2 drives in some circumstances). Also, when you're building decently-sized arrays, you might consider adding a hot spare that automatically swaps in for a failed member without your intervention.

Of course, that doesn't get you your data. Assuming you've got a 5x500GB array, you've got around 2TB of usable space. If you have backups, then you really need to recover from those after recreating the array.

Since it sounds like you don't have backups, first, good luck. Second, it's time to get some sort of secondary storage post haste. I would recommend an external 2TB drive. They're running around $160 on pricewatch.com. If for whatever reason you can't do that, try to logically break it up and dispatch it to several other machines while you rebuild the array.

You probably want to hurry.

share|improve this answer
    
Actually it's possible to shrink RAID5 nowadays. The answers here almost convinced me to not even try it. But it works "mdadm /dev/md0 --grow --raid-devices=4" –  rudimeier Aug 6 at 14:33

From the other answers it seems clear that you can't just 'shrink' the raid. However, I feel that one of the points of RAID5 when using it for redundancy is that you can just slot out the faulty disk and slot in a new one? I don't think you have to rebuild the whole array...

I'm fairly sure, but test this on your own lab network first, use this at your own risk, don't use this in a production environment without having tested and validated it according to your preferred validation procedures first, etc ... :

See the current status of the array, let's say it's /dev/md0:

sudo mdadm --detail /dev/md0

... shows you the current status of the array, each device etc.

Set the old drive faulty and remove it from the array. Let's say the faulty drive is /dev/sdg:

sudo mdadm --set-faulty /dev/md0 /dev/sdg
sudo mdadm --remove /dev/md0 /dev/sdg

At this point, if you do sudo mdadm --detail /dev/md0 , you should see that that drive has been removed from the array.

Shut down the computer, swap out the old drive, plug in the new one, start up the computer.

Start up the array with the drive missing. Let's say the other devices were /dev/sdf and /dev/sdh, so:

sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdf missing /dev/sdh

... replacing the missing device name with the word 'missing'.

The array should start up. Now add in the new device/disk. Let's say the new disk is /dev/sdg again:

sudo mdadm --add /dev/md0 /dev/sdg

mdadm should add the new device to the array, and start rebuilding the array onto it.

You can check by doing:

sudo mdadm --detail /dev/md0
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.