4

3 years ago a co-worker setup a software RAID-6 array on Ubuntu 9.04 and I'm getting messages from the OS that the drive has bad sectors and should be replaced. I'd like to remove this drive and replace it with a new drive, however, I have never done this before and I'm terrified that in the process of fixing the array I'm going to end up ruining it.

I know the device ID of the array and I know the device IDs of the individual drives in the array. Additionally I physically have the bad drive.

What are the steps to replace the bad drive with a new drive and get the array running again?

1
  • 2
    Sounds like you could do with getting a pro in to be honest, don't mean to be rude but you don't sound too comfortable with this and it's not worth potentially blowing your system out over.
    – Chopper3
    Sep 14, 2012 at 14:40

1 Answer 1

5

I strongly suggest you become familiar with the tools and implications of each step before proceeding. The last step has the most potential for error and makes the assumption your boot device is hd0. Know thy bootloader!

In this example sdc is the failing device raid member, sdb is a known good device raid member, and md0 is the raid device.

  1. Create a partition table structure backup of the current (failing) drive:

    # sfdisk -d /dev/sdc > ~/raid.ptbackup
    

    If this does not work, or the table is not-recoverable/suspect, copy the structure from another drive in the raid set.

    # sfdisk -d /dev/sdb > ~/raid.ptbackup
    
  2. Mark all failing drive partitions as failed and remove. cat /proc/mdstat for list of raid set partitions and repeat commands for each partition. (sdc1, sdc2, sdc3, etc.)

    # mdadm --manage /dev/md0 --fail /dev/sdc1
    # mdadm --manage /dev/md0 --remove /dev/sdc1
    
  3. Physically replace failed drive with new drive.

  4. Partition the new drive with the required partition table structure. confirm device name sdc, may have changed when drive replaced

    # sfdisk /dev/sdc < ~/raid.ptbackup
    
  5. Add drive partitions into raid set. repeat for all partitions as in step 2.

    # mdadm --manage /dev/md0 --add /dev/sdc1
    
  6. Install grub on new drive.

    grub
    grub> device (hd0) /dev/sdc
    grub> root (hd0,0)
    grub> setup (hd0)
    grub> quit
    
2
  • If the array is only used for storage, do I still need to install grub on the new drive?. (I have a separate drive with / and /home/ partitions.)
    – slayton
    Sep 14, 2012 at 17:06
  • @slayton If it's not bootable, then you can (and should) skip the step entirely.
    – h0tw1r3
    Sep 14, 2012 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .