2014年9月17日星期三

Add new/replacement harddisk in Linux Raid 1(Mirror)

Example data like this
sda is original / source harddisk
sdb is new / replacement  harddisk

md0 members are sda1 and sdb1
md1 members are sda2 and sdb2

After you have changed the hard disk /dev/sdb, boot the system.
 ----------------------------------------------------------------------------------------------------------------
If you use a disk and it is contained some raid info, you need to erase the metadata using this command.
mdadm --zero-superblock /dev/sdb
 ----------------------------------------------------------------------------------------------------------------


sda is master/original drive
sdb new drive

after replace harddisk

boot the master harddisk. If bios have problem and cannot boot, boot rescuecd(you can download from search the web) via usb or CD.

after login and access terminal or command prompt.

copy partition table
sfdisk -d /dev/sda | sfdisk /dev/sdb

after that can verify use
fdisk -l

if ok then

add join harddisk to raid. add partition one by one
mdadm --manage /dev/md0 --add /dev/sdb1

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

if md1 is big and boot up is using rescuecd, you can reboot pc using the new harddisk now due to md0 is boot partition and sync is completed. It can startup now.
After reboot, login to root and re-add md1 again using the last command.

God bless you!

沒有留言: