How to unmount a USB drive which is not mounted under /media directory

1

I am running Gnome 3 on Debian Wheezy. I want to unmount a USB drive without sudo or root privileges. I've googled and found out that there are eject and pumount commands available. However, those commands require the mounted directory to be under the /media directory.

The USB drive is mounted under $HOME/USB/myusb.

How can I unmount it with a non-sudoer user. I also wonder which command Nautilus runs when I press the eject button?

Thanks.

The_Cute_Hedgehog

Posted 2014-04-03T18:57:00.930

Reputation: 123

Answers

1

The eject manpages says that eject can unmount devices corresponding to the device (e.g., /dev/sda1) or the mountpoint (which is in your case $HOME/USB/myusb).

If eject $HOME/USB/myusb is not working. Try eject -v $HOME/USB/myusb to get more information about what is happening.

Tested eject here. It works as expected. Maybe it is a permission problem?

user3422070

Posted 2014-04-03T18:57:00.930

Reputation: 501

It did not work. It says $HOME/USB/myusb is not below /media/. – The_Cute_Hedgehog – 2014-04-03T20:37:21.567

My manpage says: "The device corresponding to device or mountpoint is ejected.". I verified that this is working. Can you check your manpage? Which distro do you use? Which eject version do you have? – user3422070 – 2014-04-04T15:27:10.620

The man page says: Eject allows removable media (typically a CD-ROM, floppy disk, tape, or JAZ or ZIP disk) to be ejected under soft‐ware control. eject version is 2.1.5. Debian Wheezy. – The_Cute_Hedgehog – 2014-04-05T17:58:46.997

Your quote is also in my manpage as first paragraph in section DESCRIPTION. My the 2nd paragraph states that eject can unmount from any location as quoted above. What gives you eject -v? – user3422070 – 2014-04-05T21:50:39.180

It says $HOME/USB/myusb is not below /media/ – The_Cute_Hedgehog – 2014-04-06T13:24:38.570

0

Some modern distribution use udiskctl for this:

udisksctl unmount -b /dev/sdc1

(if the usb drive is /dev/sdc).

Nautilus probably use dbus to contact the udisk service for this. (it is what udiskctl do). If you are interested, freedesktop.org as the documentation of the dbus interface.

Rémi

Posted 2014-04-03T18:57:00.930

Reputation: 1 300

It did not work neither, it says $HOME/USB/myusb is busy. However, I don't read/write from it at the moment. lsof gave me a list of processes that might be using that device. – The_Cute_Hedgehog – 2014-04-03T21:07:22.980

udisksctl has a --force option, but you should probably close those processes. – Rémi – 2014-04-04T04:43:26.697

0

You can add an entry for the mount point in /etc/fstab and include the user option to the line

Scandalist

Posted 2014-04-03T18:57:00.930

Reputation: 2 767