You are not logged in.

#1 2025-11-02 15:28:48

Elmario
Member
Registered: 2023-08-21
Posts: 91

WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

Hello!

After recently (kind of) fixing the fstrim issue for my external SSDs, I want to maybe finally conquer an issue that I have literally wasted hundreds of hours on through the years.
It's by concept as simple as:
Connect any external storage, with whatever filesystems on, and when clicking them in Thunar have them mounted in a way that I can directly write to these filesystems without having to type 'sudo mount -o rw' everytime.

I tried about anything I could find, from udev rules, through some very obscure (to me) systemd shenanigans and mount options from different places, configuring udev, Thunar GVFS, systemd, mount options, ACLs (to the mount path), fstab, udisk2, a lot of methods I already forgot about again, and tried dozens of methods for monitoring whatever happens ..

The only thing I have been reaching so far is the storage devices in /dev/ being manipulated by a udev rule like:

cat 20-allow-USB-access-for-all.rules 
ACTION=="add", SUBSYSTEM=="block", MODE:="0777", ENV{mount_options}="umask=0000"

The permissions of the block device (sdX) are modified successfully, while the mount's path obviously isn't. (Setting the umask ENV has no effect)

I have of course arched thousands of times - no joke - and found no adequate solution, as they all result in the insufficient cause of just allowing a specific partition from a specific storage device using UUID.

Is this even possible?
Thank you in advance! smile

Last edited by Elmario (2025-11-02 21:09:13)

Offline

#2 2025-11-02 15:34:05

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,247

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

Wait, are you saying it's being mounted with the ro mount option? If rw works, that's the only explanation I can see, and that has nothing to do with permissions. Usually we would see this with Windows filesystems that are marked as dirty.

Offline

#3 2025-11-02 15:43:13

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

It happens with any filesystem that supports permissions, be it ext3, ext4, NTFS, btrfs or f2f2. All filesystems are able to be mounted rw by using a simple mount command, so they are working fine.
( And I thought for pretty sure, that this is default on all desktops I have been using!?).

Last edited by Elmario (2025-11-02 15:46:15)

Offline

#4 2025-11-02 15:46:48

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,247

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

Again, mounting rw has nothing to do with permissions. Are they actually being mount ro?

Offline

#5 2025-11-02 15:53:56

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

No. It's just the mount path being writeable for root only:

mount
...
/dev/sda1 on /media/7bc03719-ff40-4883-8f33-1a8e7c5e97ba type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
ls -al /media/7bc03719-ff40-4883-8f33-1a8e7c5e97ba/
insgesamt 24
drwxr-xr-x 3 root root  4096  2. Nov 14:05 .
drwxr-xr-x 5 root root  4096  2. Nov 16:52 ..
drwx------ 2 root root 16384  2. Nov 14:05 lost+found

Writing does work after:

sudo chmod 777 /media/7bc03719-ff40-4883-8f33-1a8e7c5e97ba/

(.. and having to do this everytime I attach external storage  (which I have all the time other ones of..  is an everlasting annoyance)

Last edited by Elmario (2025-11-02 15:59:02)

Offline

#6 2025-11-02 19:36:20

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

Man!

I think I got it.. at the moment this solution (workaround?) seems to finally solve this basic issue, which IMHO is a very urgent problem, especially for new Linux/Arch users. I think maybe based on this idea, there should be a default for this included in Arch!

Actually this dirty idea just came from Claude AI ! lol

# Mark USB-block devices as external
SUBSYSTEM=="block", ENV{ID_BUS}=="usb", SYMLINK+="external/%k"

# Mark all known removable block devices as external
SUBSYSTEM=="block", ATTR{removable}=="1", SYMLINK+="external/%k"

# automatically set permissions after mount (working for ALL Filesystems!)
SUBSYSTEM=="block", ENV{ID_BUS}=="usb", RUN+="/pathto/fix-external-mounts.sh %k"
SUBSYSTEM=="block", ATTR{removable}=="1", RUN+="/pathto/fix-external-mounts.sh %k"

And the script 'fix-external-mounts.sh' :

#!/bin/bash
sleep 3  # Wait dor udev to finish mounting
DEVICE="/dev/$1"
MOUNTPOINT=$(findmnt -n -o TARGET "$DEVICE" 2>/dev/null)

if [ -n "$MOUNTPOINT" ]; then
    chmod -R 777 "$MOUNTPOINT"
fi

I would prefer to have the scripts functionality inside the udev command line, but Claude meant this would be too unreliable ..
I just imagined their probably also is a solution using inotify on (run/media .. but I can't judge which one would be better ..

Last edited by Elmario (2025-11-02 20:05:49)

Offline

#7 2025-11-02 21:34:26

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 70,942

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

    chmod -R 777 "$MOUNTPOINT"

Don't.
Skip the "-R" or if you want to actually change the permissions of *all* files, use "oga+rwX"

man chmod wrote:

execute/search only if the file is a directory or already has execute permission for some  user  (X)

and having to do this everytime I attach external storage

But only once per device, right? The permissions don't get reset?

I'd rather not unconditioanally set the permissions of every filesystem that comes along, but straying in executable bits is most certainly wrong.

Offline

#8 2025-11-03 09:26:08

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

Ye,s you are right of course. I was just too happy for finally having a 'solution' that I did not check the details at all.
I changes Claude's suggestion to 'chmod 764'.
thank you for having a look at it! smile

Yes, this was needed just once per filesystem before. I recreate filesystems very often, for one because of years of trouble with NVME-USB-enclosures which tended to cripple data over and over (solved this some months, ago), but also because after huge operations with moving millions of files I just don't trust a filesystem's integrity anymore as much, after deleting all of these files, and of course reformatting is much faster anyway. Integrity also is the reason why I am using Linux filesystems on removeable storage. The stone age Windows filesystems just are terrible and lose data just by watching the drive intensely with your bare eyes.

Last edited by Elmario (2025-11-03 09:31:22)

Offline

#9 2025-11-03 09:30:55

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 70,942

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

I changes Claude's suggestion to 'chmod 764'.

That will prevent anyone but root from entering the directory and still only the root user can write it.

chmod 777 "$MOUNTPOINT"

will allow everyone to write the root of the mount (the critical omission is "-R") - what, ftr, I would still not unconditionally do to every disk you attach.

Offline

#10 2025-11-03 09:34:47

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

Yes. For some reason I always expect being the owner .. of what I own xD
OK, it's 666 then. I assume f I can live without executing directly from USB storage usually. As most times it's about backupped partitions, images or whatever from others' PC that I recovered, it's 99,9999% data to me anyway.
But writing is a thing that I always need.

Last edited by Elmario (2025-11-03 09:38:52)

Offline

#11 2025-11-03 09:37:33

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 70,942

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

666 is rwrwrw - but you want to be able to "execute" a directory, ie. rwxrwxrwx ie 777

Offline

#12 2025-11-03 09:39:39

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: WORKAROUND: Mount any external filesystem rw for user in XFCE/Thunar

So reading a directory's contents is executing the directory? Or why would I want to execute a directory otherwise?
Could it be better to also use chown then, for being able to use 766 or such, instead of 777?

Last edited by Elmario (2025-11-03 09:41:48)

Offline

Board footer

Powered by FluxBB