You are not logged in.

#1 2017-01-07 22:34:48

TheChosenOne
Member
Registered: 2012-09-27
Posts: 130

[SOLVED] How to recover data from RAID 1

I've set up two hard drives in RAID 1. I want to know how to recover data from them if anything goes wrong with one of the drives.

I've tried to start the raid with

sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdc missing

But that doesn't seem to work.

How can you check data on one of the RAID devices? I guess this must be possible since RAID 1 is just a mirror of the data.

Thanks.

Last edited by TheChosenOne (2017-01-08 15:56:02)

Offline

#2 2017-01-08 00:23:53

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] How to recover data from RAID 1

When one of the drives fails, you remove it from the array, stick a new drive in and resync and away you go. That is the whole point of running RAID.

The procedure I use:

# identify broken drive
hdparm -i /dev/sdx

# removing and replacing a faulty device
mdadm --manage /dev/md0 --fail /dev/sdx1
mdadm --manage /dev/md0 --remove /dev/sdx1

# power off
# insert new drive
# copy partition table across
sfdisk -d /dev/sdy | sfdisk --Linux /dev/sdx

# check array members
cat /proc/mdstat

# add the new partitions to the array
mdadm --manage /dev/md0 --add /dev/sdx1
etc…

# watch the resync
watch -n 1 cat /proc/mdstat

# once complete, reinstall grub/syslinux to new device
syslinux-install_update -i -a -m
# on Debian
grub-install --recheck /dev/sdx
update-grub

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-01-08 15:05:55

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: [SOLVED] How to recover data from RAID 1

TheChosenOne wrote:

--create

And that's your problem right here. Run mdadm -h and read about the first two options.

I think this would do it:

mdadm -A -R /dev/md0 /dev/sdc

Offline

#4 2017-01-08 15:55:49

TheChosenOne
Member
Registered: 2012-09-27
Posts: 130

Re: [SOLVED] How to recover data from RAID 1

mich41 wrote:
TheChosenOne wrote:

--create

And that's your problem right here. Run mdadm -h and read about the first two options.

I think this would do it:

mdadm -A -R /dev/md0 /dev/sdc

It works! Thanks!
PS: --create fucked up my previous raid setup, but that's ok since the drives were still empty.

@jasonwryan
Thanks for the reply. I'll use this when a drive fails.

Offline

Board footer

Powered by FluxBB