0

I ddrescue'd from a sick drive device into an image file (I had enough free space, but not a spare device to copy onto). It seemed to go quite well, but now I can't find how to mount just one partition from the entire block device image.

(All the docs that I can find refer to mounting a partition image file, not the whole device.

$ sudo ddrescue --no-split --sparse -v      \
    /dev/disk/by-id/$disk_by_id_2t_g5_boot  \
    g5_boot.img g5_boot.state-log
...
$ ^--no-split^--max-retries=3^
...
$ file g5_boot.img
g5_boot.img: data

Thanks in advance!

DouglasDD
  • 513
  • 3
  • 16

1 Answers1

2

If the disk image actually has a partition table, you can use kpartx to examine and/or mount it.

To view:

kpartx -l g5_boot.img

To mount:

kpartx -a g5_boot.img

If the drive was GPT formatted, you may need to add the -g option.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • Sweet tool! [simple usage](http://robert.penz.name/73/kpartx-a-tool-for-mounting-partitions-within-an-image-file/) – DouglasDD Mar 08 '14 at 21:34
  • Does ddrescue compress sparse data? If so the result of that might not work quite as anticipated.. Leasyways it will probably expose the partitions, but the data from the mounted filesystem may be pointing to the wrong offsets. – Matthew Ife Mar 08 '14 at 21:43
  • Good point. According to the log file everything was recovered after the `--max-retries=3` run, so I should be OK this time. But in the future avoiding `--sparse` might be safer(?). – DouglasDD Mar 08 '14 at 21:52