I am developing a device that runs Raspbian on Raspberry Pi. The device runs a background process that should be able to access usb drives when they are plugged in. The problem is that the background process is owned by another user, say user1, while the mountpoint /media/pi/KINGSTON, for example, is owned by 'pi'. This results in EACCESS error for the background process.

It is not possible to use mount commands etc., as the end user will only have access to a simple UI. Is it possible to always automatically mount the device so that the mountpoint is owned by user1, e.g., /media/user1/KINGSTON even if user pi is logged in? Only user1 will need access to the drive


I was able to solve this problem the following way:

  1. Disable PCManFM automount (Edit -> Preferences -> Volume Management)
  2. Run udiskie in the background as user1

The simplest way was to create a systemd service for udiskie owned by user1. Another option is to run sudo -u user1 udiskie in the background but that will, at least for me, ask for pi's password each time a usb drive is plugged in. The mountpoint is still owned by user1, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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