5

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?

1 Answer 1

7

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.

3
  • I'm unfamiliar with the low-level device-mapper and loopback device manipulations, but the dmsetup command failed with the message "Invalid format on line 1 of table on stdin", which is the line $(s /dev/loop1) linear /dev/loop1 0. A quick look at the man page suggests two numbers before the linear command word. I take it the replacement line should be 0 $(s /dev/loop1) linear /dev/loop1 0? Commented Nov 27, 2012 at 22:16
  • Sorry, copy-paste error of mine. It should be ok now. Commented Nov 27, 2012 at 22:28
  • Yup, that works great. Very useful commands to know of, thanks! I'm going to take the fact that I can manually split the disk image from ddrescue as obviously true (especially seeing as the ddrescue log files give me a table to blocks labelled by byte position, so that I can confirm that the splitting of the disk image is faithful); so, with your answer, I'm going to take the question as answered. Thanks. Commented Nov 27, 2012 at 22:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.