2

I have both the Bus and Device numbers for a USB device I want to unmount. I tried resetting the USB device like so
How do you reset a USB device from the command line?

but it doesn't unmount it from the desktop.

2

MTP devices are mounted via gvfs (gnome virtual filesystem). You'll need to use the propper tools for managing gvfs, like gvfs-mount or fusermount.

  • First use lsusb to get your mtp device number and bus number. I think you already have this.

    Simple example using lsusb+grep for a Nexus 4:

    $ lsusb | grep Google 
    Bus 002 Device 025: ID 18d1:4ee2 Google Inc.
    
  • Then use gvfs-mount:

    gvfs-mount -u /run/user/1000/gvfs/mtp:host=%5Busb%3A{busnumber}%2C{deviceNumber}%5D
    

    Replace busNumber and deviceNumber, also remove the brackets.

    You should end with something like:

    gvfs-mount -u /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C025%5D
    
  • If gvfs-mount doesn't work, try with fusermount:

    fusermount -u /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C025%5D
    

Hope it helps.

UPDATE: Sorry,gvfs-mount and fusermount seems to be designed to work without sudo as they are intended to manage fuse-based mounts by non admin users.

UPDATE 2: I observed the correct path is : /run/user/1000/gvfs/, while testing by myself on Ubuntu 16.04/16.10 , using 1000 instead of yourUsername.

  • Thanks, but when I try either option I get sudo: /etc/sudoers is owned by uid 999, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin – Bachalo Dec 28 '16 at 16:14
  • Sorry ,try fusermount -u /run/user/myUser/gvfs/mtp:host=%5Busb%3A002%2C025%5D, fusermount seems to work without root permissions for mounts using fuse. Answer edited... – dgonzalez Dec 28 '16 at 16:44
  • Updated answer, you should check if it solves your question. – dgonzalez Dec 28 '16 at 17:10
  • 1
    gvfs is deprecated in favor to gio mount. – Pablo Bianchi Mar 15 at 22:43
0

You can use

df

to find all mounted devices, and you get more information if you run the following command

sudo lsblk -f

or even better in a wide terminal window (if necessary)

sudo lsblk -fm

When you have identified the USB device, you can unmount it with the following command line

sudo umount /dev/sdxn

where x is the drive letter and n is the partition number, for example '/dev/sdb1'

-o-

This is unmount. The buffers are flushed, so it is safe to unplug the device. The device has still power on, so it can be 'seen on the desktop', and it can be mounted again. This is different from eject. An ejected pendrive will be powered off, and must be unplugged and plugged in again if you want to mount it.

0

I was asking the wrong question.

Instead of figuring out how to unmount the device, I needed to find out what process or daemon was claiming it.

I issued

ps aux | grep mtp

which gave me a few mtp related processes and compared with the camera mounted and unmounted to get the specific process

and then

pkill -9 gvfsd-mtp

does the trick.

0

You can unmount by using below commands, First check list of all the blocks and mount paths. lsblk

sudo umount /dev/sdb

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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