Problem Description:
I can connect my mobile phone or e-ink tablet with a USB cable to my desktop, and the device is mounted, but not as a removable device. There is no option to unmount/eject the device.
I can copy/move/delete files from/to the device, but after that the only thing I can do is disconnect it. I am concerned that after moving files from/to the device they may get corrupted if I just unplug the cable without unmounting first.
Relevant System Information:
This is a fresh install of Ubuntu Studio on a Lenovo ThinkCentre desktop.
Note that the phone is not listed under removable devices. Right-clicking on the device pops up a menu that only allows opening the device in a new tab or window; no option to mount or eject.
Since the phone is mounted on the desktop, not the other way around, is it possible to make Ubuntu unmount (flush any buffers, etc.) from the phone or tablet? Can you help me find out how to do this?
I have a laptop running Pop!_OS (another flavor of Ubuntu) 22.04, and all such devices are mounted in /run/user/<uid>/gvfs/mtp:<device-id> and can be ejected from Ubuntu. Is the lack of an eject option something new in Ubuntu 24?
MTP-mounts should go through GIO, so you should be able to do an unmount through the command line using gio.
First list all the current mounts gio knows about:
gio mount --list
Then do an unmount with the location:
gio mount --unmount mtp:// ...
You could also tell it to unmount everything using a specific scheme:
gio mount --unmount-scheme=mtp
Another thing you could try is to use sync before unplugging. sync forces the system to write out all cached data.
So the device (or something) is telling the OS not to allow unmounting.
Does that mean that with MTP you don’t have to unmount before unplugging?
Everywhere I search the assumption is that you should eject/unmount before unplugging any device (which I assume you still have to do with things like flash drives). And again, everywhere I search the assumption is that there is an option to unmount.
Maybe the unmount/eject option has been provided for MTP mounts even though it’s not really necessary?
I do a lot of file transfers between Android devices and desktop; I guess I can just unplug when finished moving files and hope for the best. It would be nice, though, to know for sure and not worry about unexpected file corruption.
Staff note:
Pop!_OS is a separate Linux distribution developed by System76.
It is not an official Ubuntu flavour (such as Kubuntu, Xubuntu, or Ubuntu MATE). While it does use elements of Ubuntu, such as the package repositories, it has its own desktop environment, tooling, and system modifications and should be treated as a distinct operating system.
Additionally, we do not provide support for distributions which are based on Ubuntu:
MTP is not really a file system, which is what you get on removable disks and flash drives. Instead, it is pretty much a file transfer protocol, like FTP.
So even though you see folders in Dolphin/Nautilus/etc. and can manipulate files as if you were looking at a file system, everything is implemented by sending messages back and forth. So it’s not (normally) possible to corrupt files or the file system by unplugging the device prematurely.
Actually, from what I’ve seen, the gio command works in the user’s space because it is designed to allow the user to mount without sudo, so if you run it as root it does not report any mounted devices.
When I connect my Motorola 53G 5G mobile phone I immediately get a notification on the phone’s screen, not on the computer, asking if I want to use file transfer or video and photo transfer which sound very similar but I assume the video and photo transfer is the mtp protocol and the file transfer is simple usb mass storage though that is not made clear in the notification.
The choice shows only for a few seconds and if I do not choose one or other immediately I have to unplug and replug it to restore the option again.
I always choose the file transfer option and it works well in both directions for all file types including videos and images, ie both to and from the phone and my computer. I do then have the unmount option from a right click on the phone in thunar file manager.
Nope, my ZTE Blade does the same and ‘file transfer’ is mtp while ‘video & photo’ is PTP (picture transfer protocol). In both cases I get a gvfs mount and I can unmount both in many different ways including the GUI …
Modern versions of Android don’t offer USB mass storage anymore because you have to have a block device - like a partition - you can share. This means you have to split system and user files into separate partitions and this means you can run out of space in two separate ways which you would then have to explain to the user somehow …
I have never fully understood the Android workings but as long as it does what I want i generally don’t worry too much, and usb transfers seem to work fine for me using the file-transfer option.
Are there any great advantages of using either one of those two options or do they both do basically the same job, ie, move files from device to device?
I don’t think there’s any great advantages to using PTP. MTP is basically an extension of PTP that doesn’t have the file type limitations. I believe PTP is only still around to support systems that don’t support MTP without having to install third party drivers and applications.
If you install openssh-server then you can use something like AndFTP to send files via SFTP over wireless from the sofa. No wires needed. This is secure too. If you port forward port 22 to the server then you can access your files over the Internet, securely, from anywhere.
Interesting… In Dolphin, which is the file manager that comes with KDE Plasma (which is what you get with Ubuntu Studio out of the box), there is no option to unmount, which is what prompted this whole conversation. I am guessing that it is provided just to give the impression of a mounted filesystem.