How To Mount Dmg In Terminal
Dec 17, 2011 A helpful command line tool called hdiutil is included in Mac OS X that allows disk image files (.dmg extension) to be mounted directly from the Terminal, without the need of using the GUI. Using hdiutil for such a task is helpful for scripting or remote connections through SSH. After installing DMG Extractor, all you have to do is double-click your DMG file to open it up. You can browse the files right in the DMG Extractor window if you just want to see what’s inside the DMG file. If you need to extract the file, click the “Extract” button on the toolbar, and then choose one of the extraction options. Step 1: Install dmg2img. Open up your terminal console; sudo apt-get update; sudo apt-get install dmg2img; Step 2: convert the.dmg to.img. Once dmg2img is installed, you will want to change our working directory to the.dmg you want to use. In my case, the image.dmg is on my desktop. ( /home/dan/desktop ) cd /home/dan/desktop.
DMG files are proprietary disk image files used for software distribution in Mac OS. Providiing both password protection and bzip2-like compression, these files are perfect packaging medium.
Usually DMG files are opened automatically when you click them in Finder. They appear as a folder with files, but actually Finder mounts each DMG file as a separate filesystem and then shows you its contents. If you're observant enough, you'll see that in the left side panell of Finder you have all the active DMG filesystems listed and ready to be ejected once you finish copying the files or installing new software.
Sometimes you may want to download and mount DMG file using Mac OS command line, and in this post I'll show you how to do it
Why would you want to mount DMG files manually?
I've been business traveling quite a bit lately which means I'm most of the time away from my home computer. Naturally, I have configured Remote Desktop access so that I can use my iPad to access my desktop whenever I need, but sometimes it takes forever to do some simple things just because of the graphics environment overhead.
If you're like me, you'll probably find Remote Desktop over 3G to be pretty boring, and will want to do as much as you can via command line.
Mounting DMG with hdiutil command
In order to manually mount DMG file, you'll need to use hdiutil command. You don't have to be a privileged user, so can do it as your own user.
For this example, I'm going to use the command line interface (CLI) for the excellent HandBrake tool, which is great for converting all sorts of videos into iPad and iPhone friendly resolution and mp4 format
Let's mount the image from my dmg file:
Mastermind minions do not benefit from acc and dmg enhancements work. As you can see from this output, the mount was successful and you now have the filesystem from DMG package available under the /Volumes/HandBrake-0.9.8-MacOSX.6_CLI_x86__64 directory.
Don't want to to take my word for it? Let's use the standard mount command to confirm that indeed we now have an new filesystem mounted:
Ejecting mounted DMG images from command line
Once you are done with whatever you were trying to do, there's no longer a reason to keep your DMG image mounted, so you should unmount it. While it's possible to use umount command, I think it makes more sense if you use the same hdiutil tool that helped you mouunt the DMG image in the first place.
Here's how you can eject the DMG image using hdiutil:
Macos Mount Dmg In Terminal
That's it for today, hope you liked the post! Let me know!
These advanced steps are primarily for system administrators and others who are familiar with the command line. You don't need a bootable installer to upgrade macOS or reinstall macOS, but it can be useful when you want to install on multiple computers without downloading the installer each time.
Download macOS
Find the appropriate download link in the upgrade instructions for each macOS version:
- macOS Catalina, macOS Mojave, and macOS High Sierra download directly to your Applications folder as an app named Install macOS Catalina, Install macOS Mojave, or Install macOS High Sierra. If the installer opens after downloading, quit it without continuing installation.
To get the required installer, download from a Mac that is using macOS Sierra 10.12.5 or later, or El Capitan 10.11.6. Enterprise administrators, please download from Apple, not a locally hosted software-update server. - macOS Sierra downloads as a disk image that contains a file named InstallOS.pkg. Open this file and follow the onscreen instructions. It installs an app named Install macOS Sierra into your Applications folder.
- OS X El Capitan downloads as a disk image that contains a file named InstallMacOSX.pkg. Open this file and follow the onscreen instructions. It installs an app named Install OS X El Capitan into your Applications folder.
Use the 'createinstallmedia' command in Terminal
- Connect the USB flash drive or other volume that you're using for the bootable installer. Make sure that it has at least 12GB of available storage and is formatted as Mac OS Extended.
- Open Terminal, which is in the Utilities folder of your Applications folder.
- Type or paste one of the following commands in Terminal. These assume that the installer is still in your Applications folder, and MyVolume is the name of the USB flash drive or other volume you're using. If it has a different name, replace
MyVolume
in these commands with the name of your volume.
Catalina:*
Mojave:*
High Sierra:*
Sierra:
El Capitan: - Press Return after typing the command.
- When prompted, type your administrator password and press Return again. Terminal doesn't show any characters as you type your password.
- When prompted, type
Y
to confirm that you want to erase the volume, then press Return. Terminal shows the progress as the bootable installer is created. - When Terminal says that it's done, the volume will have the same name as the installer you downloaded, such as Install macOS Catalina. You can now quit Terminal and eject the volume.
* If your Mac is using macOS Sierra or earlier, include the --applicationpath
argument, similar to the way this argument is used in the commands for Sierra and El Capitan.
Use the bootable installer
After creating the bootable installer, follow these steps to use it:
- Plug the bootable installer into a compatible Mac.
- Use Startup Manager or Startup Disk preferences to select the bootable installer as the startup disk, then start up from it. Your Mac will start up to macOS Recovery.
Learn about selecting a startup disk, including what to do if your Mac doesn't start up from it. - Choose your language, if prompted.
- A bootable installer doesn't download macOS from the Internet, but it does require the Internet to get information specific to your Mac model, such as firmware updates. If you need to connect to a Wi-Fi network, use the Wi-Fi menu in the menu bar.
- Select Install macOS (or Install OS X) from the Utilities window, then click Continue and follow the onscreen instructions.
Learn more
For more information about the createinstallmedia
command and the arguments that you can use with it, make sure that the macOS installer is in your Applications folder, then enter this path in Terminal:
Catalina:
Mojave:
High Sierra:
Sierra:
Mount Dmg To Usb
El Capitan: