Can you just "pull the plug" on MTP devices?

17

6

After attaching a typical USB storage device to Windows, it is important to properly unmount the drive before unplugging it. If you don't, you might lose data.

But for MTP devices (such as many Android devices) connected to a Windows box via USB, is it necessary to perform any procedure before disconnecting the USB cable?

I'm interested in understanding this for all versions of Windows (XP and later), so please include the applicable Windows version(s) in your answer.

RockPaperLizard

Posted 2016-10-05T04:42:35.330

Reputation: 5 415

1You should always eject mass storage devices. This policy applies to all versions of Windows and all types of storage devices connected to Windows. – Ramhound – 2016-10-05T04:46:30.073

@Ramhound That's what I thought too, but for Android MTP devices in Windows 7, I see no systray icon (hidden or visible) to perform the eject. – RockPaperLizard – 2016-10-05T04:47:19.110

@Ramhound Also, in Windows File Explorer, the context menu has no Eject menu item for Android MTP devices. – RockPaperLizard – 2016-10-05T04:48:46.157

The Safety Remove Hardware and Eject Media icon should though. – Ramhound – 2016-10-05T04:49:37.320

1@Ramhound I feel a little silly for asking, but where's that? I'm not seeing it. Will delete this comment due to embarassment once you tell me I'm staring right at it... :-) – RockPaperLizard – 2016-10-05T04:51:20.803

3@Ramhound: MTP devices aren't mass storage devices. – user1686 – 2016-10-05T04:55:25.390

Answers

21

When you plug in a USB mass storage device, it gives the host computer undifferentiated access to the mass storage.

It assumes absolute control over the file system similar to that of a hard drive.

As such, unless explicitly commanded by the host system to sever the connection between the devices there is a chance that the host computer might corrupt the file system. Hence the "Safely Remove Hardware and Eject Media" message.


However, MTP, or Media Transfer Protocol, operates at the file level rather than as a large unit of mass storage at the block level.

When plugging in a device such as a MTP device, the host system queries the files on the device.

This is often maintained as a database or index on the root file system of the MTP device. The MTP device's system does not have to re-scan the entire device when its content is modified; it only needs to update the database/index.


The host system can then download a file, a signal will be sent to the device to acknowledge this request.The requested file will sent by the device.

Deleting files work much the same way. The host system sends a message to the device, marking a file for deletion. The device removes the file upon acknowledging the signal.

This works much like a transactional file system, where either the file is modified or it is not. The storage will not be affected by failed transfer.


This is also the reason why MTP only allows one file transfer at a time (atomic file transfer), such that corruption cannot occur as operations are run sequentially.

So yes, you can just pull the plug on your device.

Further reading about MTP, and comparisons to USB Mass Storage

Carrein

Posted 2016-10-05T04:42:35.330

Reputation: 1 382

I made a couple edits to your answer. If you can, please proofread my edits to make sure I got everything right. – RockPaperLizard – 2016-10-05T10:35:41.877

@RockPaperLizard Thanks for the edits. I am trying to find an image to further illustrate the protocol but nothing so far. If I find something, I'll edit this post again. – Carrein – 2016-10-05T10:48:08.597