Thursday, 30 January 2014

Replace failed hard drive in software RAID

Partitioned disk using sgdisk as follows,which means disk structure copied to replaced drive.

# sgdisk --backup=table /dev/sdb
# sgdisk --load-backup=table /dev/sda
# sgdisk -G /dev/sda


Use sfdisk command,
-replace the old /dev/sda hard drive with a new one

 sfdisk -d /dev/sdb | sfdisk /dev/sda


 sfdisk /dev/sdb > part_table
sfdisk /dev/sda < part_table
sfdisk /dev/sda < part_table --force

To view the disk structure.
parted  /dev/sdb
parted  /dev/sda

Added the partition to raid array,

/dev/sda1 to /dev/md1 array and /dev/sda2 to /dev/md2

  mdadm --add /dev/md1 /dev/sda1---------------->add the sda1 to raid md1.
   mdadm --detail /dev/md1--------------------->details

To remove failed disk from raid.

   mdadm /dev/md1 -f /dev/sda1  ---------->mark sda1 as faulty drive.
    mdadm --detail /dev/md1------>shown sda1 degraded
   mdadm /dev/md1 -r /dev/sda1 ---------------->remove sda1 from md1.


No comments:

Post a Comment