How to split a ddrescue disk image and how to use it again?

I have a 500GB external HDD that I need to rescue the contents of. Unfortunately I only have two 400GB partitions to save the contents to. Can I split the disk image as:

~$ cd /mnt/part1/Recovery/
/mnt/part1/Recovery/$ ddrescue -f -n -i0 -s250...00 /dev/disk disk.part1.ddraw disk.part1.log
/mnt/part1/Recovery/$ cd /mnt/part2/Recovery/
/mnt/part2/Recovery/$ ddrescue -f -n -i250...00 /dev/disk disk.part2.ddraw disk.part2.log

(values of numbers are missing a few zeros for convenience). That is, can I just use the -i and -s flags to split the disk image into two parts manually?

Secondly, is there a way I can mount the two parts of the image as one?

Asked By: Zorawar

||

To answer the second part of your question. How to mount a FS stored in two files (a and b) Two options I can think of:

Using device-mapper and loop devices:

losetup /dev/loop1 a
losetup /dev/loop2 b
s() { blockdev --getsize "$1"; }
dmsetup create merge << EOF
0 $(s /dev/loop1) linear /dev/loop1 0
$(s /dev/loop1) $(s /dev/loop2) linear /dev/loop2 0
EOF
mount /dev/mapper/merge /mnt

The idea being to do a linear device-mapper device which is just the concatenation of the two loop devices.

Using nbd-client + nbd-server

ln -s a part.0
ln -s b part.1
nbd-server 127.1@12345 "$PWD/part" -m
nbd-client 127.1 12345 /dev/nbd0
mount /dev/nbd0 /mnt

(easier but less efficient)

Here, we’re using the “multi-part” mode of nbd-server that expects the parts to be named as part.0, part.1… Unfortunately, contrary to qemu-nbd, nbd-server/client can’t work with Unix domain sockets which mean we have to have the TCP overhead and qemu-nbd doesn’t have such a multi-part mode.

Answered By: Stéphane Chazelas
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.