Usb automount to only root

hi community,

i have been facing a problem a long time ago. I dont know when it started but i think it worked correctly in the past. At the moment every usb stick or sd card that i stick in will be mount under /run/media/[myuser]/[mountpint] but only root can access the directory. So i have to create dirs with root and have to change the permission so that my user can access.
This is annoying.
I installed an EOS with xfce without modify things for automounting. Where can I change this behaviour so that my user can access automatically the device via Thunar?
Thanks in advance.

What file system are you using on the usb stick?

you could just take over ownership of the device

sudo chown -R $USER /path/to/device

1 Like

THe filesystem is not relevant.
Like u read already I changed manually the permission, but it should work automatically.

is not the same thing I am talking about I"m talking about taking ownership of the DEVICE.

as far as I know MS formats don’t follow linux permissions.

Sorry. The filesystem was a good hint. I tested all my stick in a row and the result was crazy.
usb stick with vfat - worked
usb stick with exfat - worked
usb stick with ext4 - not working
usb stick with btrfs - not working
sd card with ext4 - not working

What happened here. This is crazy. With some FS it worked and with others not.
I controlled the mounting parameter with “mount” and noticed that the sticks that worked show the uid and gid mount option with my user id. The others not.

These are Linux File Systems so you will need to use the command I gave earlier to take ownership make sure to replace “/path/to/device” with the actual path like /dev/sda if you need to run lsblk before hand to know which device you wish to take ownership of.

You are right. I do it like u mentioned and also after reboot it worked. Thank and sorry.
I thought i did it already in this way, but after reboot it was gone. Maybe i did it wrong.

This is a sample of 3 partitions within my usb stick
You can do it als follows :

  • check with command sudo blkid the UUIDs of your usb stick

  • adapt /etc/fstab :
    UUID=xyzp1 /usbp1 vfat noauto,user,noatime 0 0
    UUID=xyzp2 /usbp2 ext4 noauto,user,noatime,commit=600,exec 0 0
    UUID=xyzp3 /usbp3 ext4 noauto,user,noatime,commit=600,exec 0 0

  • choose your own xyzp1 usbp1, xyzp2 usbp2, … and partitiontypes

  • save /etc/fstab

  • systemctl reload daemon-reload

  • create above directories : sudo mkdir /xyzp1, sudo mkdir /xyzp2 , sudo mkdir /xyzp3

  • set permissions sudo chown your_userid:your_userid /xyzp1 /xyzp2 /xyzp3

  • afterwards you can manually mount the partitions with you own userid !
    mount /xyzp1 /xyzp2 /xyzp3

  • to umount : umount /xyzp1 /xyzp2 /xyzp3

1 Like

While I was searching for a solution to an other it problem i noticed an other way to get it working. U can change the filesystem automount parameter from udisk2. There u can define f.i. uid and gid and so on.
https://wiki.archlinux.org/title/Udisks
Very nice, but the solution at the top is better.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.