LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   mdadm assemble raid5 with loopback mounted disk images (http://www.linuxquestions.org/questions/linux-server-73/mdadm-assemble-raid5-with-loopback-mounted-disk-images-715343/)

Voltar 03-29-2009 05:01 PM

mdadm assemble raid5 with loopback mounted disk images
 
I have an old RAID 5 array that was comprised of three 320 GB IDE Western Digital drives. Currently one of the old drives is completely toast, an another is questionable. I have a full image of the questionable drive (299 GiB) that I dd'd, and I have the third drive that is still working. My goal is to get mdadm to assemble the array in a degraded state, long enough for me to copy all the data that is still on there somewhere else.

I started with dd'ing an full image of the questionable drive to an image file:

Quote:

# dd if=/dev/sdp of=/home/drive.img
Then I mounted the image file via losetup:

Quote:

# losetup /dev/loop0 /home/drive.img
Attempting to now use /dev/loop0 in the assembly yeilds this:

Quote:

# mdadm -A /dev/md17 /dev/sdp1 /dev/loop0
mdadm: no RAID superblock on /dev/loop0
mdadm: /dev/loop0 has no superblock - assembly aborted
After that I realized that I dd'd the entire drive not just the main partition. So using fdisk to find out the partition table yeilds this:

Quote:

# fdisk -l /dev/loop0

Disk /dev/loop0: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/loop0p1 1 38913 312568641 fd Linux raid autodetect
Seemingly normal and all is working so far. So trying to assemble the array with the following also fails:

Quote:

# mdadm -A /dev/md17 /dev/sdp1 /dev/loop0p1
mdadm: cannot open device /dev/loop0p1: No such file or directory
mdadm: /dev/loop0p1 has no superblock - assembly aborted
Any suggestions? I know it would be a lot easier to hook both drives up and attempt to start the degraded array that way, but the server I'm working with has no IDE channels, and I only have one USB adapter.

Thanks in advance for any help

int0x80 06-11-2011 01:20 PM

Offset
 
Sorry to rez an old thread, just wanted to post some info as I was playing with this today.

The Linux raid autodetect partition (0xfd) in the image may be at an offset so you need to use losetup with the offset.

1. Find the offset:
Code:

# parted drive.img
(parted) unit b
(parted) print
Number  Start    End        Size      Type    File system  Flags
 1      1048576B  98703359B  97654784B  primary              raid

2. Create the loopback with the offset:
Code:

# losetup -o 1048576 /dev/loop0 drive.img
3. Continue with your RAID setup


All times are GMT -5. The time now is 06:54 PM.