0

My laptop's motherboard died. I removed the two hard drives, and both are operational. I then plugged both into to another computer and using some free software was able to get the following:

  • Block size: 128 KB (256 sectors)
  • Data starts at sector LBA 0
  • Block Map: 1, 2
  • I also know the drive order

I'm wondering if this is enough information to rebuild the array, and if it is, how would I go about it?

1 Answer 1

2

I have fully recovered my colleague's data in the same situation (dead motherboard). The tool was dmsetup in Linux. If you don't have Linux installed then use LiveCD e.g. Knoppix.

I don't know whether you are familiar with Linux or not. My answer will not cover all the "obvious" basics you may need (like mkdir or sudo), so if you are a Linux newbie then learn, ask in comments etc.

Here I assume your two drives are /dev/sda and /dev/sdb. Remap my example to your actual values.

Investigating further

Since you know 256 sectors equal 128 KiB, the sector size is 512 B. You need to know how many sectors there are on every disk. You said you know the drive order; this doesn't necessarily mean you will know which device will be /dev/sda when your Linux starts. Invoke one by one:

gdisk -l /dev/sda
gdisk -l /dev/sdb

One of these commands should show you a sane partition table, it indicates the first device in your array (this knowledge will be useful later). Ignore warnings, if any. Every command will show you also the number of sectors for respective disk. These two numbers may or may not be equal. If they are equal, multiply the number by 2 (in general: by the number of disks); if they are not equal, get the lowest number and multiply by 2. The result is a maximum number of sectors RAID0 can utilize. Let's call it N.

But! Your array should have 256 sectors of one disk followed by 256 sectors of the other and so on, equal number of them. Therefore the number of sectors in your array should be divisible by 512. N might not be divisible, so you should pick the nearest non-greater integer that is divisible by 512. Work with calculator or e.g. bash (substitute "N" with your actual number):

M=$((N/512*512))
echo $M

This is the most probable number of sectors in your array. The most important thing now: this is the valid number, even if for some reason the actual number is less than that.

Creating mapped device

The following command should almost be the right one for you:

echo "0 $M striped 2 256 /dev/sda 0 /dev/sdb 0" | dmsetup create mydevice

I wrote "almost" because there are few things to adjust:

  • substitute $M with its proper value by hand if you used calculator instead of shell arithmetic;
  • change the device order and names to fit your case;
  • you will probably need sudo to run dmsetup.

The argument to echo is your device map, mydevice is an arbitrary name. The map says (in order) that the new device fragment starting with 0-th sector and covering $M sectors is striped, built with 2 devices with stripe size of 256 sectors, the devices (in order) are /dev/sda (starting from its 0-th sector) and /dev/sdb (also starting from its 0-th sector).

Now you should have /dev/mapper/mydevice available and ready to use. (I'm not 100% sure every implementation of dmsetup creates nodes in /dev/mapper/; mydevice should appear somewhere.)

Mounting

Check the partition table which should be sane and make sense:

gdisk -l /dev/mapper/mydevice

If there is MBR, not GPT, you may get a warning about secondary partition table overlapping the last partition. This is because gdisk gets ready to write GPT. You don't need to do that and you won't. Ignore the warning if any. There's nothing to worry about unless you already have GPT and overlapping occurs.

I have seen people using dmsetup or kpartx to create a node associated with a partition they want to mount. Or even dd to "extract" a partition and mount the resulting file. None of these is necessary. Nowadays you can mount a partition from inside the entire device thanks to offset option. E.g. if the partition you need to mount starts at sector 63. (common value for Windows XP system partition), then you mount it like this:

mount -o offset=$((512*63)),ro /dev/mapper/mydevice /mnt/foo

I highly recommend to mount read-only (-o ro) at first (or at all, if you just want to get data out). If the software you used got something wrong or if I made a mistake with some command then you may corrupt your data, unless you mount read-only. This is a good reason to use ro option, at least until you wander around the filesystem, read few files (i.e. play mp3-s and avi-s, read pdf-s, display jpg-s etc.) and confirm that everything seems in order.

Cleaning

To destroy /dev/mapper/mydevice:

dmsetup remove /dev/mapper/mydevice

Of course you should umount its partitions first.

1
  • Wow, what an awesome answer. I sense some technical writing in your background. Very clear and organized information. I'll be reading your other posts on HD maint/repair. Tnx!
    – shellter
    Commented Nov 28, 2023 at 21:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .