The Problem
Recently I had to re-setup my laptop because of *reasons*. However, I am used to backup it regularly by creating a full-disk image with dd which is stored on a separate hard disk.
Now i wanted to restore some data and settings from my last backup by mounting it into my fresh set up laptop.
The Solution
One solution would be to crawl the partition table by utilizing fdisk:
Disk /media/gue/GUE-USB3/finalBackup.dd: 238,5 GiB, 256060514304 bytes, 500118192 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
Disklabel type: dos
Disk identifier: 0x57bf86df
Device Boot Start End Sectors Size Id Type
/media/gue/GUE-USB3/finalBackup32Bit_T440S_20200124.dd1 * 2048 500117503 500115456 238,5G 83 Linux
It tells us that a partition of type 83 (=Linux) starts at byte#2048 and ends at byte #500117503, and there we could already use the mount command to mount it.
BUT - this approach becomes more complicated with more partitions, starting at different offsets because you could just mix things up and accidentally try to mount things that do not exist.
Then, I stumbled across kpartx.
loop2p1 : 0 500115456 /dev/loop2 2048
loop deleted : /dev/loop2
It reads partition tables on specified device and create device maps over partitions segments detected. It is called from hotplug upon device maps creation and deletion - which is exactly what we want.
So instead of callint it with the parameter -l i could start it with the parameter -a which creates loopback devices and calls hotplug (which is used to mount the device afterwards) like this:
Fine - the system adds the partition as drive which can be (if you have the acces rights) be read like a USB stick.
To get rid of it, just call it with the parameter -d which removes the loopback devices:
Thats it, have fun !