How to read a RAID1 hard disk if you can’t use the RAID Controller?
December 30, 2007
I had following problem:
An 3ware RAID controller got destroyed after a power surge and I needed to read the data on the RAID without waiting for a replacement controller. I therefore attached one of the hard disks via an USB adapter (PATA/SATA to USB2) to my notebook. The problem now is that a RAID Controller uses some blocks at the beginning of the disk for itself, this leads to the problem that the partition table is not found by the Linux kernel.
Solution:
I used LDE (The Linux Disk Editor) to find out how many blocks are used by the RAID controller. My 3ware controller used 0x200 = 512 blocks with 1024 byte = 524288 bytes offset. I therefore created an loop back device with this offset:
# losetup -o 524288 /dev/loop0 /dev/sdb
and I checked if the partition table is readable via:
# fdisk -l /dev/loop/0
Disk /dev/loop/0: 160.0 GB, 160041361408 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot    Start     End    Blocks  Id  System
/dev/loop/0p1 Â Â Â Â Â Â Â 1 Â Â Â Â 249 Â Â 2000061 Â 82 Â Linux swap /
Solaris
/dev/loop/0p2 Â * Â Â Â Â 250 Â Â Â Â 1494 Â Â 10000462+ Â 83 Â Linux
/dev/loop/0p3 Â Â Â Â Â Â 1495 Â Â Â 19457 Â 144287797+ Â 83 Â Linux
Looks good, but mounting didn’t work directly but I didn’t have the time to look into more detail (maybe udev didn’t created the /dev entries), it was important to get the data of the disks as fast as possible. So I just removed the loop back device with
# losetup -d /dev/loop0
and started to do some math. The swap partition was of no need, I needed only the two ext3 partitions. I calculated the offset of the first of these partitions this way: 249 units with each 8225280 bytes and of cource the RAID controller offset:
249*8225280 + 524288 = 2048619008
with this I did the mounting like this:
# losetup -o 2048619008 /dev/loop0 /dev/sdb
# mount -r /dev/loop0 /tmp/1
and for the second ext3 partition this.
1494*8225280 + 524288 = 12289092608
# losetup -o 12289092608 /dev/loop1 /dev/sdb
# mount -r /dev/loop1 /tmp/2/
I hope this helps someone in a similar situation as I was.
3 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress
Entries and comments feeds.
Valid XHTML and CSS.
37 queries. 0.071 seconds.
I recently needed to recover some files from one disk of a 3ware raid1, and wasn’t looking forward to powering off my machine, pulling it out, opening it, installing the 8006-2LP card, and recabling things. Your post inspired me to try the more direct approach. Thanks!
I’m not sure why mounting didn’t work for you. It worked perfectly for me. Here’s what I did:
1. Determine where 3ware placed the master boot record. It happened to be in the same place as yours. (1024 * 512 = 524288) I verified by dumping it to a file and examining that file:
# dd if=/dev/sdc of=out bs=512 skip=1024 count=1
2. Expose the 3ware-wrapped disk via a loopback device:
# losetup -o 524288 -f –show /dev/sdc
3. View the partition table via the loopback:
# fdisk -ucl /dev/loop0
Disk /dev/loop0: 250.1 GB, 250058825728 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488396144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00006786
Device Boot Start End Blocks Id System
/dev/loop0p1 * 63 476680679 238340308+ 83 Linux
/dev/loop0p2 476680680 488392064 5855692+ 82 Linux swap / Solaris
4. Calculate the partition boundaries, based on the MBR offset and the fdisk output:
disk start: 1024 * 512 = 524288
partition start: (1024 + 63) * 512 = 556544
partition size: (476680680 – 63) * 512 = 244060475904
5. Release the loopback device I claimed earlier:
# losetup -d /dev/loop0
6. Expose the partition via a loopback device:
# losetup -o 556544 –sizelimit 244060475904 -f –show /dev/sdc
7. Mount the partition read-only:
# mount /dev/loop0 /mnt -o ro
Comment by Forest — June 26, 2011 #
This post was an absolute lifesaver. Had a 10 year old (not backed up!) Linux machine that suffered hardware failure. 3Ware RAID controller was PCI-X and didn’t fit into any of our desktops. Using the original post and Forest’s comment I managed to recover all the data from one half of the RAID 1. Thank you both so much.
Comment by Ads — December 13, 2012 #
The offset was 556544 for me as well. I found it using this script:
for i in `seq 1 104857600`; do echo $i; mount sdb.img /mnt -t auto -o loop,offset=$i; if [ $? -eq 0 ]; then echo $i; exit; fi; done
If you’ve mounted the hard drive but didn’t write down the offset, use losetup -a to show it.
Comment by me2014 — December 15, 2014 #