06
Nov
12

Swapping Raid Disks – Part 1 MDADM

We have a 2 disks (/dev/sda & /dev/sdb) which contains 2 SW RAID partitions partitions and one data partition.  The SW raid partitions where used for /boot and /.  the data partition was used as an hadoop data partitions.  hadoop is designed to perform best by making sequential reads/writes from a disk.  By having OS partitions on the same disk as the data partition we noticed that we where causing some issues with hadoop performance and decided to move the OS partitions to dedicated disks (/dev/sdi & /dev/sdj).

This was relatively simple.  New disks where installed and we used sfdisk and mdadm to configure them.

The first thing to do was to dump the partitions table for the current disk(s)

sfdisk -l /dev/sda -O partition

This preduced the following partitions table

Disk /dev/sda: 243031 cylinders, 255 heads, 63 sectors/track

Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 0+ 45689- 45690- 367001600 fd Linux raid autodetect
/dev/sda2 * 45689+ 45702- 13- 102400 fd Linux raid autodetect
/dev/sda3 45702+ 243031- 197329- 1585042432 83 Linux
/dev/sda4 0 - 0 0 0 Empty

However we did not want the data partitions on the new disks so we had to modify the partition table a little first so it looked like this:

Disk /dev/sdi: 243031 cylinders, 255 heads, 63 sectors/track

Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sdi1 0+ 45689- 45690- 367001600 fd Linux raid autodetect
/dev/sdi2 * 45689+ 45702- 13- 102400 fd Linux raid autodetect
/dev/sdi3 0 - 0 0 0 Empty
/dev/sdi4 0 - 0 0 0 Empty

We configure our new disk as follows:

sfdisk -I partition --force /dev/sdi

We then updated the raid configuration to add the new partitions

mdadm --manage /dev/md0 --add /dev/sdi2
mdadm --manage /dev/md1 --add /dev/sdi1
mdadm --manage /dev/md0 --fail /dev/sda2
mdadm --manage /dev/md1 --fail /dev/sda1
mdadm -D /dev/md0
mdadm -D /dev/md1

Wait until the sync has completed.  you can monitor progress with the below command

watch cat /proc/mdstat

Once all data has synced to both raid partitions repeat the above steps for sdb/sdj.  Once the raid partitions are configured in such a way that sdi and sdj or the two active partitions and have been completely synced you can remove sda and sdb from the raid configueration

mdadm --manage /dev/md0 --remove /dev/sda2
mdadm --manage /dev/md0 --remove /dev/sdb2
mdadm --zero-superblock /dev/sda2
mdadm --zero-superblock /dev/sdb2

mdadm --manage /dev/md1 --remove /dev/sda1
mdadm --manage /dev/md1 --remove /dev/sdb1
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1

continue to swapping raid disks – part 2 fixing /boot for info on how to fix grub and the /boot partitions

Advertisements

0 Responses to “Swapping Raid Disks – Part 1 MDADM”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: