Removable media

Removable media Article description::consists of any media that is easily removed from a system; typically this includes CDs, DVDs, USB drives, or memory cards of all form factors. These types of media require special handling if an unprivileged user desires to mount an unknown device.

Prerequisites

 * Kernel support for the storage device.
 * Kernel support for the filesystem used by the device.

UUIDs and labels
In many cases storage devices are identified by their device file, e.g. . Alternatively their UUID (Universally Unique Identifier) or label  can be used. In comparison to device files UUIDs and labels are persistent and will never change because of asynchronous detection. The UUID is generated automatically during filesystem creation. The label can be specified at filesystem creation or changed afterwards.

Use or  (part of ) to show all storage devices and their UUIDs and labels:

Mounting removable media
For mounting as a normal user without root privileges the device needs an entry with the option in fstab.

Plug removable media to the computer then run or.

The and  lines display the UUIDs  and  to be added to  for two media just plugged-in. also has the label which could be used alternatively. Let's create their mountpoints and :

And add them in.

With the option in these entries, they can be mounted / unmounted by normal users.

To see what is mounted, run without arguments or  again and find the  column populated for sdb1 and sdc1:

Once a device is mounted it can be accessed like a normal hard disk. Usual operations like, , , etc. work fine.

For unmounting the usage of mountpoint, label or UUID is equivalent as is for mounting. Any of them will do it.

Mounting without the fstab entry can be done by root only.

For further details see.

Another alternative is to edit /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy, under action id "org.freedesktop.udisks2.filesystem-mount", change auth_admin to yes for allow_any. This will allow a disk to be mounted by remote and local users, so consider this change as a potential security risk.

MTP
For handling media using the MTP (Media Transfer Protocol) protocol see the MTP article.

External resources

 * https://wiki.debian.org/Part-UUID
 * https://en.wikipedia.org/wiki/Universally_unique_identifier