1

I have CentOS 5.8 on my computer, with 5x 1TB hard drives.

I used software RAID. (RAID 1 as a boot partition md0, RAID 0 as a root partition md1 and RAID 5 as /home partition md3).

Unfortunately one of these hard drives failed lately and I want to replace it with a new one.

I want to know that is it possible to change this hard drive without data loss?

The important partition is RAID 5 so in theory if one of hard drives failed I should be able to recover its data without any problem. But in practice how can I do that?

4
  • 1
    If you've lost a disk in a RAID0 then you've lost the the RAID0 array
    – Cry Havok
    Oct 29, 2012 at 17:07
  • The only Partition that is important for me is /home that is raid 5 on disk 1-5.
    – Ali
    Oct 29, 2012 at 17:12
  • Actually i have a backup of raid 0 partition.
    – Ali
    Oct 29, 2012 at 17:15
  • Unless you lost two drives at the same time, you should never have lost access to your data on the RAID5 volume.
    – Zoredache
    Oct 29, 2012 at 19:07

3 Answers 3

2

The folks at this location actually mapped the serial numbers of the physical disks to separate names to help identify those in the RAID array. They used UDEV rules for it. This eliminates the guesswork since serial numbers are typically written on the disk paper labels.

In the below link you'll find real 2 drive failure on a RAID6 setup (+) and recovery. Take a look. You might be able to identify in a similar way which drive you need to unplug.

Regards,

RAID 6 + XFS + MDADM

RAID 6 UDEV Naming

0

It should be something like

mdadm --add /dev/md3 /dev/<disk>

… where <disk> is of the form sda1, sdb1, sdc1, etc.

1
  • Is this command recover my data too?
    – Ali
    Oct 29, 2012 at 18:33
0

Assuming you disk setup is as follows: Disk layout constructed from the comments

With:
sda1 and sdb1 as md1 (mirrored) root
sda2 and sdb2 as md0 (striped) boot
sda3, sdb3, sdc1, sdd1 and sde1 as md2 (RAID5) /home

Since you lost drive 2 (sdb) you:

  • You lost md0. A stripe needs **all* of its drives. You will need to restore this from backup or reinstall it.
  • You lost one drive from md1. Since that is a mirror it will still work. (without redundancy atm)
  • You lost on drive from md2. Since that is a RAID5 is will work with one drive lost. You should still be able to access all your data.

My first step would be to check my backups. Nothing should go wrong while you fix your RAID arrays. But it is better to be safe and have backups. Since both / and /home are still readable in degraded mode I suggest to start with that.

Afterward pull the broken drive (disk 2, aka sdb), replace it with a new drive and partition the drive. I understood from your comments that it used the same setup as the first drive. Which means that you can configure it correctly from your notes, or 'spy' at sda.

Next fix the three broken RAID arrays.

md0 is lost. You will need to recreate it and restore from backup.

md1 might work with mdadm --assemble /dev/md1 /dev/sda1 /dev/sdb1

md2 might work with mdadm --assemble /dev/md2 /dev/sda3 /dev/sdb3 /dev/sdc1 /dev/sdd1 /dev/sde1

Might. I am a BSD guy (not a Linux user) which uses hardware RAID cards. Please double check everything before committing to these commands. This includes your checking your backups.

21
  • The problem is i used some part of each drive for specific drive, i mean for example i add 100G of sda and sdb as root partition, 200M of sda and sdb for root partition and remaining space of sda and sdb and also the whole sdc sdd and sde as a /home partition!
    – Ali
    Oct 29, 2012 at 18:52
  • the failed disk is sdb, so should i first create sdb2 partition? how can i do that?
    – Ali
    Oct 29, 2012 at 19:01
  • sda1 and sdb1 as root partition (md1) sda2 and sdb2 as boot partition (md2)
    – Ali
    Oct 29, 2012 at 19:50
  • I make a backup from are available data, now the problem is i dont know how can i partition this new disk in a way that is usable by software raid. how can i do that? these new partitions should be in what format?
    – Ali
    Oct 30, 2012 at 17:38
  • I did that but i got "no devices found for md0"
    – Ali
    Oct 31, 2012 at 12:54

You must log in to answer this question.

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