Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have just broke my software RAID 5 Array (build using mdadm) set up by changing one of the HDD partition.

The exact command I used is:

sudo parted -s /dev/sdb mklabel msdos

on one of 4 HDDs in my array.

Is there a way how to fix this HDD and add it back to array without loosing any data?

I'm very new to linux, so now sure how to show you more info about my set up.

Mike

share|improve this question
    
Are you using hardware or software Raid? –  Mitch Jun 5 '12 at 11:05
    
I'm using software raid –  Mike Jun 5 '12 at 11:07

3 Answers 3

up vote 0 down vote accepted

How to add the 4th disk back to the raid? "From Mike's Question in previous comment"

Edit this for your needs:

mdadm --add /dev/md1 /dev/sdf1
mdadm --grow /dev/md1 --raid-devices=4

This then took several hours to reshape the array.

The filesystem the needs to be expanded to fill up the new space.

fsck.ext3 /dev/md1
resize2fs /dev/md1
share|improve this answer
    
Thanx Subv3rsion that will do it :) –  Mike Jun 5 '12 at 12:15
    
That is how to add a new disk to an array, and expand it to use the additional space, not how to fix @Mike's problem. –  psusi Jun 5 '12 at 14:04

You can use a tool named raidextract.

Example usage:

./raidextract --window 1024 --stripe 16 --rotate 6 \
    --start $((0x41C6E79A00)) --length $((4096*1024*64000)) \
    --failed 5 /dev/sd[a-g] | ssh othermachine dd of=RecoveredFilesystem

If you use raidextract to read a filesystem image, you can write the output to a file and run all the standard filesystem tools (tune2fs, e2fsck) on the file. Once you've finished, you can the mount the filesystem with mount -o loop.

For more information, you can read this: http://www.chiark.greenend.org.uk/~peterb/linux/raidextract/

Hope this helps.

share|improve this answer
    
Cheers Subv3rsion, unfortunately I dont have other HDD where can I output 3TB of data to :( I thought that by having Raid-5 one of the HDD is redundant and all data could be easily recovered if one hdd dies. –  Mike Jun 5 '12 at 11:38
    
Well, note that RAID isn't a backup system. –  Subv3rsion Jun 5 '12 at 11:39
    
One more thing, can you try do a XFS repair? then try to mount it again. –  Subv3rsion Jun 5 '12 at 11:42
1  
ok, I managed to start the raid in degraded state and mount it. Good news is I can access all the data. How to add the 4th disk back to the raid? –  Mike Jun 5 '12 at 12:01

If the only thing you did was blow away the partition table with parted, then all you have to do to fix it is to recreate the partition table exactly as it was before. Put parted into sector mode with the unit s command, and you can probably look at the other disks in the array to guess how this one was partitioned.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.