22

When I type diskutil mount disk3 in the terminal, it says Volume(s) mounted successfully. However, the disk is not mounted and I can confirm this by opening the GUI of Disk Utility.app and also the disk does not show in the Finder.

I suspect this is because the disk is encrypted and the terminal command is not passing via "Keychain" to retrieve the password for the encrypted disk.

What do you think? Is there a way to mount encrypted disks via the command line?
Thanks.

5 Answers 5

31

You want to run diskutil coreStorage unlockVolume <UUID>, where the UUID is the Logical Volume UUID associated with your encrypted disk, /dev/disk3. You can get the lvUUID by running diskutil cs list in the terminal and looking for the output related to /dev/disk3. The identifier is a long string that would look something like this 'B807C2A0-577F-3DB0-9002-F82B9137696C'.

It will prompt you for a password at that point and if it's correct, unlock the disk.

2
  • 3
    This worked great. It should be said that when you do a diskutil coreStorage list, you may encounter a stack of such ID's representing the device. In my case, the stack looks like: Logical Volume Group, Physical Volume, Logical Volume Family, and finally Logical Volume. You want to use the ID shown with Logical Volume, which is the last one, for your unlockVolume call. Commented Oct 17, 2016 at 18:28
  • 6
    Note for modern apfs file systems you should use diskutil apfs unlockVolume and diskutil apfs list
    – Max Coplan
    Commented Sep 4, 2019 at 22:24
10

You can use hdiutil to mount a disk image that is protected with a passphrase.

hdiutil attach -agentpass /path/to/image.dmg

That should attempt to mount the disk image, prompting you for the passphrase. If it's encrypted with a public key, you can pass that using option -pubkey.

4
  • Thanks. This isn't quite what I"m looking for. It doesn't ask for the password the disk is encrypted with. It asks for my local account password twice before attaching the disk.
    – josswinn
    Commented Mar 4, 2012 at 7:40
  • 3
    Oddly enough it only prompts me for a password when I omit the -agentpass option. Commented May 13, 2013 at 9:17
  • 1
    Your answer, using hdiutil, has nothing to do with the OP and question asked, which was about mounting an encrypted disk from the command line, not an encrypted disk image, which are two different things! foundling's answer, using diskutil, is the correct answer! Commented May 1, 2016 at 20:00
  • Good answer. hdiutil is the answer for another related question I had: how to unmount encrypted dmg and "lock" it for it start to ask password on new mount. Answer is hdiutil eject /Volumes/your_volume Commented Aug 18, 2017 at 18:02
2

I can't see what I'm doing differently today, but

diskutil unmount disk3           

and

diskutil mount disk3        

are working fine and properly unmounting and mounting the HDD and it is viewable in the Finder. Encryption doesn't seem to have anything to do with it.

1
  • 1
    Are you answering your own question here? If so, is your answer that the problem simply went away?
    – Daniel
    Commented Mar 6, 2012 at 7:01
0

Enter Recovery Mode. Open Terminal app. Launch Disk Utility app from the command line by executing:

/Applications/Utilities/Disk\ Utility.app/Contents/MacOS/Disk\ Utility

Select the lock drive and click mount. It will prompt for a password if encrypted

You can then enter your root volume normally.

0

You can unlock via CLI like so:

diskutil mount DiskName
diskutil apfs unlockVolume DiskName -passphrase 12345

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .