'

RELOCATING a RAID1 mdadm array to bigger hdds on CentOS - pt.2.

February 22nd, 2013 by Andrea Matesi 3147 Views

To successfully understand what am I talking about, you should read my previous article:

RELOCATING a RAID1 mdadm array to bigger hdds on CentOS - pt.1.

Remove the faulty hdd and disable the swap.

If you've followed me, here's some hands-on.

The first step involves removing sdb (the faulty hdd in my case), so:

mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
mdadm /dev/md1 --fail /dev/sdb2 --remove /dev/sdb2
swapoff /dev/sdb3
mdadm /dev/md2 --fail /dev/sdb4 --remove /dev/sdb4

  • The previous commands will remove /dev/sdb from the active array. Also, have a look at fstab and comment the swap line (I had 2 different swaps on two different partitions, which were outside the mdadm RAID 1 array).

screenshot:

fstab screenshot

Add your new hdd.

Now you can shutdown your system, physically install the new hdd and pwr the system up.

At this point I'm assuming you've already taken care of the physical layer (i.e.: by physically adding the new, additional hdd to your server), so let's proceed.

this is how the mdadm array should look.

On the left, how my original mdadm array was (before adding the 1TB hdd), on the right (followed by the "->"-simbol), how my new mdadm array will look like (ie. after following the whole guide).

(set the partition type to 0xDA - Non-fs data or 0xFD, Linux raid autodetect if you are still using the deprecated autodetect check other disks and decide!)

Fdisk fun hour!

Now you should fire fdisk and create a new partition table and the new partitions on the new additional 1TB hdd.

Here's a summary of the possible fdisk commands:

fdisk /dev/sdb
   
    o for a New Partition TABLE.
    p to VIEW (print) the Partition table.
    n for a New PARTITION (1, default starting sector, +end_sizeM).
    a to make the (/boot) Partition ACTIVE.
    t to change/specify the Partition TYPE.

  • Use fdisk to recreate your partition table and your partitions scheme (this is fun, the best part of my guide)!

Some adjustments.

After you manually created the partition table and your desired partitions, create and enable the swap partition like so:

mkswap /dev/sdb3
swapon /dev/sdb3

  • Then open fstab and uncomment the previously commented swap string.

Once the new partitions are created and the swap is enabled, synch the new partitions to the existing mdadm array:

mdadm --add /dev/md0 /dev/sdb1
mdadm --add /dev/md1 /dev/sdb2
mdadm --add /dev/md2 /dev/sdb4

The previous commands will add the new partitions to your pre-existing array.

A background synchronization process will (automatically) start.

The synch process will simply replicate the content From the original (pre-existing) 80GB disk To the new 1TB disk.

Tweaking the mdadm Synchronization process.

To SPEEDUP the mdadm resync process:

echo 400000 >/proc/sys/dev/raid/speed_limit_max
echo 4000 >/proc/sys/dev/raid/speed_limit_min
ps fax | grep sync
renice -20 mdX_resyncPID (to add priority to the sync process).

TO WAIT for the RESYNC process to finish:
mdadm -W or --wait /dev/mdX

(AFAIR, wait will take your control of your prompt and won't be able to mess with your system in the meantime, but that's subjective - just be patient!).

GRUB setup.

It would also be a good time to check the mdadm.conf, so have a look at /etc/mdadm/mdadm.conf and verify everything is alright on your new array.

Once the synch process has finished (believe me, it takes a lot even after the tweaking it), you will need to "grub-ify" the new hdd.

Installing grub on the new additional mdadm hdd.

The commands I typed are as follows:

grub
root (hd0,0)
setup
root (hd1,0)
setup

After grub was setup on your new hdd, you'll need to check if it works, so remove the old original (booting) disk, and leave the new (just synched) 1TB hdd alone (i.e.: /dev/sdb), then verify If CentOS boots up from the new hdd (it will be recognized as /dev/sda).

Fantastic, if you made it successfully 'till here, you're on your way to succeed!

[ADD THE SECOND 1TB DISK - repeat the first disk steps!]

Now...it is time to add the second 1TB hdd to the array. I'm not going again on a step-by-step process (like a boring wallpaper which periodically keeps popping up), simply because the procedure is more or less the same as I explained above.

And I am pretty sure your setup differs from mine, so you'll have to adjust accordingly to your specific requirements.

Refreshed RAID 1 mdadm array booting successfully from BOTH NEW Hard Disk Drives.

At this point, you've already tested your system and it successfully boots from BOTH hard drives, because you were diligent and you DID test it by booting first from the 1st disk then from the 2nd disk.

Well done! You're almost finished.

The last step consists on the baptism of fire growing the new hdds for them to avail of the whole space.

GROW and RESIZE GOOD RAID 1 ARRAYS.

Before growing the array, check the partitions are clean with fsck, then grow the array and resize the filesystems to their maximum available size.

The final step: growing good filesystems!

mdadm --grow /dev/md0 --size=max

The previous command will grow your array to the maximum available space, then:

resize2fs -p /dev/md1

To resize the filesystems online.

Please note for it to work, you'll need at least linux-2.6.x, which supports the ext3 "on-line resizing" feature.

Now run mdadm -W or --wait /dev/mdX!

Did I make your day?! Shout a Coopers for me (Paypal under my pic!).

Posted in LINUX, System Administration | Comments Off on RELOCATING a RAID1 mdadm array to bigger hdds on CentOS - pt.2.

Comments are closed.