You are not logged in.

#1 2018-11-24 14:46:10

devnull
Member
Registered: 2017-06-29
Posts: 60

how to automount with write permissions without root

Hello everyone,

I am recovering some old pcs and setting up accounts without root or sudo privileges, as they are for public usage. I'm using Debian 9 (stable).

One of the most common usage is putting usb drives in, writing, working with files, and I can't seem to be able to do that. I mean, with some tinkering on the command line, but a simple inserting the drive, automounting and being able to read and write seems above my capacities!

Can you help me out with this?

So far I've tried to:

chown 777 /media/user/*

Added this code to /etc/udev/rules.d/90-usb-disks.rules

KERNEL=="sd*[0-9]", ATTR{removable}=="1", ENV{ID_BUS}=="usb", MODE="0022"

but nothing is working: usb is mounting, I can read but not write

Thanks!

Offline

#2 2018-11-24 15:52:09

onlain
Member
Registered: 2016-04-22
Posts: 31

Re: how to automount with write permissions without root

You were mixing chmod and chown sentenses?

anyway, with the USB connected, run "sudo blkid" and find the UUID and TYPE.

then, try make a new dir in media, like "/media/usbstick".

finally, add this to /etc/fstab:

UUID=*UUID* /media/usbstick *TYPE* user,umask=000,utf8,flush,noauto 0 0

replace *UUID* and *TYPE* with the blkid's command output.

save changes in fstab and run "sudo mount -a" at terminal.

did it work?

PD: Just for security, changing /media/user/ permitions could be a bad idea, even if "nothing" change. (default is 750)

Last edited by onlain (2018-11-24 15:53:11)

Offline

#3 2018-11-25 08:30:45

ohnonot
...again
Registered: 2015-09-29
Posts: 3,194
Website

Re: how to automount with write permissions without root

this functionality should just be there right from the start, if you install a DE (desktop environment) that is.
additional configuration steps might be required; it's a while since i did this but i think "policykit" is the keyword.
so how and what exactly did you install?

PS: if your stick isn't formatted FAT32, you might need to chown it to uid 1000 first.
PPS: NEVER EVER "chmod 777"!!!

Offline

#4 2018-11-26 02:19:18

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 4,673
Website

Re: how to automount with write permissions without root

I had the same problem yesterday. Some usb sticks were automounting as belonging to me, others as root-owned.

Much googling later, I realized that the problem sticks were all ext4 formatted, probably created by gparted, running as root. It stands to reason that the file system is root owned. OTOH VFAT systems for example, having no ownerships, are usually automounted user-owned.

---
Now, I'm only going to talk about the setup in BunsenLabs, which uses Thunar-volman and udisks2 to handle these things. @devnull whether this applies to you or not depends on what you have installed in Debian9 and how you have configured it.

Plugged in external devices are automounted to a temporary directory under /media/<username>/<tempname> (<tempname> might be the device label, if it has one, or else some long string like a UUID.)

/media/john belongs to me, but those ext4 sticks were mounted to /media/john/<tempname> which was owned by root, to match the stick partition's ownership.

The solution in my case was (with the device plugged in and mounted) to navigate to /media/john and perform 'sudo chown -R john:john <tempname>' This changed the ownership on the stick partition, so persisted after removing and re-plugging. Another option would be to create a subdirectory belonging to you.

I don't know if there's a way to have root-owned filesystems automounted with user permissions.

Last edited by johnraff (2018-11-26 08:52:12)


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

Board footer

Powered by FluxBB