I have a file called BaseSystem.dmg which contains a hfs+ system image as well as other files. I am trying to extract just the hfs+ system image file using 7z from the p7zip-full package.

I have tried all these commands and others too...

7z x BaseSystem.dmg
7z e BaseSystem.dmg
7z x BaseSystem.dmg 4.hfs

Instead of extracting just the 4.hfs file I either get nothing or 7z goes straight to extracting all files and folders in BaseSystem.dmg.

I am able to use dmg2img like this and it works...

dmg2img -p 4 -i BaseSystem.dmg -o 4.hfs

But my question is about how do I use the 7z command to extract just the 4.hfs file from BaseSystem.dmg?



I get the same result when I use 7-Zip 19.00 (32 bit or 64 bit) on Windows and also when I use 16.02 (64 bit) on Ubuntu.

I know that this is possible because Boot Disk Utility uses 7-Zip 19.00 (32 ) and IS able to extract 4.hfs from BaseSystem.dmg. However I don't know what parameters it uses. I actually also downloaded 7-Zip 19.00 (32 ) separately for my Windows OS and again when I run it myself it does not extract just the 4.hfs file.

So it must be something about what 7z parameters I am using?

  • 1
    Have you read superuser.com/questions/321829/… (seems like you're already doing that, but if it doesn't work, it doesn't work, and you simply can't use your version of 7z; what version is that, by the way?)? (also, there's nothing OS-specific in here, not quite sure this should be here instead of superuser.com) May 27 at 10:29
  • I updated my question with some more info as you request. I posted my question on SuperUser also. May 27 at 21:17

I found the answer to this by asking the 7-Zip author at SourceForge.

In my case this is the command I needed to extract just the 4.hfs partition from BaseSystem.dmg:

7z e -t* BaseSystem.dmg 4.hfs

This command lists the files one level deep in BaseSystem.dmg:

7z l -t* BaseSystem.dmg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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