Recipe: How do I mount an SD card image that has multiple partitions?

All credits and original text can be found at http://bharath.lohray.com/weblog/how-do-i-mount-an-sd-card-image-that-has-multiple-partitions/

Mounting an image of a file system is pretty simple –

$ sudo mount imageFile.img mountpointFolder/

However, this will fail to work if the image file has multiple partitions. In my case the image of an sd card that I created by –

$ sudo dd if=/dev/sdd of=diskImage.img bs=4M

After a little search I found a utility called kpartx which solved my problem. kpartx can be installed from the default repositories of ubuntu and other similar distributions.

We may use file to check if the file we are trying to mount is an image with multiple partitions –

$ file -s diskImage.img
diskImage.img: x86 boot sector; partition 1: ID=0xc, active, starthead 1, startsector 63, 144522 sectors; partition 2: ID=0x83, starthead 0, startsector 144585, 6988275 sectors, code offset 0x0

We may then use kpartx -l to dry run kpartx and check the loop devices that would be created if kpartx is run.

$ sudo kpartx -l diskImage.img
loop5p1 : 0 144522 /dev/loop5 63
loop5p2 : 0 6988275 /dev/loop5 144585
loop deleted : /dev/loop5

Now, we run kpartx (-v for verbose and -a to add loop devices).

$ sudo kpartx -a -v diskImage.img
add map loop5p1 (252:10): 0 144522 linear /dev/loop5 63
add map loop5p2 (252:11): 0 6988275 linear /dev/loop5 144585

The loop devices are created at /dev/loop<someNumber>. The partitions are mapped at /dev/mapper/loop<someNumber>p<partitionNumber>.These mapped partitions may then be mounted –

$ sudo mount -o ro /dev/mapper/loop5p1 tmp1/
$ sudo mount -o ro /dev/mapper/loop5p2 tmp2/

Old Hardware – MRT NAS 35HD-DUAL-NAS-E

After two years without turning this thing on, the result is this:

So by now, i’ve to accept that MRT NAS 35HD-DUAL-NAS-E is dead and completely deprecated.

User support foruns can be found now at a new adress (guess they change in last years because of hosting cost) and the firmware websites from www.embeded-systems.net are now a sponsored landing page… so, i’ve made a copy of the last firmware knowed for this device in order to preserve their existance.

A Germany company still has it in the site… so before they close, i’ve create a backup. At MRT Website no existence of this hardware by now, so it was a good old product.

All the firmware and GPL Code in the site are mirrored here, and also a firmware that i used in the past which has the ability to spinoff disks: https://cloudpt.pt/link/ef960544-d4…L-NAS-E-GIGANAS

Nothing to see more in here, moving on. Rebuilding array…