Created
September 22, 2012 04:55
-
-
Save gnrfan/3765172 to your computer and use it in GitHub Desktop.
Bash script for killing all processes that are using a volume in Mac OS X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # This script helps when you're getting this kind of error on a Mac: | |
| # | |
| # "The volume can’t be ejected because it’s currently in use." | |
| # | |
| # Just copy this script to /usr/bin/free-volume or somewhere else you | |
| # want and then call it passing the path to the volume you want | |
| # to free. | |
| # | |
| # Example: free-volume /Volumes/Iomega_HDD | |
| # | |
| # WARNING: This script kills all process currently using the volume | |
| # so use it at your're own risk when you are sure you aren't performing | |
| # any important operation with the disk and the OS is simple refusing to | |
| # unmount it. | |
| # | |
| # Once you've run it you can safely unmount the volume the usual way. | |
| # | |
| kill -9 `lsof $1/|awk '{ print $2 }'|grep -v PID|sort|uniq|tr '\n' ' '` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment