5

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.

Bachalo
  • 753

4 Answers4

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.

dgonzalez
  • 7,010
  • 6
  • 19
  • 28
1

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.

Bachalo
  • 753
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.

sudodus
  • 46,324
  • 5
  • 88
  • 152
0

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

sudo umount /dev/sdb
GNK
  • 2,839