2
  • I have a software RAID 1.
  • There is data already stored on the system.
  • I want to shrink an existing partion and then create a new one with the remaining space.
  • I'll use parted.

I'm aware I cannot partition any /dev/sd* device while it would ignore and break the RAID 1. But just to be sure ... can I partition the / dev/md* devices while they represent the RAID 1?

/dev/md0
 - /dev/sda1
 - /dev/sdb1
/dev/md1
 - /dev/sda2
 - /dev/sdb2

... and so on

My questions are:

Do I have to partition every single device of the RAID array in question or can I just partition the RAID array itself and the software RAID proxies it to the single devices?

If I have to partition any single device do I have to unRAID them first, partition them and RAID them again?

Refers: shrink a partition without losing data

0

The way I would approach this is to shrink the RAID, free up space on the underlying HDDs, and then add additional partitions with the newly freed space for incorporation into the 2nd RAID.

Shrinking high level process

In regards to shrinking the RAID so that you can free up space on the underlying HDDs so that you can repartition them, you'd do something like the steps outlined in this howto titled: How To Resize RAID Partitions (Shrink & Grow) (Software RAID) is how I've done this in the past.

For example, assuming a RAID-1 of 40G:

  • check filesystem

    $ e2fsck -f /dev/md2
    
  • shrink RAID-1's filesystem

    $ resize2fs /dev/md2 25G
    
  • shrink the RAID

    $ mdadm --grow /dev/md2 --size=31457280
    
  • now expand the filesystem to the max available in RAID

    $ resize2fs /dev/md2
    
  • check filesystem (again)

    $ e2fsck -f /dev/md2
    

At this point you should be able to use something like parted to reduce the size of the partitions and reclaim their freed up space, which can then be added to the new partitions.

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.