MacOS dmg file question

Not entirely sure if this is where to ask this, but I can't find another place to...

I've recently switched from Windows to Mac and I am trying to understand more in depth what I'm working with.

My question is: are .dmg files the equivalent of .zip files in Windows? I came to this theory when downloading a .dmg and when I opened it, it contained a .app and and text file read me. To me, this seems like a compressed file.

Is this correct?


Solution 1:

A DMG file (Apple Disk Image) is a disk image file that is mounted as a volume, just like a physical disk. They can be password protected and compressed (like ZIPs), and are usually used for packaging and downloading Mac software (amongst other things).

DMGs are exclusively an Apple file format (though can be opened as read-only on Windows computers with 3rd party software), while a ZIP file is universal, and can be opened on both Mac and Windows. The nice thing about them is the ability to mount them, as I mentioned earlier. When you open a ZIP, it extracts the files to your computer, taking up more space on your hard drive. A DMG once mounted, however, can be interacted with and ejected without copying any files or taking up space on your hard drive.

@klanomath said it best in their comment on this answer, so I will quote them here:

All valid DMGs contain a file system - so they are mounted exactly like a real partition to a file system. They get their own device/disk identifier (like all disks) Check diskutil list after opening a DMG.