What are Disk Images?
Disk images are a means of archiving data. They are created using a tool called Disk Utility which is a File System Management Utility of macOS. Disk Images follow the extension ‘.dmg‘ and are only compatible with macOS.
Disk Images are a popular way of distributing applications for macOS. They provide the capability of compressing large files and make delivery over the internet very easy.
In this article we are going to look at how we can create disk images for application distribution.
Creating the DMG Folder for distribution
- Create a Background image. This can have any design. It’s a good idea to have arrows or other visual aids to assist others during installation.
- Create a new Disk Image. Open Disk Utility.
- Click on File > New Image > Blank Image
- Leave the default settings as is. Choose the size that you desire.
- Mount the Disk Image.
- Create a folder called background in the mounted volume.
- Save the background image in the folder we just created.
- Now we will hide the background folder. Switch to terminal and run the following command.
cd /Volume/InstallDMG/ mv background .background
Here we are simply renaming the background folder with a ‘.’ before it. This hides the folder from the GUI.
Now we will prepare the payload. This can be any file or folder we wish to install. For the sake of this demo I will be choosing Mozilla FireFox. In reality you would be distributing your own application. - Copy the FireFox app into the mounted volume.
- Open “Show View Options“.
- Restrict the mounted volume to icon view only. Feel free to customise the other settings as you wish. This includes icon size.
- Drag and arrange the icons in your mounted window to match the background.
- Eject the disk image.
- Make a duplicate copy of the image file. This can act as a reference for future images you wish to create.
- Now we will convert the disk image into a read only compressed disk image. This will be the one that we will use for distribution. Open Disk Utility.
- Click on Images > Convert
- Select the InstallerDMG.dmg from Desktop or wherever you had saved it.
- Give it a new name and convert it to compressed format.
That’s it. You now have your own drag drop window ready for distribution.