How to mount and unmount drives in macOS and OS X from the command line

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. Mounting usually happens automatically when a new drive is inserted into a USB port or SD card slot.

However, there is a way to do this via the command line, of which I am a big fan. Fire up a Terminal session and see how to do it.

Listing available drives

To see what’s currently attached to your Mac, let’s use the diskutil command, followed by the word list. You’ll see output like this:

diskutil list

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *512.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh SSD           511.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3

/dev/disk1 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk1
   1:                        EFI EFI                     209.7 MB   disk1s1
   2:                  Apple_HFS Mac HDD 1TB             999.9 GB   disk1s2

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 TB     disk2
   1:                  Apple_HFS VM Drive 

Attached drives are listed with their physical locations on the left (i.e. /dev/disk0, /dev/disk1, etc), as well as with their respective partitions if available on the right (like disk0s1, disk1s2, etc). Make a mental note of the latter: you’ll see that we have a physical disk (like disk0), on which several partitions may have been created. It is those partitions we’ll mount and unmount, NOT the physical drive.

Unmounting an attached hard drive

On my system I have two internal hard disks (disk0 and disk1), and one external USB drive (disk2). Let’s unmount that USB drive now:

diskutil unmount /dev/disk2s1

Volume VM Drive on disk2s1 unmounted

Note how we use the unmount command. We need to specify the location of the partition with its full path (i.e. /dev/disk2s1).

Mounting an attached hard drive

To mount the drive again, without having to take it out and plugging it in again, I can issue this command:

diskutil mount /dev/disk2s1

Volume VM Drive on /dev/disk2s1 mounted

Jay is founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices. He blogs about his coding journey at and

You can leave a comment on my original post.