Force-mount unmountable disk images | 16 comments | Create New Account
Oct 06, 2016 Have you ever tried to format a disk in Mac OS X and Disk Utility won't Unmount the Hard Drive for formatting? It can happen for external (USB and Firewire) as well as internal disks. If the internal drive is causing the issue because the OS X Recovery exists as a partition on the physical disk, unable to modify or unmount the internal drive, then the preference must be given to a network drive or an external drive. There are many solutions when the user faces these problems. An AppleScript to mount, run, unmount a disk image. In reply to mmatties's question: the problem you came across (the app can't find the image) is EXACTLY what the script in the hint is designed to fix. It fixes the problem by NOT using the Finder to mount the disk, but by using a shell script. Nov 08, 2007 Having said that It is not a constant problem, some days all my mounted DMG files eject no problem, other days only a restart works. After a lot of experimentation and yelling at my screen I have found a temp solution if you have stuck mounted volumes and don't want to restart. Apr 12, 2009 OS X:: MacBook Internal HDD Won't Mount - How To Remount. Disk Utility initially showed the drive as mounted when I ran the application. I don't know what's happened as I did not unmount the drive. Verify Disk and Repair Disk quit because of errors.
Click here to return to the 'Force-mount unmountable disk images' hint |
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Great, Great, Great.
I am creating a lot of disk images at the moment for the distribution of a product and obviously I have to test those images. After mounting about 10 the Finder stops doing it's work as described in the hint. This problem exists even in 10.3.5 and I am very happy now, cause rebooting, the only solution I had figured out so far, really interrupts my work big time.
Thanks for the tip.
---
DubMaster
--
Rehab is for quitters!
I am creating a lot of disk images at the moment for the distribution of a product and obviously I have to test those images. After mounting about 10 the Finder stops doing it's work as described in the hint. This problem exists even in 10.3.5 and I am very happy now, cause rebooting, the only solution I had figured out so far, really interrupts my work big time.
Thanks for the tip.
---
DubMaster
--
Rehab is for quitters!
I have an image that is password protected, and it still doesn't mount with this hint. Here's the output from terminal. Since the GUI password box came up on the display, I suspect that whatever OSX bug the command line evades is non-evaded when the PW function is called. Another encrypted image that mounts ok in the standard way (double-click) mounts fine using hdiutil. Haven't tried rebooting to see if that lets me mount the first image.
AppleScript to Force-mount unmountable disk images
Os X Unmounted Dmg Wont Remount Download
Apr 30, 2017 How to mount and unmount drives in macOS and OS X from the command line. April 30, 2017. Unmounting external drives on a Mac is usually done quick and simple by either dragging drive icon to the trash, or by using the eject symbol in a Finder window.
It just so happens that we already built an AppleScript solution using this method; I'll paste it below for those who are Terminally challenged. As for the issue with password protected disks, this script will indeed trigger a GUI window asking for any such passwords not already stored in Keychain. I have yet to find an instance where presentation of the password box triggered the failure we're looking to overcome in this hing, but the -stdinpass switch would likely resolve it (see the man page), and could be added to this script. Sorry about the code wraps, Rob, I tried to install AS returns, but they wouldn't deal with the line wraps any better because of the parentheticals.
AppleScript to Force-mount unmountable disk images
[Rob, you can delete the post above (when are we going to get edit privileges?) if you want; I modified the script to fit nicely--F]
It just so happens that we already built an AppleScript solution using this method; I'll paste it below for those who are Terminally challenged. As for the issue with password protected disks, this script will indeed trigger a GUI window asking for any such passwords not already stored in Keychain. I have yet to find an instance where presentation of the password box triggered the failure we're looking to overcome in this hing, but the -stdinpass switch would likely resolve it (see the man page), and could be added to this script.
It just so happens that we already built an AppleScript solution using this method; I'll paste it below for those who are Terminally challenged. As for the issue with password protected disks, this script will indeed trigger a GUI window asking for any such passwords not already stored in Keychain. I have yet to find an instance where presentation of the password box triggered the failure we're looking to overcome in this hing, but the -stdinpass switch would likely resolve it (see the man page), and could be added to this script.
AppleScript to Force-mount unmountable disk images
Man, it is amazing how fast folks around here report bugs. Sorry for the oversights; the script was originally written for single DMGs, and I added multiples without really testing it or thinking it through; also we rarely use a special character in a file path because we're so used to working on the web. All bugs should be resolved, except those idiosyncracies that exist with name problems in hdiutil (such as 'image already specified' errors).
AppleScript to Force-mount unmountable disk images
Now, if you could add an 'on open' handler that handled drag-and-drop, you'd be all set! Just drag your dmg files onto the script and they would mount. No file dialog to get in the way.. :-)
AppleScript to Force-mount unmountable disk images
Hi there...
Well, I tried both versions of your script on several disk images (including one that I KNOW mounts fine by itself), and most of them were grayed out in my file dialog. My first thought was that perhaps they were corrupted, but at least one of them mounts fine on its own, and it was not accessible either.
I very much appreciate your scripting skills, but do you have any idea why I might be having such problems? Any suggestions from anyone else out there? I would really appreciate the help!
Thanks in advance,
mlaurenc
Well, I tried both versions of your script on several disk images (including one that I KNOW mounts fine by itself), and most of them were grayed out in my file dialog. My first thought was that perhaps they were corrupted, but at least one of them mounts fine on its own, and it was not accessible either.
I very much appreciate your scripting skills, but do you have any idea why I might be having such problems? Any suggestions from anyone else out there? I would really appreciate the help!
Thanks in advance,
mlaurenc
AppleScript to Force-mount unmountable disk images
![Wont Wont](/uploads/1/2/5/3/125378783/668722837.jpg)
I may just be a big newbie, (and I undoubtably am), but when running this script the only items I could select when it asked me which DMG I wanted to mount were file folders and no DMG files. Even with a foler selected, 'Choose' never highlit. Am I doing something wrong?
Also, is there an applescript super newbie thread I should be hitting up before getting to knee deep in this?
by the way, rebooting still didn't allow me to mount the DMGs. I'm running 10.3.7.
Thanks for any/all help guys!
-Seth
Also, is there an applescript super newbie thread I should be hitting up before getting to knee deep in this?
by the way, rebooting still didn't allow me to mount the DMGs. I'm running 10.3.7.
Thanks for any/all help guys!
-Seth
AppleScript to Force-mount unmountable disk images
I may just be a big newbie, (and I undoubtably am), but when running this script the only items I could select when it asked me which DMG I wanted to mount were file folders and no DMG files. Even with a foler selected, 'Choose' never highlit. Am I doing something wrong?
Also, is there an applescript super newbie thread I should be hitting up before getting to knee deep in this?
by the way, rebooting still didn't allow me to mount the DMGs. I'm running 10.3.7.
Thanks for any/all help guys!
-Seth
Also, is there an applescript super newbie thread I should be hitting up before getting to knee deep in this?
by the way, rebooting still didn't allow me to mount the DMGs. I'm running 10.3.7.
Thanks for any/all help guys!
-Seth
While this is a nice workaround - I really wish the problem would be solved instead. Very annoying. On my machine - happens everyday after about my tenth disk mount. The image actually appears to get mounted and appears in /Volumes but it shows up no where else and is impossible to access.
I must say, it doesn't happen much with me. But if it shows up in /Volumes, you should be able to refresh the finder by doing 'disktool -r'. I am writing a script that triggers mounting of dmg and the 'disktool -r' seems to solve some of my problem.
Good luck
Good luck
I tried this Hint for the first time today, but I didn't appear to have the relevant utility. Typing in hd and tab brought up
hdiutil
which is not the command quoted in the actual command string in the Hint.
Anyway, I tried hdiutil, and it tried to attach the dmg, but failed with the same problem: no mountable file systems. <sigh>
Back to restarting...
from Clytie, still having trouble
---
Clytie Siddall -- Renmark, in the Riverland of South Australia
iBook G3, 10.3.5, all updates current
hdiutil
which is not the command quoted in the actual command string in the Hint.
Anyway, I tried hdiutil, and it tried to attach the dmg, but failed with the same problem: no mountable file systems. <sigh>
Back to restarting...
from Clytie, still having trouble
---
Clytie Siddall -- Renmark, in the Riverland of South Australia
iBook G3, 10.3.5, all updates current
Yeah, 'hdituil' is a typo.
Unfortunately, this didn't work for me. :-(
---
Ron
---
Ron
I tried the applescript but nothing is highlight-able
---
Infants are born. Children learn as they grow. Knowledge is power. Information in the wrong minds is deadly!!!
---
Infants are born. Children learn as they grow. Knowledge is power. Information in the wrong minds is deadly!!!
Same here
It won't work
---
Infants are born. Children learn as they grow. Knowledge is power. Information in the wrong minds is deadly!!!
It won't work
---
Infants are born. Children learn as they grow. Knowledge is power. Information in the wrong minds is deadly!!!
<OS X Daily>
This trick works with external USB disks, hard drives, Firewire, Thunderbolt, DVD’s, CD’s, network drives, even USB thumb drives, literally any volume that can be mounted and accessed through the incredibly helpful diskutil command. By using the command line to remount the drive, the entire process can be completed remotely if necessary through SSH, and without ever having to physically disconnect a drive from the Mac. This is infinitely useful for troubleshooting situations, for scripting and automation, and it’s a great trick for those of us who just like to tinker around in Terminal.
Unmount a Drive from the Command Line
Let’s first cover unmounting drives. To do this you’ll need another volume attached or connected to the Mac in some form or another, then launch Terminal to get started (sits in /Applications/Utilities/).
1: List All Drives
The first thing you’ll need to do is list the connected drives. This will provide a list of all drives that are attached to the Mac, that are either mounted and unmounted, and all of their respective partitions. We are doing this so we can get the drive identifier, which is typically something like disk1s2, or disk2s2, etc
diskutil list
The output will look something like this:
$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *16.0 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_HFS OSXDaily 15.7 GB disk1s2
For the sake of this example, we’ll focus on the attached drive named “OSXDaily”, which happens to be an external USB thumb drive that appears last in the list. Note the identifier for that drive is “disk1s2″ and we’ll carry that to the next series of commands to unmount and remount it.
It’s probably worth mentioning that drives will always be located in /dev/ and thus /dev/ will always be prefixed to the identifier.
2: Unmount the Specified Drive
Still using the diskutil command, we’ll point it at the drive in question to unmount.
diskutil unmount /dev/disk1s2
This will report back the named volume and location has been unmounted, like so:
$ diskutil unmount /dev/disk1s2
Volume OSXDaily on disk1s2 unmounted
That’s all there is to it. You’ll notice the drive is no longer accessible in Finder, but it will still be visible through diskutil from the command line, or the more familiar Disk Utility app in OS X’s GUI.
Mount a Drive from the Command Line
If you can unmount a drive, of course you can mount or remount one too. The command sequence is very similar; locate the volume, then mount the drive.
1: Find the Drive to Mount
If you already know where the volume is located, you can ignore part 1 and jump straight to part 2, but let’s cover retrieving the volume identifier anyway. This time around we’ll shorten it a bit because we’ll assume we know the name of the drive to mount, thus we only need to locate the identifier. We’ll do this by using grep to shorten the output of the diskutil command like so:
$ diskutil list |grep OSXDaily
2: Apple_HFS OSXDaily 15.7 GB disk1s2
That output is obviously much shorter than the full output of diskutil list which we showed above.
For this example, the drive “OSXDaily” is still located at /dev/disk1s2 and that’s what we’ll mount.
2: Mount (or Remount) the Drive
To mount (or remount) a drive, we’ll use the same diskutil command with a new flag and inputs like so:
diskutil mount /dev/disk1s2
Using the same examples as elsewhere, here is what the command and the output will look like:
$ diskutil mount /dev/disk1s2
Volume OSXDaily on /dev/disk1s2 mounted
This obviously mounts the drive again, and it will also make the mounted volume visible again in the OS X Finder and to GUI-based apps in the various Open or Save dialog boxes.
Unmount & Remount a Drive / Volume in a Single Command
Want to quickly unmount and remount the same volume, essentially power cycling it’s connectivity to the Mac? You can do that in a single command by stringing the two together like so:
diskutil unmount /dev/disk1s2;diskutil mount /dev/disk1s2;echo 'Remounted Volume'
This would look like the following when executed:
$ diskutil unmount /dev/disk1s2;diskutil mount /dev/disk1s2;echo 'Remounted Volume'
Volume OSXDaily on disk1s2 unmounted
Volume OSXDaily on /dev/disk1s2 mounted
Remounted Volume
If you happened to be watching the volume in the Finder during this process, you would find it to disappear briefly, then reappear almost immediately. The last echo portion is optional but it makes the entire command action even more verbose.