6

I have a software raid configured (/dev/md2) which has assigned the partitions sda3 and sdb3 from two 3TB disks (sda and sdb). The partition types are GPT not LVM and file system is ext4. Now, the root partition is taking 1TB and the home partition (sda4 and sdb4 on raid /dev/md3) is taking 1.8TB, I wanted to resize the root partition to take only 250GB and assign the free space to the home partition, so that it ends up being 250GB for root in md2, and 2.5TB for home. For doing this, I read that using mdadm and resizing the array volume would achieve that, but the problem is that it only resized the md2 device, but the free space in sda3 and sdb3 is unused, and I have no way to assign it to sda4 and sdb4 so I can use that extra space in md3, so I have:

At the beginning:
/dev/md2 with ext4, mounting / with quota of 1000GB
    sda3: 1000GB with ext4 using the full 1000GB
    sdb3: 1000GB with ext4 using the full 1000GB

/dev/md3 with ext4, mounting /home with quota of 1800GB
    sda4: 1800GB with ext4 using the full 1800GB
    sdb4: 1800GB with ext4 using the full 1800GB

I want:
/dev/md2 with ext4, mounting / with quota of 250GB
    sda3: 250GB with ext4 using the full 250GB
    sdb3: 250GB with ext4 using the full 250GB

/dev/md3 with ext4, mounting /home with quota of 2550GB
    sda4: 2550GB with ext4 using the full 2550GB
    sdb4: 2550GB with ext4 using the full 2550GB

And ended up with:
/dev/md2 with ext4, mounting / with quota of 250GB
    sda3: 1000GB with ext4 using only 250GB
    sdb3: 1000GB with ext4 using only 250GB

/dev/md3 with ext4, mounting /home with quota of 1800GB
    sda4: 1800GB with ext4 using the full 1800GB
    sdb4: 1800GB with ext4 using the full 1800GB

To achieve this, I followed the instructions in this website: http://www.howtoforge.com/how-to-resize-raid-partitions-shrink-and-grow-software-raid

So, I restarted in rescue mode, and ran the following commands as root:

#configure everything to edit the raid devices
modprobe linear
modprobe multipath
modprobe raid0
modprobe raid1
modprobe raid5
modprobe raid6
modprobe raid10
cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
mdadm --examine --scan >> /etc/mdadm/mdadm.conf
mdadm -A --scan

### Shrink md2 from 1000GB to 250GB
#check the raid disk
e2fsck -f /dev/md2
#resize the file system from 1000GB to 245GB to leave room for the partition to shrink without issues
resize2fs /dev/md2 245G
#resize the partition from 1000GB to 250GB
mdadm --grow /dev/md2 --size=262144000
#resize the file system to fit the whole 250GB
resize2fs /dev/md2
#do a disk check again
e2fsck -f /dev/md2

### Grow md3 to include md2 750GB free space
#grow md3 to the max free space
mdadm --grow /dev/md3 --size=max
#run a disk check
e2fsck -f /dev/md3
#resize the file system
resize2fs /dev/md3
#check the file system again
e2fsck -f /dev/md3

But then it turns out that for actually achieving the resize, I need to fail and remove the partitions from the raid device, repartition each disk, add back to the raid device and sync.

So I tried instructions from this web site: http://www.zedt.eu/tech/linux/resize-grow-mdadm-raid1-device/

And also tried from this serverfault answer: How to resize two RAID-1 partitions?

I've tried doing all that, resize with parted, but nothing, parted sends errors stating that it doesn't recognize the file system of the partition, I've read somewhere else that parted doesn't support ext4 but I don't care, I already resized the file system using resize2fs, so all I need to do is resize the partition. Also on some samples, I see parted print output to print file system type and all, but when I print mine, I don't get any of that information: sda and sdb disk output:

Number  Start   End     Size    File system  Name  Flags
 5      1049kB  2097kB  1049kB                     bios_grub
 1      2097kB  12.9GB  12.9GB                     raid
 2      12.9GB  13.4GB  537MB                      raid
 3      13.4GB  1113GB  1100GB                     raid
 4      1113GB  3001GB  1888GB                     raid

As you can see, I get no info on file system or name, and I get errors if I want to resize partition 3 (sda3 and sdb3), and likewise I cannot grow partition 4 to acommodate the free space.

Can anyone help me on how can I resize my disks so that my raid devices can take the full space?

Thanks!

1

1 Answer 1

1

I had good result using this approach:

http://www.howtoforge.com/how-to-resize-raid-partitions-shrink-and-grow-software-raid

Regards

1
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. May 31, 2013 at 15:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .