Monday, September 17, 2012

Linux to the rescue (again)

Recover a broken NAS Drive

So I get to meet these people regularly. Drive/PC full of important stuff like photos videos and whatever but no backup. Last week a guy in a blind panic enters our offices. All the family pictures, videos communion etc on his NAS device and its not working. "I have no backup and the wife is going to kill me if they are lost." Put the drive on the bench dead as a duck, no problem, strip the device once its established it is out of warranty, and remove both drives and place into the workshop PC. On power up one of the drives is clonking or in other words goosed. This is not good, most likely this is a raid device and if its RAID0 someone will be heading for the divorce courts.

My trusty Rescue CD

There are many rescue CD's out there about but my choice is Image For Linux by Terabyte Unlimited. This comes as part of the Image For Windows and is well worth the €49 price tag. It cotains an ISO image which has full network and scripts to do SMB connections as well as all the usual tools from Busybox.
I will outline below how you can mount up a broken/degraded raid system with a rescue or full Linux system.

Use fdisk to determine, the data partition will be the largest one
#fdisk/dev/sda (first sata Drive) use hda if its first IDE
In this case it was sda3

Try and mount the partition
#mkdir /mnt/data
#mount /dev/sda3 /mnt/data
error stating this is part of a Linux raid array

Check the system for raid drives
#mdadm –examine --scan
You should get an output like ARRAY /dev/md1 UUID:<long string of characters>

Then create a configuration file
#mdadm --examine --scan > /etc/mdadm/mdadm.conf

Edit the configuration file
#mcedit /etc/mdadm/mdadm.conf
Add to each line the raid type, number of devices and the actual devices
Example for a raid1
ARRAY /dev/md0 level=raid1 num-devices=2 UUID:<long string of characters> devices=/dev/sda3,missing

Make the raid devices available
#mdadm –A –scan

Check the output of /proc/mdstat
#cat /proc/mdstat
The device should be listed as degraded [U_]

Mount the drive
#mount /dev/md0 /mnt/data

Extract data and save some poor fella from a faith worse then death.

Only wimps use tape backup real men just upload their important stuff on ftp, and let the rest of the world mirror it ;)

No comments:

Post a Comment