Checking a system, I found a server with 12 4TB drives in Raid5, with LVM on top. Single VG, single PV, and a few LGs that wouldn't need more than 6TB of space (currently only 4TB). Read speed is no issue so I'd like to reduce the raid to only 5 disks + 1 spare. It's not expected to grow much in the next few years.

Have anyone had experience reducing arrays that sit under LVM?

Yes, I will backup first, but I'd like to know if there is a safe and secure way to do it.

The steps I assume are:

  • resize (reduce) the fs of the LVs
  • reduce the LVs
  • move the extents (pvmove) to the beginning of the VG
  • fail-remove one disk from RAID5
  • pvresize --setphysicalvolumesize=new_smaller_size
  • reduce (mdadm --grow /dev/md0 --raid-devices=n-1..) the array (let's hope it cuts only the tail)
  • .... repeat for next disk.

I'd like to hear your opinions.

PS: Yes, I know that backing up, rebuilding and loading the backup might be faster and easier, but I want to learn... have some experience if I ever face a situation where backing up is unfeasible.

  • Linux RAID is cool but it's totally capable of sending you into the desert as well. Shrinking in particular... tried it just now and the reshape process got stuck. Go with the faster, easier, and so much safer route. – frostschutz Feb 9 at 3:37
  • 1
    If you want to attempt it anyway... do not fail-remove a disk. Do not --force. Go with RAID6 instead of RAID5+spare. Don't use old version of mdadm. Try to grow directly into the desired final form without repeated intermediate steps. Good luck. – frostschutz Feb 9 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.