Anyone can unmount a usb drive from Finder by clicking on the "eject" icon next to it. However, only a user with administrative privileges can unmount a drive from the terminal using umount
.
Are umount
and "eject" different in some way that requires more security for umount
from the terminal?
Note I am running OS X 10.8.2
Best Answer
umount
is a UNIX command that adheres to the traditional UNIX perspective that unmounting a filesystem is a system administration task.The rationale behind is that unmounting a filesystem, if poorly planned or executed, could be disruptive, even destructive, especially on a multiuser system. So regular users are protected from this potentially dangerous command and only root or a privileged user is allowed to execute it.
This makes a lot of sense when UNIX is used as a server operating system, but a UNIX-based desktop OS (for example, OS X or Ubuntu) has other needs: any user should be able to unmount flash drives, removable harddrives, etc.
The Finder and
diskutil
(see man diskutil for more information) work this way. For example, I can open Terminal and successfully run:whereas
umount
fails:What is the Finder or
diskutil
doing differently? Behind the scenes, they send a request to a daemon called com.apple.SecurityServer (see man page for more information), which grants the right to unmount the filesystem:This allows any user to unmount a drive without requiring additional authentication. (Ubuntu has a similar philosophy. If you are interested, take a look at this answer on AskUbuntu.)
To support the behavior explained above the Finder and
diskutil
use several Apple frameworks:umount
, on the other side, is only linked to this dynamic library:(
/usr/lib/libSystem.B.dylib
uses several other libraries, but isn't linked to any framework.)