I am running an Ubuntu Server. Currently, I have the hard drive configuration shown below:
I want to remove the /mnt/winback partition and add the extra space to the /mnt/data partition. What is the best way to do this keeping the other partitions the same?
I have found the article here that shows how to shrink each drive:
Resize underlying partitions in mdadm RAID1
but would the steps be modified like this:
1. Resize the mdadm RAID resize2fs /dev/md2 [size] where size adds the additional space from /dev/md3
2. Remove one of the drives from the RAID mdadm /dev/md2 --fail /dev/sda1 && mdadm /dev/md3 --fail /dev/sda1
3. Remove /dev/md3 from partition table
4. Resize the removed drive to occupy this extra space with parted
5. Restore the drive to the RAID mdadm -a /dev/md0 /dev/sda1
6. Repeat 2-5 for the other device
7. Resize the RAID to use the full partition mdadm --grow /dev/md0 -z max
Does the above seem right? I don't want to mess up my server.
Answer
Something is unclear in your description: how can /dev/sda1 be both in /dev/md2 and /dev/md3? Also, is this RAID1? What devices make each array?
To give you an idea of a possible sequence of steps, I assume RAID1 in the following and that /dev/mdX is made of /dev/sdaX and /dev/sdbX (X={2,3}), and that /dev/sdY2 and /dev/sdY3 are contiguous on the disk (Y={a,b}).
General rule: when you shrink (whether on RAID or not), you need to shrink the filesystem first, then the partition; when you grow, you need to grow the partition first, then the filesystem.
So, in your case resize2fs /dev/md2 is the very last step.
You should start by unmounting
/dev/md3.Then you need to fail and remove the devices (partitions) making up
/dev/md3:mdadm /dev/md3 --fail /dev/sda3 --remove /dev/sda3(and same for/dev/sdb3).Then stop
/dev/md3:mdadm --stop /dev/md3.Fail and remove
/dev/sda2:mdadm /dev/md2 --fail /dev/sda2 --remove /dev/sda2.Within, e.g., parted, you can remove
/dev/sda3and extend/dev/sda2to occupy the unpartitioned space created.Add
/dev/sda2back to/dev/md2:mdadm /dev/md2 --add /dev/sda2. Wait for it to resilver the newly added partition:watch cat /proc/mdstat; only when you get[UU], move to the next step.Fail and remove
/dev/sdb2, then remove/dev/sdb3and resize/dev/sdb2. Then add/dev/sdb2back to/dev/md2and wait for[UU]again.Grow the array:
mdadm --grow /dev/md2 --size=max. Wait for[UU]again.Resize the filesystem:
resize2fs /dev/md2.
Please check the man pages for mdadm and consult other sources. I am not responsible for any possible data loss.

No comments:
Post a Comment