what the blog?

{upgrade in progress..}

Enlarge linux software mirror raid 1 howto

Scenario

A linux box running on a software raid 1 mirror harddisk (120GB), recently the server is running out of disk space. A new pair of harddisk with larger capacity (500GB) is going to replace the existing pair.

Current disk layout

100MB md0:/dev/sda1, /dev/sda2
111GB md1:/dev/sdb1, /dev/sdb2

/boot /dev/md0
VolGroup00 /dev/md1
– LogVol00 swap
– LogVol01 /

Synchronize the data to new harddisk

  1. Shutdown the box
  2. remove sdb from the box
  3. replace with the new 500GB disk

Create new disk layout

fdisk /dev/sdb

Create sdb1 as same as sda1 using FD type, and then create sdb2 with allocate the rest of free space.

Add the new disk to current MD raid

mdadm --manage --add /dev/md0 /dev/sdb1
mdadm --manage --add /dev/md1 /dev/sdb2

Install the grub boot loader on new 500GB harddisk

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

Monitor the disk synchronizing progress

mdadm -D /dev/md0
mdadm -D /dev/md1

Wait until both MD is fully synchronized

Grow the MD disk

  1. Shutdown the box and then remove sda disk.
  2. Swap sdb to sda position order, leave only one 500GB new disk in the box.
  3. Boot the box into normal state

Grow it

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

Verify the new disk size by

mdadm -D /dev/md1

Resize the PV to allocate new space

pvresize /dev/md2

Verify new VG size

vgdisplay -v

Extend the logical volume

lvextend -l <FREE PE> /dev/VolGroup00/LogVol01

Allocatie the new space for / file system

resize2fs /dev/VolGroup00/LogVol01

Synchronize the second new harddisk

  1. Shutdown the box.
  2. Install another 500GB as sdb
  3. Boot the box into normal state

Create new disk layout

fdisk /dev/sdb

Create sdb1 as same as sda1 using FD type, and then create sdb2 with allocate the rest of free space.

Add the new disk to current MD raid

mdadm --manage --add /dev/md0 /dev/sdb1
mdadm --manage --add /dev/md1 /dev/sdb2

Install the grub boot loader on new 500GB harddisk

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

Monitor the disk synchronizing progress

mdadm -D /dev/md0
mdadm -D /dev/md1

Wait until both MD is fully synchronized

Almost done…

Remove any mark failed drive if any
mdadm –manage /dev/md0 –remove /dev/sd??
mdadm –manage /dev/md1 –remove /dev/sd??

Limitation

This approach only work for 2.6 later kernel.

linuxmdadmraid

levin • April 28, 2010


Previous Post

Next Post

Leave a Reply