If you cd- change directory to the mounted filesystem then you must cd out of the filesystem before you can eject it. As an example
cd; diskutil eject /Volumes/<volume name>
cd: changes the current working directory to your home folder
diskutil: ejects the filesystem
There is one case where the tab needs to be closed. Sometimes the initial working directory is on the volume. (This can happen if you open a new tab from an existing tab that is visiting the volume.) When this happens, two processes are initially using the volume: login
, and the shell it launches. cd
will change the working directory in the shell, but won't affect the login
process. The only way to make login
stop using the volume is to close the tab.
If you're not sure which tab(s) to close, you can use lsof
:
sudo lsof -a -c login /Volumes/<volume name>
This command will show the process IDs (and other info) for all login
processes that have open some subdirectory of the volume. With the process ID, you can either:
- (if Terminal is configured to show the TTY name in the title):
- get the controlling terminal with
ps
(ps -o tty -p <login pid(s),>
)
- find the relevant tabs from the Window menu
- close them
- more simply, shut down the relevant
login
by sending it/them a SIGHUP (kill -HUP <login pid(s)>
)
cd
to the volume, how exactly did you rundf -h
?df -h
. It list all connected volumes.