Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I insert a thumb drive, media card, or USB hard drive, to unmount it via the command line, I need to use

sudo umount /media/the_device

But, I can unmount the device in a file manager like nautilus simply by clicking the eject button or using the right-click context menu on the device.

What is the rationale for the difference? How can I change it so that I can unmount from the command line without needing root privileges? Is changing it a bad idea?

Edit: In case it has changed, I am running 9.04. I've run most versions 5.10--9.04, and as far as I recall, it has always been this way.

share|improve this question
2  
Huh I hadn't thought of that. That is strange isn't it? –  DLH Jul 29 '10 at 17:10
    
Yeah, and then there's the mystery mounts. I have been trying for a long time to figure out how nautilus locates and mounts the local Windows network the computers in the house run on. I can get to the shared folders of anywhere through nautilus, but it would be really nifty to know how to get there from a terminal. –  Campadrenalin Jul 29 '10 at 17:36
    
Any network drives in Nautilus can be accessed under ~/.gvfs. Also, I recommend the nautilus-open-terminal plugin. –  Marius Gedminas Jul 30 '10 at 12:02
add comment

2 Answers 2

up vote 28 down vote accepted

Nautilus doesn't unmount the device directly; it talks over DBus to a system daemon (udisks-daemon) and asks it to unmount.

The daemon checks if you're allowed to do that, by contacting another system daemon, PolicyKit.

PolicyKit uses the configuration defined in /usr/share/polkit-1/actions/org.freedesktop.udisks.policy (unless the local system administrator overrides it in /etc/polkit-1). That file tells PolicyKit that users with active console sessions can detatch drives, so PolicyKit talks to a third daemon, ConsoleKit, to see if you have active console sessions. Logging in via gdm counts as a console session; logging in via ssh doesn't.

There's a command-line tool udisks that lets you unmount devices without using sudo, using the same mechanism:

udisks --unmount /dev/sdb1

that unmounts the filesystem; I can also detatch the whole device with

udisks --detach /dev/sdb

which makes the LED on my USB key go dark.

share|improve this answer
3  
I want to thank you very much for provoking me into doing this research. I wanted a command-line tool to unmount devices without using sudo for a long time. –  Marius Gedminas Jul 30 '10 at 12:28
1  
Um, your welcome for my provoking you into giving a really good answer to my question. :-) –  vanden Jul 30 '10 at 15:02
1  
The rights to do this are no longer present (as of Ubuntu 12.10) - however the answer below with gvfs-mount now works –  David Fraser Jun 5 '13 at 14:30
add comment

The situation might have changed -- in current Ubuntu 10.04 umount works without sudo for USB drives. Generally I think that the command

gvfs-mount -u /media/the_device

(gvfs-mount is in the gvfs-bin package) should always work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.