Ubuntu server remove extra partition and resize current larger in mdadm RAID1

1

I am running an Ubuntu Server. Currently, I have the hard drive configuration shown below:

Hard drive config

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.

J Spen

Posted 2016-11-10T21:53:12.467

Reputation: 143

Answers

2

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/sda3 and extend /dev/sda2 to occupy the unpartitioned space created.

  • Add /dev/sda2 back 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/sdb3 and resize /dev/sdb2. Then add /dev/sdb2 back to /dev/md2 and 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.

Luca Citi

Posted 2016-11-10T21:53:12.467

Reputation: 214

Sorry for the mistakes here but yes it is Raid1. /sda and /sdb make up each array. Also, I have read about making sure bad blocks are detected before doing the above using: repair > /sys/block/md2/md/sync_action. Is this recommended for the above? – J Spen – 2016-11-22T06:12:42.557

THanks a lot. GOt it all sorted. Of note is I cound't remove both /dev/sda3 and /dev/sdb3 but removing one then caling stop everything worked fine. – J Spen – 2016-11-23T18:06:31.247