5

I have a Pi 3 which I've wiped clean, and updated to Pixel; nothing else is running on it (correction, I loaded realvnc). I'm using the graphical interface, if that makes a difference. When I plug in a memory card reader with SD or CF cards inserted, they are automatically mounted to /media/pi/, which is OK, but I'm puzzled as to how that's happening. When I plug them in, I get a "removable medium is inserted" pop-up window, with a default action of Open in File Manager. What process is mounting these media?

I've searched here and elsewhere, and have not found a definitive answer, or one that appears to be the case for my pi. I've looked at /etc/fstab and etc/udev/, and neither of those shows an entry for automounting USB. I'm still figuring out /etc/systemd, but I'm not seeing an obvious rule there either. What am I missing? This seems like it would be reasonably useful knowledge for pi/linux newbies.

Also, when I plug in a USB "thumb" drive when the pi is already booted, it is not auto mounted, unlike the card reader USB device. If I boot with that USB drive connected at power up, it is mounted, which to me would point to fstab, but again, no entries there that show any indication of USB.

To clarify/reiterate my question: When running the Pixel GUI on a Pi 3:

  1. What process is responsible for automatically mounting some types of USB media like USB memory card readers?
  2. What process is responsible for automatically mounting other types of USB media like USB thumb drives when (and only when) they are connected at boot time?

Thanks!

  • Welcome to RaspBerryPi.StackExchange - be sure to take the tour to see how this one works: raspberrypi.stackexchange.com/Tour – SDsolar Apr 13 '17 at 3:20
  • Upvote because I am hoping someone can give a definitive answer to this. I had a flash drive mounted, and it asked for my password and everything, but much later discovered that the drive itself is empty and all the files I have been "saving" are going to a simple folder under /media/ip - so now have a script to scp it to a Ubuntu machine periodically so I have a hard-drive copy of what I thought it was saving. – SDsolar Apr 13 '17 at 3:22
  • Interesting answers and suggestions here: raspberrypi.stackexchange.com/questions/15474/… – SDsolar Apr 13 '17 at 3:26
3

The auto-mounting of USB devices in Raspberry Pi is handled by the GUI/DE (as suggested helpfully by multiple folks here), which is based on LXDE, and specifically, it's controlled by PCManFM, the file manager. To disable this behavior, open the File Manager, and from the Edit menu, choose Preferences. Pick the Volume Management tab/item.
File Manager menuFile Manager Preferences

The second option, "Mount removable media..." can be unchecked to disable auto-mounting "removable" class media on insertion. The "Show available options..." setting can be disabled to prevent the pop-up window prompting for available programs. I'm guessing that the first option, "Mount mountable volumes..." is what is mounting my thumb drive when it's present at boot. The screenshot above is from an older version (wheezy?); Jessie has a few more minor options that aren't relevant to the question, but define the behavior of File Manager when devices are mounted/unmounted.

I didn't find any information about how LXDE/PCManFM classifies a USB device as either "mountable volumes" or "removable media" but for my purposes, I can disable both to simplify developing my own mounting scripts. Thanks to all of the great input here which set me on the right search path to find this. As others stated, this is not unique to Raspberry Pi, but as there are a lot of Pi users who are new to Linux, that may not be obvious.

1

Use your device UUID to automount using /etc/fstab. Simple plug-in your device:

  • check UUID using sudo blkid
  • Find your device (like /dev/sda1) and copy UUID
  • Write at the bottom /etc/fstab file:

UUID={YOUR-UID} {/path/to/mount/point} {file-system-type} defaults,errors=remount-ro 0 1

  • Save, close, reboot device to check or type: sudo mount -a
  • Using 1 as the last number here may slow your boot times down occasionally if this conflicts with the root fs and they get scanned in arbitrary order. Not sure. In any case, you should really create a definite ordering with the root fs first. See man fstab. – goldilocks Apr 13 '17 at 15:24
  • Great info; thank you. I just edited to clarify my question. The info on how to automount is definitely appreciated, but what I can't find anywhere is information on how the current, stock auto-mounting of certain types of USB devices is done (and why it only mounts certain things, not others). I see vague references to this being a function of the GUI, e.g.: raspberrypi.org/magpi/connecting-disks-with-the-command-line – David Bump Apr 13 '17 at 15:36
  • It usually is a function of the DE, pretty certain Raspbian is no exception to that. However, it may be an independent daemon service the DE starts. Since PIXEL is built on LXDE, you might want to research the latter. – goldilocks Apr 13 '17 at 16:10
0

I cannot answer, but (many years ago) did investigate. It is handled by the Desktop Environment. This was first introduced by Mandrake, and now included in most mainstream distributions.

If you boot to the command line, there is NO automounting.

NOTE It is not done by fstab, although you can use this to PREVENT automounting. I use
UUID=2dd6c96e-4655-4a04-a8ca-7a5fd39d09bb /mnt/PiHDD ext4 defaults,noatime,noauto 0 0 to STOP Raspbian automounting my external HD, and also to change where filesystems are mounted.

This may or may not work with SD Cards.

You may get more information on http://unix.stackexchange.com/questions as this is NOT specific to the Pi.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.