How to resize RAID1 array with mdadm?

Just use

mdadm --grow --size max /dev/md2

Then you'll be able to use

resize2fs /dev/md2

To let file system match the raid size. All of that is done online without even unmounting the md2.


From looking at /proc/partitions, it's apparent that linux thinks sda3 and sdb3 are smaller than they are.

Sum the sizes of the partitions

8       17      96358 sdb1
8       18    3903795 sdb2
8       19  152248005 sdb3

and you'll get a number much lower than the size of the disk.

8       16  488386584 sdb

152248005 blocks of 1024 bytes is consistent with the size mdadm --grow and resize2fs are reporting for md2.

Did you initially create these partitions with a smaller size, then later recreate them to utilize the rest of the disks? If so, rebooting should allow the kernel to re-read the partition table. After that, growing the RAID device and resizing the filesystem should work.


I regularly use mdadm and consider it one of the most dangerous Linux utilities. However, if you employ the correct safety precautions you can avoid most cases of potential data loss Backup all your data!!! i have been bitten twice by mdadm in the past, lost over 700GB of data and very very little of it was able to be recovered, you have been warned.

There is a very good chance you will need to create the RAID array again as mdadm does not expect or compensate for drives suddenly increasing in size. It will use the size stated in the raid superblock and not the drive itself. Provided that the drives are already synced, you shouldn't have many problems.

Remember if you want to boot of it use superblock version 0.9.

Edit

This is how i would do it, untested!

Create a RAID1 with a missing dive just so we can quickly test that the data remains while still having another drive with a copy of the data, your old metadata was 0.90 so we will keep the same version here.

mdadm --create /dev/md2 --level=mirror --metadata=0.90 --raid-devices=2 missing /dev/sdb3

Mount it to test that everything works

mkdir /mnt/test
mount /dev/md2 /mnt/test

check your data

   ls -l /mnt/test

If it all looks ok then unmount the drive and resize.

unmount /mnt/md2
resize2fs /dev/md2

Once that is all ok you can add the other drive to the array.

mdadm --add /dev/md2 /dev/sdb3

and wait for the drives to resync

cat /proc/mdstat