Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

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
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.

share|improve this answer
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? – Zorawar Nov 27 '12 at 22:16
Sorry, copy-paste error of mine. It should be ok now. – Stéphane Chazelas Nov 27 '12 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. – Zorawar Nov 27 '12 at 22:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.