MacOS – How to mount a specific file system on a disk image in OSX

macosmount

I have a disk image file containing multiple file systems, such as HFS (Journaled) in addition to Joliet or UDF. I want to mount whatever non-HFS file system is there. First, I attach the image without mounting:

$ hdiutil attach -nomount path/to/image.iso

/dev/disk3 Apple_partition_scheme
/dev/disk3s1 Apple_partition_map
/dev/disk3s2 Apple_HFS

Then, the man page for mount seems to say that I can mount non-HFS file systems like this:

$ mount -a -t nohfs /dev/disk3s2 /tmp

But the response is

mount: exec /System/Library/Filesystems/nohfs.fs/Contents/Resources/mount_nohfs for /private/tmp: No such file or directory

which sounds like it just doesn't understand the documented "no" prefix for filesystem types that you don't want to mount. Is there any way to make this work, or must I know what specific file system I want to mount?

(This motivation for this question involved building CDs for software distribution. That might not be of interest here. But people on StackOverflow suggested that there might be more expertise on the mount command on this site.)

Best Answer

You should parse the output of hdiutil, and mount the filesystems you're interested in - because you can't do what you're trying to do with mount.

The first few lines of the man page show supported syntax:

 mount [-adfruvw] [-t lfs | external_type]
 mount [-dfruvw] special | node
 mount [-dfruvw] [-o options] [-t lfs | external_type] special node

Notice for -a, there are no options to specify a node path, which makes your command invalid syntax.

(Also, I'd suggest testing with a proper image file - one that is an actual CD image. Your image is a hard-disk type, with an Apple Partition Map, and no non-HFS partitions. In Disk Utility, choose New -> Blank Image and note all the selections carefully. You want "CD/DVD"; you can then edit the partition map after you've created it; say, to change to two partitions.)