3

I have a .dmg sitting on an external drive (which also contains other data).

The .dmg is an image of a failed drive so I can't mount it but I want to attach the .dmg without mounting the partition it is in.

Is this possible?

I ask because, if I mount the partition, attach the .dmg and then try to run TestDisk, TestDisk returns this message:

Write access for this media is not available.
TestDisk won't be able to modify it.

- No partition from this disk must be mounted:
Open the Disk Utility (In Finder -> Application -> Utility folder)
and press Unmount button for each volume from this disk

I tried what I thought would work: hdiutil attach /dev/disk2s2/cfp/disk0s2-clone.dmg it didn't, attach failed - Not a Directory

I guess a different way of asking my question is, "How can I use TestDisk on a .dmg if I can't mount the partition that the .dmg is in?"

4
  • 1
    The error message might be misleading here. I assume you want to run TestDisk against the DMG, right? This is different from „how can I open a file from a drive without mounting the drive“ (which is what your question currently asks). Can you focus your question on what you actually want to accomplish? – nohillside Mar 1 '20 at 8:23
  • Thanks for answering @nohillside. You are correct: I'd like to run TestDisk against the .dmg but, from what I understand, the partition that the .dmg is in (or any partitions on that drive) cannot be mounted for TestDisk to be able to function. – tripleman Mar 1 '20 at 16:06
  • TestDisk complains about the DMG, not the partition it is stored on. If you can't select the unmounted DMG from within TestDisk I suspect the application is just not built for the task you want to do. – nohillside Mar 1 '20 at 16:14
  • 1
    The short answer is No. You cannot access any file on a given filesystem unless that filesystem is mounted! – user3439894 Mar 1 '20 at 16:15
1

If you mount a drive one of the things which happens is that the file system type gets identified so macOS afterwards knows how to access the content of the drive (and find the DMG for instance). So operating systems can't access files on a drive without mounting it first.

Your actual problem seems to come from the fact that TestDisk is a tool to recover data from physical drives. So it could be used to work with the original disk your DMG represents, but it won't be able to recover data from a DMG.

1
  • Thanks @nohillside. The first paragraph of your answer is, as far as I can tell, the crux of the issue and the actual answer—and I've marked it as such. But my knowledge in Terminal is limited and was hoping there was a way. For sure, TestDisk can be used to recover data from the original, failing drive. But, all the information I've gathered says that it's best to image a failing drive and attempt recovery on the image. First, because if you botch things, you can grab another image and try again, and second, it limits the strain on a failing drive. – tripleman Mar 1 '20 at 21:00
0

Running hdiutil attach -nomount -verbose ~/Downloads/test.dmg will attach the disk but not mount it. Here is the view from Disk Utility after running the command.

enter image description here

1
  • Thanks for answering, @notkevin. That will attach the .dmg without mounting it but the important part—that the partition containing that .dmg must not be mounted. At least, that's how I interpret the warning that TestDisk shows when I try to analyse the .dmg. – tripleman Mar 1 '20 at 16:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .