Mount & Unmount Drives from the Command Line in Mac OS X

May 13, 2013 - 45 Comments

Terminal The easiest way to unmount a drive in OS X is to either just drag a volume into the Trash, use the eject keys, disconnect the drive, or use one of the force eject methods. Along the same lines, if you want to remount a drive you can usually just physically unplug the drive and plug it back again. But what if you want to be able to mount, unmount, and remount drives from the command line? That’s exactly what we’ll cover here.

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
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
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.

Mount and unmount drives from the command line in Mac OS X

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.

Thanks to Nilesh for the tip inspiration

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks


» Comments RSS Feed

  1. Bayesrisk says:

    Pretty good help. I need the next step, though.

  2. Nittn says:

    i am getting following reply – need help, thanks

    Volume LaCie on disk2s1 timed out while waiting to unmount

    • Will Kallhoff says:

      I am having the same issue. Did you find anything out?

    • Wendy says:

      Same thing. How did you resolve this?

    • xira says:

      me too!
      i got this message when i mount it :
      “Volume on disk1 timed out waiting to mount”
      please help !

    • xira says:

      me too ! please help :(

      • Raphael says:

        So I was trying various methods mentioned on this forum

        My external HD was disconnected accidentally and it wouldn’t show up on my desktop, only on my disk utility while blinking rapidly. The HD under the indented section on the left panel would be in grey. When I ran “verify disk” and “repair” it said it couldn’t be repaired and needed to be repaired.

        the wd support (I have a wd passport 2tb) to no avail. I’ve tried
        -terminal (got the same message as you did)
        -disk utility as mentioned above
        -unplug, shut down the computer, restart
        -restart the computer while the external HD is plugged in, and repeat the disk utility step.
        -deleted finder plist

        Nothing worked until I tried the most crude method mentioned on the forum as my last resort: shut down the computer manually(close all apps, press down the power button until it shuts off) with the external HD still plugged in, then started it back up and it worked! Hope this is helpful.

  3. Frank says:

    Thanks! My HD won’t sleep after unmount. To achive that I used diskutil eject /dev/disk1s2 or even diskutileject MyHDsVolumenName

  4. Phillip Lovgren says:

    I’m able to mount my external OWC FW800 drives using Apple’s Disk Utility. It seems to unmount a mount my USB3.0 thumb drive also.

  5. M. Mossman says:

    OMG. This is the best tip I’ve found. I would have died if I lost everything on my external hard drive. You saved my HD many times because of this tip alone. I’ve have people pull out my HD without ejecting it properly…sometimes I do too…and my Adata HD always unmounts itself.
    Thank you thank you thank you.


  6. Garrett Blair says:

    Hi there

    What if the disk fails to mount?

    • volkansal says:

      diskutil unmount /dev/disk1s2;diskutil mount /dev/disk1s2;echo “Remounted Volume”
      Unmount failed for /dev/disk1s2
      Unable to find disk for /dev/disk1s2

      can you help me?

      • ph says:

        Use diskutil list to see where the drive is mounted, its not mounting because it can’t be found, you’re pointing it at the wrong thing.

        • So then says:

          When I do diskutil list, it only comes up with:

          $ diskutil list
          0: GUID_partition_scheme *500.1 GB disk0
          1: EFI EFI 209.7 MB disk0s1
          2: Apple_HFS Macintosh HD 499.2 GB disk0s2
          3: Apple_Boot Recovery HD 650.0 MB disk0s3

          Therefore, I have no idea what to be pointing it at…any ideas?

  7. Jeet says:

    Hi my external HDD is not getting mounted. Its visible in the disk utility but can’t be verified or repaired. I followed the above command line to mount the HDD but it still couldn’t be mounted. this is what the result says:

    0: FDisk_partition_scheme *2.0 TB disk2
    1: Windows_NTFS Yaanus Movies 2.0 TB disk2s1

    $ diskutil unmount /dev/disk2s1
    disk2s1 was already unmounted

    diskutil mount /dev/disk2s1
    Volume on disk2s1 failed to mount


  8. cyberpi says:

    Hi my external HDD is not getting mounted. Its visible in the disk utility but can’t be verified or repaired. I followed the above command line to mount the HDD, but it still couldn’t be mounted. This is what the results say:

    0: GUID_partition_scheme *160.0 GB disk0
    1: EFI EFI 209.7 MB disk0s1
    2: Apple_HFS Macintosh HD 159.2 GB disk0s2
    3: Apple_Boot Recovery HD 650.0 MB disk0s3
    0: GUID_partition_scheme *250.1 GB disk1
    1: EFI EFI 209.7 MB disk1s1
    2: Apple_HFS 249.2 GB disk1s2
    3: Apple_Boot Recovery HD 650.0 MB disk1s3
    $ diskutil mount /dev/disk1s2
    Volume on disk1s2 failed to mount
    $ diskutil unmount /dev/disk1s2
    disk1s2 was already unmounted
    $ diskutil mount /dev/disk1s2
    Volume on disk1s2 failed to mount

    What am I doing wrong or what is the issue? I need mount disk1s2. It is an external HDD with an Apple file system. I am trying to retrieve my personal data. It crashed due to the Yosemite upgrade.

  9. Tom says:

    I needed to have the command and the redirect executed together so it had permissions to /etc/fstab:
    sudo sh -c ‘echo “LABEL=MYDRIVE none ntfs rw,auto,nobrowse” >> /etc/fstab’

  10. Jesse says:

    For the trick with unmounting and remounting a drive, just in case anything were to go wrong in the process, it would be better to replace the inner semicolons with double-ampersands (that way, the remount is only attempted if the unmount were successful, and the success message would only be echoed if success actually occurred):
    diskutil unmount /dev/disk1s2 && diskutil mount /dev/disk1s2 && echo “Remounted Volume”

  11. Sara says:

    My external drive won’t unmount, says it’s busy?????

  12. Vijay says:


    My situation is like, my disk got locked and tried to mint it and it’s giving me this msg disk0s2 is FileVault or fusion drive physical volume; use “disputing corestorage list” to find its logical volume, which you can then unlock and mount

    How I can unlock my disk please help me out
    M in very bad situation and my drive is a fusion drive

  13. Wally says:

    My external drive is now greyed out in Disk Utility (though the repair function works and says the disk is OK). The disk permissions option is missing. How do you get “permission” to mount the disk. Nothing seems to work.

  14. Blaise says:

    I did the remount option and it says “Volume on disk2 failed to mount; if it has a partitioning scheme, use “diskutil mountDisk”
    If the volume is damaged, try the “readOnly” option”

    not sure what to do next.

    Also, it shows up in my disk utility in grey. Is there a way to at least get the files off of it if it is damaged?

  15. Sameh says:

    Hi in terminal reply comes that disk1 mounted “it is the 1st partition” in my external hard disk but it fails to mount the 2nd partition.
    also I don’t see the partitions in the disk utility, I want to format the 2nd partition OS X Journaled for time machine backup.
    would you please help ?

  16. Sas says:

    Strange issue. Name of drive’s identifier does not appear! Help, anyone!

    /dev/disk2 (external, physical):
    0: GUID_partition_scheme *1.0 TB disk2
    1: EFI EFI 209.7 MB disk2s1
    2: Apple_HFS 999.9 GB disk2s2

    • kfl says:

      I can report about the same thing here. — 1 TB WD My Passport, + El Capitan.

      Greyed out, unmountable. No disk identifier!

      Is this one of the problems that I hear rumors about w/r/t El Capitan problems. Come to think of it, the other issue is with MOTU audio interfaces, so maybe there is a major USB issue?

  17. Devon says:

    Thanks man!
    This saved my Harddisk it wouldt come up at finder only disk utility.
    Now its reconized, going to make a big backup and send it back :)

    Many many thanks

  18. lino says:

    Hi, thanks for this! when i type diskutil list, i see 2 hard drives and my ssd. I do not see the external dvd writer listed.

    I do see it under disc burning and I can see the player with toast but cannot mount anything, data or dvd discs.

    How can toast see it but not any other apps?

    disc burning: PIONEER BD-RW BDR-208D:

    I tried the csrutil disable but still dont get discs mounted.

    thanks for any suggestions!

  19. JB says:

    In the “power cycling” part, instead of using ; at the end of the command, use &&, which makes sure that the previous command is successful before doing the next command(so you don’t mount the drive while it is already mounted, etc).

  20. CL says:

    tried terminal command to mount disk that i cannot mount with disk utility. but looks like this is basically the same thing as using disk utility. basically same result: terminal says: “Unable to find disk for …” That disk is greyed out in Disk Utility. DU says to repair disk and then try mounting again. But repair returns/fixes no errors. but disk still wont mount. oddly, it was just mounted on a different computer. i shut that computer down, to move disk to a different computer; and suddenly it stopped mounting.

  21. KP says:

    This definitely does work, it just takes some time. If the light on your hard drive is blinking or you can hear the motor spinning, that means you Mac is trying to read it. It may time out, so you have to continue to prompt the disk utility to unmount, even if it says that the disk is already unmounted. Mine finally unmounted after about ten tries. Then I typed the command to mount and it did. You have to be patient and stay at it. Remember that you are working with a machine.

  22. Chris says:

    To unmount you don’t need to find the /dev/disk… name: just use the /Volumes/whatever name.

    I have two simple shell scripts to make this easier because I can never remember the detail:
    hdiutil eject /Volumes/LaCie
    set -e
    dv=`diskutil list | grep LaCie | sed -E ‘s/^.+(disk.+$)/\1/’`
    diskutil mount /dev/”$dv”

  23. Ben says:

    If you want to fully automate the process of ejecting the disk based on a partition name, this should do the trick:

    diskutil list | grep PartitionNameOnDisk | tr ‘ ‘ ‘\n’ | grep disk | sed ‘s/s.$//g’ | xargs diskutil eject

  24. Kelly says:

    If you connect a damaged disk, and the light indicates heavy activity but the OS does not immediately complain or appear to mount the disk, it is likely running fsck in the background.

    In my case, I noticed that fsck was going through an error/repair/recheck loop continuously, and not fixing the problem. However, after a very long time it would sometimes mount the disk in read-only mode, and tell me that the disk could not be repaired and I should copy files I needed as soon as possible.

    I found that if I killed the fsck process, it would skip right to mounting it as read-only (which, if you have a damaged disk, is probably the best you can hope for).

    To kill the fsck process, first find it by doing:

    ps waux | grep fsck

    Note the second column (a number) will be the process ID (e.g. 88888). Use that number (not 88888) to kill the process:

    sudo kill -9 88888

    Hopefully this helps someone, because I was looking for a way to cut off the useless repair process and just mount it read-only, but the “diskutil mount readOnly” wouldn’t work if fsck was busy operating on the disk.

    • DMurray says:

      Great advice – found the fsck process in Activity Monitor, killed it and very shortly after, the drive mounted.

    • camilla says:


      I have tried everything that has been mention on the above comments, and were now trying this but i am not sure what number i sould use? The disk that will not show up is the one reffered to as disk2s2, and i could see the fsck activity as you mentioned. When i ran the comando this came up:

      root 785 21,3 12,6 3510292 1053384 ?? U 11:56pm 1:21.46 /System/Library/Filesystems/hfs.fs/Contents/Resources/./fsck_hfs -y /dev/disk2s2
      *my name on the computer that i do not want on the internet* 855 0,0 0,0 2432804 1976 s000 S+ 12:00am 0:00.00 grep fsck

      I hope that you can help me!

  25. Ces says:

    I just had the same problem. Time machine external became unmountable in (running El Capitan) but I also tried it on a different mac running Leopard (yes,) still didn’t mount. Tried disk repair, tried First Aid. It would say all good, but the drive would NOT mount. I could see it in Disk Utility (on both OS’s). Even tried terminal, and force mount on terminal and it’d give me the whole try Read Only mount –also didn’t work. Called Apple and THEY couldn’t help either (after asking me if i tried everything -which I had) So I bit the bullet and bought DiskWarrior for $128 and crossed my fingers. IT WORKED. It could access the drive and instead of rebuilding the drive’s directory I made it copy my files to a new external. Doing it now. (SIGH…..) months and months of files saved.

    • Ces says:

      I should also add – DiskWarrior was the first program I tried. I read not so great reviews on others, but I’m glad the first one worked.

  26. Daniel says:

    This worked for me, thank you!
    My WD external hard drive wasn’t showing up in finder but worked in my PS4. I simply followed the instructions and it worked.

    diskutil list
    diskutil unmount /dev/disk2
    diskutil mountDrive /dev/disk2

  27. Lalitha Sundararajan says:

    I have a macBook air. I did a list on the terminal command window and showed the following removable disks. I tried to dismount both of them, the reply I received I am copying below:

    /dev/disk2 (external, physical):
    0: *1.0 TB disk2

    /dev/disk4 (external, physical):
    0: *1.0 TB disk4

    Charus-Air:~ lsr$ diskutil unmount /dev/disk2
    disk2 was already unmounted or it has a partitioning scheme so use “diskutil unmountDisk” instead
    Charus-Air:~ lsr$ diskutil unmount /dev/disk4
    disk4 was already unmounted or it has a partitioning scheme so use “diskutil unmountDisk” instead
    Charus-Air:~ lsr$

    Is it advisable to do “diskutil unmountDisk”? I am afraid to do that because what will happen to the internal drives if I do the “diskutil unmountDisk”?
    Any help will be appreciated

Leave a Reply


Shop for Apple & Mac Deals on

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates