we are running software raid (RAID1-mirror) in our ubuntu server, RAID1 running with two disks( sda 1TB, sdb 1TB). both the disks are having 4 partitions (/dev/md0 as /swap, /dev/md1 as /root ,/dev/md2 as /opt ,/dev/md3 /home), now the /dev/md2 partition almost full so we need to extend that /dev/md2 partition for that we have 1 addition raw disk in that server. is it possible to extend the RAID1 /dev/md2 partition from raw partition .kindly help us to sort out.
Now was able to test with VM with ubuntu server 16.04. I created two virtual disks, each 20G in size, and partitioned appr. 10 GB each partition.
After creating RAID1 (
/dev/md0 as /,
/home) on sda1/sdb1 and sda2/sdb2 and installing, I added a third disk and partitioned in an equal way (sdc1 and sdc2, rsp.). The drive md1 should be grown. As you want to grow md2, replace
sdc2 with whatever partition you have created on your third drive, in the following commands.
First, I added the partition to the raid:
$ sudo mdadm --add /dev/md1 /dev/sdc2
The third partition is added as "spare" (see the output of
sudo mdadm --details /dev/md1) Next, I grew the RAID and changed the raid level as well in one call
$ sudo mdadm --grow --raid-devices=3 -l 5 /dev/md1
Now wait, as syncing takes some time. After syncing is done, you will see the changed raid device:
$ sudo mdadm --detail /dev/md1 /dev/md1: Version : 1.2 Creation Time : Tue Apr 18 13:58:59 2017 Raid Level : raid5 Array Size : 22392832 (21.36 GiB 22.93 GB) Used Dev Size : 11196416 (10.68 GiB 11.47 GB) Raid Devices : 3 Total Devices : 3 Persistence : Superblock is persistent Update Time : Tue Apr 18 15:52:23 2017 State : clean Active Devices : 3 Working Devices : 3 Failed Devices : 0 Spare Devices : 0 Layout : left-symmetric Chunk Size : 64K Name : testRaid:1 (local to host testRaid) UUID : a85a5ca8:17549f5d:7dc28c7b:e24bd25b Events : 136 Number Major Minor RaidDevice State 0 8 2 0 active sync /dev/sda2 1 8 18 1 active sync /dev/sdb2 2 8 34 2 active sync /dev/sdc2 $
What you see now is that the raid level has changed to 5, and the "Array size" is now 20G. The "Used device size" still is 10G, as the filesystem is not automatically grown. This will be done with
$ sudo resize2fs /dev/md1
ext4filesystems may be grown online; with no size parameter, it is extended to the max. If you have other filesystem, look if resizing online is possible.
df -h now shows:
/dev/md1 21G 30M 20G 1% /home
I hope this helps. And remember: Always have a current and verified backup before playing around with disks and partitions!
You've painted yourself into a corner here by using software raid for both high availability and volume management. Next time put LVM on top of the RAID to separate those concerns. In that scenario adding more storage is as easy as adding more backend storage to the volume group and extending the logical volume to use the additional backend. That additional backend can be another self contained RAID1, once you extend the LV across the two RAID1's you have a RAID 10 (stripe of mirrors) for that volume.
Your only way out at this point is to convert your array from a RAID1 to a RAID5 like ridgy proposed, which is going to kill your write performance.
As a side note, your multiple MD partition are probably not aligned properly which could sink as much as up to 20% of your bandwidth.
Full is a hard place to be for a storage array. That's why it's crucial to plan your deployment to have an answer for that, and test it, before you commit to production. Backup all your stuff before you continue and good luck.