1

is there terminal command that shows/reads the file system(s) (and versions) of a .iso or .dmg image?

E.g. Udf 2.50/Joliet/hfs+

bmike
  • 235,889
  • Perhaps mount the image first and then use diskutil info /dev/<disk#>? – Joy Jin Dec 25 '20 at 12:42
  • I’ve linked in my answer to some details like @JoyJin has helpfully commented. https://apple.stackexchange.com/a/73931/5472 as asked this is basically a yes/no question. – bmike Dec 25 '20 at 12:48
  • Read the manual pages for hdiutil and diskutil. You can read the manual page for command in Terminal by typing command and then right-click on it and select: Open man Page – user3439894 Dec 25 '20 at 14:00

1 Answers1

3

Yes - you can read the details from ISO and DMG from the command line using OS provided tools.

The primary command line tool to manipulate disk images is hdiutil and you may need to attach / authenticate / mount them and use diskutil to determine file systems contained within a dmg or iso if the wrapper doesn't contain the information you require.

The option I use is hdiutil imageinfo but also hdiutil fsinfo has exceptional details on these containers that may be useful to you.

% hdiutil imageinfo foo.dmg
Format Description: UDIF read-only compressed (zlib)
Class Name: CUDIFDiskImage
Checksum Type: CRC32
Size Information:
        CUDIFEncoding-bytes-total: 1015091
        Total Empty Bytes: 13726208
        Sector Count: 30730
        Total Bytes: 15733760
        CUDIFEncoding-bytes-wasted: 0
        Total Non-Empty Bytes: 2007552
        Compressed Ratio: 0.50548329507778633
        CUDIFEncoding-bytes-in-use: 1015091
        Compressed Bytes: 1015091
Checksum Value: $81F7C3A0
Segments:
        0: /Users/me/foo.dmg
Partition Information:
        1:
                Name: disk image (Apple_HFS : 2)
                Partition Number: 1
                Checksum Type: CRC32
                Checksum Value: $AAEEB101
        -1:
                Name: Driver Descriptor Map (DDM : 0)
                Partition Number: -1
                Checksum Type: CRC32
                Checksum Value: $77150592
        2:
                Name:  (Apple_Free : 3)
                Partition Number: 2
                Checksum Type: CRC32
                Checksum Value: $00000000
        0:
                Name: Apple (Apple_partition_map : 1)
                Partition Number: 0
                Checksum Type: CRC32
                Checksum Value: $5AC9B785
Format: UDZO

There are dozens of verbs to send to the tool, so I suppose the one you need may vary based on your specific query against the data contained within the packaged file.

bmike
  • 235,889
  • But hdiutil does not show me the file systems of an existing image. – user400439 Dec 25 '20 at 12:37
  • 1
    ISO and DMG are packages. Their version is shown in info. @user400439 perhaps the [tour] will help you refine your question by showing some research? There may be several questions here TBH. – bmike Dec 25 '20 at 12:41
  • Does hdiutil fsid get the enclosed filesystsm? I can't test as I don't have anything that's not HFS+ – Tetsujin Dec 25 '20 at 13:25
  • 1
    @Tetsujin, Yes, hdiutil fsid works on the ISO images I tested it on. Which reported the expected ISO 9660 filesystem as well as UDF, and on a hybrid disc it even reported a FAT12 partition, among others on that disc. – user3439894 Dec 25 '20 at 14:11
  • hdiutil imageinfo is the one I use the most, but OP here is so vague, we can't really guess what level of knowledge they have, what they're doing or what research / actual problem they face is... (do they know what a man page is? do they really just need to know which ISO are PC and need a one liner with awk|sed|grep treatment, etc... – bmike Dec 25 '20 at 14:14
  • ok, I tested the commands and they are really useful, thank you all! But I was not able to read the version of the file system. E.g. is the UDF file system version 1.50 or 2.60, etc. Is there a command to read get the version? The man pages do not show any hints regarding udf versions – user400439 Dec 28 '20 at 11:33
  • You might have to upload a sample file. The commands work for all the images I have @user400439 how did you come across your files? – bmike Dec 28 '20 at 16:35
  • Use hdiutil create -size 1m -fs UDF -volname Test ~/Desktop/Test.dmg followed by newfs_udf --wipefs yes -b 2048 -r 2.60 -v Test ~/Desktop/Test.dmg Now I need a terminal command which shows me: "UDF 2.60". The commands show me that the fs is UDF but not the version (2.60). Or did I miss something? – user400439 Dec 29 '20 at 09:38