hdiutil

Latest

  • Daily Mac App: FlashMount quickly mounts disk images

    by 
    TJ Luoma
    TJ Luoma
    12.30.2011

    DMG files are often used when distributing Mac software outside the Mac App Store. While DMGs can be confusing to new users, I like them because they allow me to keep an original, unmodified version of whatever program I have downloaded. About the only drawback for me is that some DMGs come with an EULA which has to be accepted before the DMG will be mounted. If the EULA window gets covered up, it can be frustrating to try to figure out why it has not mounted. EULAs can also make DMGs unreliable to mount in shell scripts. While looking for a solution, I came across references to an application called "FlashMount" which was designed to do exactly what its name implies: mounts disk images (dmg, iso, etc) in a "flash." It also automatically accepts any EULA which is presented. OK, sure, we all know we are supposed to read them first. If you do, feel free to skip this app. FlashMount also skips the verification of disk images before mounting. That sounds bad, but in reality, if the disk image is corrupted or incomplete, it probably won't mount anyway. The only time I have ever seen a corrupted DMG, it was an incomplete download. Some disk images don't even have a checksum to verify against, but depending on the size of the DMG, verification can take a long time. On a 1.2 GB DMG, verification takes almost 3 minutes on my MacBook Air. Without verification, I can mount that same disk image in two seconds. Still, if that's not a risk you're comfortable with, this probably isn't the app for you. Otherwise, FlashMount is fast, handy, and free. Download After reading about FlashMount, I was sold on the potential usefulness of this app, but there was one problem: all the download links I found were broken. The articles which talked about FlashMount linked to "www.liquidnexus.com" which was the original site where the app was hosted by its developer. However, sometime in the past few years, the domain registration must have lapsed and been re-registered by a domain squatter (which is why I have not actually linked to it here). Eventually I found a site which had mirrored the download on their own server. Warning: linked website is fairly awful. If you'd rather avoid that, you can download FlashMount 1.5.2 (188K, MD5 sum = 43522f417ae5ccf4f883fc049c8fd0c1) from my personal website. A one page PDF overview is also available. The good news is that the app seems to work perfectly under Lion. I've made FlashMount the default app for opening DMG and ISO files on my Mac, and if I run into any trouble with a particular file, then I open it with DiskImageMounter. However, I found an even better solution if your goal (like mine) is mounting DMGs in Terminal, even if the DMG has a EULA and needs to be mounted by a non-interactive script. Here's where things get nerdy While I was investigating the app, I realized that the whole thing was basically a wrapper around a simple shell script: #!/bin/sh -f echo "Y" | /usr/bin/hdid "$1" #if ($status != 0) exit% I was not familiar with hdid (I had always used hdiutil for mounting DMGs on the command line) but it worked. Sending echo "Y" tells hdid to accept the EULA. (It's important to note that you are not subverting, bypassing, or avoiding the EULA, you are doing on the command line what most people do with the mouse: accepting it without reading it.) I started building on that and made my own script, which I called flashmount.sh. It uses the same echo "Y" trick as the original, but it adds some extra error checking. It also adds an option to verify disk images if you use the '-v' flag, like this: flashmount.sh -v foo.dmg which is handy for those times when you do want to verify an image before you mount it. If the disk image successfully mounts, the script will output the mounted path, which will be something like "/Volumes/Flashmount/" or similar. You can download my flashmount.sh if you want. You could even wrap it up as an app with Platypus if you don't trust the FlashMount.app. FlashMount isn't going to change your life, but it can make one part a little easier and a little faster.