How can I mount an encrypted disk from the command line?
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.
Solution 1:
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.
Solution 2:
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
.