Tip to help eject disks that are "in use"

Posted:
in macOS edited January 2014
I don't know if you ever try to eject a disk and get that annoying message:



The disk x is in use and could not be ejected



but it doesn't say what is in use. Normally, I would just quit programs at random trying to find the culprit but there's an easier way with the terminal.



Just type:



diskutil list



in the command line to get something like:



/dev/disk0

#:------- type----------name----size-----identifier

0:-Apple_partition_scheme--------*37.3 GB---disk0

1:---Apple_partition_map---------31.5 KB---disk0s1

2:--------Apple_HFS-----Data----37.2 GB---disk0s3



The disk has identifier /dev/disk0. The partition I call Data, which is my system volume has identifier /dev/disk0s3.



Now let's say that's the drive I wanted to eject but can't. To list open files on that volumes, type:



lsof /dev/disk0s3



Then it will tell you what apps to quit. Sometimes these apps might be daemons but you can quit these using the process viewer. Once you do so, you should be able to eject the drive. I get this trouble a lot because I have a clone of my internal drive so often the open with dialog sometimes chooses the same apps on my external drive.



Another thing is if you need to mount a drive again, you don't need to unplug and plug it back in either. Just load Disk Utility and the partition will be greyed out. Select this and click mount.

Comments

  • Reply 1 of 3
    Always nice to learn new Unix commands. thanks
  • Reply 2 of 3
    jabohnjabohn Posts: 582member
    Makes you wonder why OS X doesn't help you out in this manner. Didn't OS 9 tell you what application was using the disk?
  • Reply 3 of 3
    MarvinMarvin Posts: 15,325moderator
    Quote:

    Originally posted by jabohn

    Makes you wonder why OS X doesn't help you out in this manner. Didn't OS 9 tell you what application was using the disk?



    I actually thought it did too but it's been so long since I used it I can't remember. Another thing I still miss is that dialog in OS 9 that told you how much space was used in trash and how many files were in there before you emptied it.



    Relatively speaking, these are pretty simple features but so useful. Y'know for all the innovations Apple come up with, I would give some up for those useful things back. I have never once made a smart folder nor felt the urge to and my use of Dashboard is practically zero these days.
Sign In or Register to comment.