# raid 5 rebuild help

## Doorsdown

Hi 

i am building a new machine for a professor at my uni. His old machine had gentoo on it with software raid 5. He got a new machine after the motherboard on the old one crashed. So i have the new one up and running with raid 1 with its 2 sd drives.

i can't figure out how to rebuild the raid 5 for the 2 ide drives the i hooked up to the system. I am afraid to do too much without knowing for sure that i won't destroy the new system. Any and all help welcomed.

Thank you

----------

## drescherjm

What happened to the third drive??

You do know that raid 5 needs atleast 3 drives to work? Although you can run it in degraded mode with two but this is basically a slower raid 0...

BTW mdadm is the tool that you need to use to get the drives up and running. 

First do a fdisk -l to see how the drives are partitioned, then use mdadm -E /drive/part for each part that is assumed to be part of the raid array on each disk to see how the drives were used in the raid.

----------

## Doorsdown

there is a third drive from the other machine. I actually don't know much about raid 5, have only used raid 1 thus far. Though i'm not sure how to hook up the third drive as i am out of ide channels

----------

## drescherjm

If you can remove the cdrom and try adding the third drive.

----------

## Doorsdown

i already did, the mother board only has 1 ide spot or thats all i saw as i already took the cdrom spot

----------

## drescherjm

Ahh, I see. I recently have built quite a few systems at work with only one ide port (ASUS M2N) but I only have the cdrom connected to the ide port since my new drives are all sata...

Does the new system have any sata disks or are you only using components from the old??

John

----------

## Doorsdown

it has 2 sata disks which is where the raid 1 lives now aswell as the new installation

----------

## drescherjm

Thats great. I started to explain the procedure in my second post. You first need to determine which devices are the two ide drives. They will probably be hda and hdb. Then you need to determine what partitons on these disks were the raid partitions. You can do this with 

```
fdisk -l
```

Lets say you found that /dev/hda3 was a raid partition, then run

```
mdadm -E /dev/hda3 
```

This will confirm that it is a raid partition or not and what level it is.

Now then you want to run something like 

mdadm -A /dev/md1 /dev/hda3 /dev/hdb3 missing

to assemble the array in degraded mode.

----------

## Doorsdown

 *Quote:*   

> 
> 
> PowerTux ~ # mdadm -E /dev/hda3
> 
> /dev/hda3:
> ...

 

----------

## Doorsdown

i couldn't use md1 to 3 as they are in use for the current system

----------

## drescherjm

Sorry, You may be able to use just 

```
mdadm -A /dev/md4 /dev/hda3 /dev/hdb3
```

If not you may have to use add a --force after the -A

----------

## Doorsdown

ok

 *Quote:*   

> 
> 
> PowerTux ~ # mdadm -A /dev/md4 /dev/hda3 /dev/hdb3
> 
> mdadm: /dev/md4 assembled from 2 drives - need all 3 to start it (use --run to insist).
> ...

 

now what is it 

```

mdadm --run /dev/md4

```

----------

## drescherjm

Sorry about the confusion. I remember if you create an array you need the missing if you are missing drives...

BTW, You should now after mounting the filesystem you should copy all the data to the sata disks because as it sits in degraded raid 5 it is really providing no redundancy at all and if one drive dies you will loose everything...

cp -RPvx --preserve=all /source /dest 

should do.

----------

## Doorsdown

hmm

 *Quote:*   

> 
> 
> PowerTux ~ # mount /dev/md4 /old
> 
> mount: /dev/md4: can't read superblock
> ...

 

i would love to mount the drive

----------

## drescherjm

Possibly this md drive had partitions on it, maybe even lvm. 

You can try fdisk -l /dev/md4

if that does not work pvs to see if it has lvm on it.

----------

## Doorsdown

 *Quote:*   

> 
> 
> PowerTux ~ # fdisk -l /dev/md4
> 
> PowerTux ~ # fdisk  /dev/md4
> ...

 

thanks for all your help dude. i think for now i will just tell him he will have to live without some data untill i can get to a linux machine where i can hookup all of the drives. If you have any other ideas feel free to say them otherwise i will just tell him that.

thanks again

----------

## drescherjm

Your welcome...

I do not think adding all three disks will fix that. If you have 2 drives running it should function as normal only without any redundancy. Did you try running pvs? Maybe it is not installed? You can emerge lvm2 or boot off a live cd to get pvs. 

You should also see if the array still up you can do a 

```
cat /proc/mdstat 
```

 to tell.

----------

## Doorsdown

 *Quote:*   

> 
> 
> PowerTux ~ # cat /proc/mdstat
> 
> Personalities : [raid1]
> ...

 

i'll try the pvs and lmv and report back

----------

## drescherjm

I think I see your problem, the personalities should include raid5 along with raid1. I believe the problem is that you either don't have raid5 compiled into your kernel or the raid5 module is not loaded. First try 

```
modprobe raid5
```

 and see if it complains. If so recompile your kernel and add raid5 support..

----------

## Doorsdown

many many thanks

 *Quote:*   

> 
> 
> PowerTux ~ # cat /proc/mdstat
> 
> Personalities : [raid1] [raid5] [raid4]
> ...

 

i looks as if it should be fixed soon. i look foward to working with you again.

----------

## Doorsdown

 *Quote:*   

> 
> 
> PowerTux ~ # mount /dev/md9 /old/
> 
> mount: you must specify the filesystem type
> ...

 

still on all the drives from the old machine  :Sad: 

----------

## drescherjm

Can you do an mdadm -E /dev/hda9 as I am very confused with your last cat /proc/mdstat output. In raid5 you need 3 drives. It can run with 2 drives with one missing fine but it says 2 drives with only one active this I don't get and I am worried that something has gone horribly wrong.

----------

## Doorsdown

 *Quote:*   

> 
> 
> PowerTux ~ # mdadm -E /dev/hda9
> 
> /dev/hda9:
> ...

 

----------

## drescherjm

That does not look good, I have no idea why it is trying to say that there are only 2 devices for a raid5 when their should be 3 ( 2 active + 1 failed).

Is this the same for the other devices like /dev/hda4? 

Can you post the output of cat /proc/mdstat also.

BTW, it is late Saturday night and I have a busy schedule on Sunday so it will be at least 18 hours before I can check any reply...

----------

## Doorsdown

no worries dude

 *Quote:*   

> 
> 
> PowerTux ~ # for i in `seq 1 9`; do mdadm -E /dev/hda$i; done
> 
> /dev/hda1:
> ...

 

 *Quote:*   

> 
> 
> PowerTux ~ # cat /proc/mdstat
> 
> Personalities : [raid1] [raid5] [raid4]
> ...

 

----------

## drescherjm

Because it does not make sense to me that you have raid 5 arrays that are 2 out of 2 disks could you disconnect both ide disks and insert the other untouched disk by itself and do not run any mdadm tools or commands on it except the command that you used to generate the last result. 

```
for i in `seq 1 9`; do mdadm -E /dev/hda$i; done 
```

----------

