We all know that there is a right way and a wrong way to detach USB mass storage devices from our computers, but does the same principle apply to MTP devices? Today’s SuperUser Q&A post has the answer to a curious reader’s question.

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

The Question

SuperUser reader RockPaperLizard wants to know if you can simply pull the USB plug on MTP devices connected to Windows:

Can you simply pull the USB plug on MTP devices connected to Windows?

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

The Answer

SuperUser contributor Carrein has the answer for us:

Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

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 an MTP device, the host system queries the files on the device.

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

The host system can then send a message to the device requesting that a file be downloaded, which will be sent by the device after acknowledging the signal. Deleting files works much the same way. The host system sends a message to the device, marking a file for deletion, then 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 a failed transfer. This is also the reason why MTP only allows one file transfer at a time (atomic file transfer), so that corruption cannot occur as operations are run sequentially.

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

Further Reading: Media Transfer Protocol [Wikipedia]

Image Credit: Jeremy Keith (Flickr)