You are not logged in.

#1 2013-03-25 17:43:27

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

[SOLVED] Wrong mount permissions in KDE

Hi, I recently bought an external HDD enclosure with USB connector to reuse an old 2.5" internal drive as external. I'm going mad because Dolphin mounts it so that only root has write access:

$ ll /run/media/mori/
total 4,0K
drwxr-xr-x 3 root root 4,0K 24 mar 17.15 EXTDRIVE

It seems that some udisks policy has to be set. I'm not an udisks expert, so I followed this https://wiki.archlinux.org/index.php/Po … USB_drives but it doesn't work (is this maybe systemd-related?). I can't figure out what to do to be able to mount the drive with write permission for my user in a safe and proper way. With USB sticks my system has no problem:

$ ll /run/media/mori/
total 4,0K
drwx------ 3 mori wizard 4,0K  1 gen  1970 222F-DB43

so maybe the HDD in the external enclosure is recognized as a different device than a USB flash memory stick? Here's the log on journalctl when plugging the external HDD:

mar 25 18:30:55 elric kernel: usb 8-1: new high-speed USB device number 18 using ehci-pci
mar 25 18:30:55 elric kernel: scsi13 : usb-storage 8-1:1.0
mar 25 18:30:55 elric laptop-mode[12442]: Laptop mode
mar 25 18:30:55 elric laptop-mode[12444]: enabled, not active
mar 25 18:30:56 elric laptop-mode[12460]: Laptop mode
mar 25 18:30:56 elric laptop-mode[12461]: enabled, not active
mar 25 18:30:56 elric kernel: scsi 13:0:0:0: Direct-Access     TOSHIBA  MK3252GSX             PQ: 0 ANSI: 2 CCS
mar 25 18:30:57 elric kernel: sd 13:0:0:0: [sdb] 625142448 512-byte logical blocks: (320 GB/298 GiB)
mar 25 18:30:57 elric kernel: sd 13:0:0:0: [sdb] Write Protect is off
mar 25 18:30:57 elric kernel: sd 13:0:0:0: [sdb] Mode Sense: 34 00 00 00
mar 25 18:30:57 elric kernel: sd 13:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
mar 25 18:30:57 elric kernel:  sdb: sdb1
mar 25 18:30:57 elric kernel: sd 13:0:0:0: [sdb] Attached SCSI disk

Thanks to everybody in advance.

Last edited by snack (2013-03-29 08:47:19)

Offline

#2 2013-03-25 17:53:51

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: [SOLVED] Wrong mount permissions in KDE

USB sticks usually use FAT - it's possible to mount Microsoft filesystems (FAT and NTFS) so that files on them belong to any user.

If your drive is using a Linux filesystem, you can "chown -R mori.users /run/media/mori/". Then you might have problems accessing it on other computers.

Offline

#3 2013-03-26 08:09:35

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: [SOLVED] Wrong mount permissions in KDE

lucke wrote:

USB sticks usually use FAT - it's possible to mount Microsoft filesystems (FAT and NTFS) so that files on them belong to any user.

If your drive is using a Linux filesystem, you can "chown -R mori.users /run/media/mori/". Then you might have problems accessing it on other computers.

I don't even have a /run/media folder before plugging the drive in... which BTW has an ext4 filesystem. Am I supposed to chown the mount folder every time I plug my drive after a reboot? This doesn't sound very user-friendly, not even power-user-friendly. Then I will be unable to use the drive with another pc (unless on that pc there is a group with my same gid which have write permissions on mounted drives, I guess), which is not so smart for an external drive...
Talking seriously, is this the way the Linux desktop is supposed to dominate the world? Is switching to a MS filesystem the only way to have a drive which I can plug in and write on on every pc with a USB port? Is there a modern, Linux-native filesystem tuned for external storage which solve these problems? Maybe everything boils down to ext4 not being tailored for USB disks...

Offline

#4 2013-03-26 08:55:19

whobanil
Member
From: United States
Registered: 2013-03-20
Posts: 11

Re: [SOLVED] Wrong mount permissions in KDE

I'd like to point out something. If you use FAT32 instead of ext4 for cross-platform usability, FAT doesn't support permissions at all. Which will result in super user access only. I had this issue with a flashdrive. To fix this, make an entry in your fstab to mount the device and include the mount options rw,umask=000,nofail. This will allow normal users to access it.

If you want to use a different FS and still having permission issues, try fstab entry with mount options rw,user,nofail

Here is the entry for my exfat flashdrive

#Flashdrive
UUID=DEDC-7FB9        /run/media/(my name)/Flashdrive       exfat            rw,defaults,umask=000,nofail,discard        0 0

NOTE: FAT32 supports file sizes < 4GB. That's why I use exfat

Last edited by whobanil (2013-03-26 09:07:25)

Offline

#5 2013-03-26 09:57:00

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: [SOLVED] Wrong mount permissions in KDE

whobanil wrote:

I'd like to point out something. If you use FAT32 instead of ext4 for cross-platform usability, FAT doesn't support permissions at all. Which will result in super user access only. I had this issue with a flashdrive. To fix this, make an entry in your fstab to mount the device and include the mount options rw,umask=000. This will allow normal users to access it.

If you want to use a different FS and still having permission issues, try fstab entry with mount options rw,user

Thanks, I never had problems with USB flash drives with FAT32: I can plug them and they are mounted so that I can write on them as a regular user, not root. I'll try the fstab entry and report the results!

Offline

#6 2013-03-26 09:59:52

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: [SOLVED] Wrong mount permissions in KDE

If you chown -R that mount point, all files on the disk will be owned by mori.users. When you put it in another PC, files will be owned by mori.users. If you take out the disk with your /home directory from your PC and plug it in another PC, files in /home will be owned by mori.users. mori or people in the users group will be able to operate on them, depending on permissions.

Microsoft filesystems don't use Linux permissions and thus they are decided at mount time. You connect a drive with NTFS/FAT, udisks mounts it so that files on it are owned by your user, thus you can do anything with them.

Yeah, problematic. I'd use NTFS if i wanted to have a (big) drive for dragging around.

Last edited by lucke (2013-03-26 10:00:22)

Offline

#7 2013-03-26 10:15:18

whobanil
Member
From: United States
Registered: 2013-03-20
Posts: 11

Re: [SOLVED] Wrong mount permissions in KDE

snack wrote:
whobanil wrote:

I'd like to point out something. If you use FAT32 instead of ext4 for cross-platform usability, FAT doesn't support permissions at all. Which will result in super user access only. I had this issue with a flashdrive. To fix this, make an entry in your fstab to mount the device and include the mount options rw,umask=000. This will allow normal users to access it.

If you want to use a different FS and still having permission issues, try fstab entry with mount options rw,user

Thanks, I never had problems with USB flash drives with FAT32: I can plug them and they are mounted so that I can write on them as a regular user, not root. I'll try the fstab entry and report the results!

OH, I just remember that I had this issue because I manually mounted it with fstab in the first place without the umask option. So it mounted to the specified dir without user write permissions. With nothing written to fstab, it does mount correctly haha.

Offline

#8 2013-03-26 13:25:33

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: [SOLVED] Wrong mount permissions in KDE

Wow, the more I go further the more things become crazy! I Added an fstab entry:

UUID=a9be3383-ea83-45a1-a5ee-f0b8d7d6c666   /media/EXTDRIVE  ext4  noauto,rw,user,exec  0  0

and created a mountpoint:

$ ls /media/ -l
total 16
drwxr-xr-x 2 root root 4096  4 dic 20.39 cd
drwxrwxr-x 2 root disk 4096 26 mar 11.02 EXTDRIVE

with write permissions for the disk group (to which my user belongs). When I mount my drive with dolphin (which relies on udisks2) I get this:

$ ls /media/ -l
total 16
drwxr-xr-x 2 root root 4096  4 dic 20.39 cd
drwxr-xr-x 3 root root 4096 24 mar 17.15 EXTDRIVE

The mountpoint ownership is now root:root instead of root:disk, so my user can't write on the HDD!! This is the intended behavior of udisks2, at least according to the udisks2 reference:

 If the device in question is referenced in the /etc/fstab file, the mount command is called directly (as root) and the given options or filesystem type given in options are ignored. The authorization checks mentioned above are still performed.

So the filesystem is mounted as root:root and I'm back to the beginning...

@lucke: I understand. I'd like at least to be able to plug the drive on my pc, mount with Dolphin and write my backup on it. I hope I don't have to switch to NTFS to do such a simple thing...

Last edited by snack (2013-03-26 13:30:46)

Offline

#9 2013-03-28 22:50:03

whobanil
Member
From: United States
Registered: 2013-03-20
Posts: 11

Re: [SOLVED] Wrong mount permissions in KDE

Try setting permissions recursively while the device is mounted?

Use chown to try.

Offline

#10 2013-03-29 08:29:38

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: [SOLVED] Wrong mount permissions in KDE

whobanil, how can I do it? Using a udev rule, a polkit policy or something weird like that? I never wrote a udev rule and I don't know how to do it. For sure, I don't want to manually chown every time I mount the drive...

Offline

#11 2013-03-29 08:36:59

whobanil
Member
From: United States
Registered: 2013-03-20
Posts: 11

Re: [SOLVED] Wrong mount permissions in KDE

No nothing like that. I was thinking that setting the owner recursively one time would work. Execute this simple command while the drive is mounted:

chown -R root:disk /media/EXTDRIVE

Offline

#12 2013-03-29 08:46:40

snack
Member
From: Italy
Registered: 2009-01-13
Posts: 861

Re: [SOLVED] Wrong mount permissions in KDE

That did the job! I mounted the drive, then chown -R root:disk, and now every time I mount it the correct ownership is set. I don't even have to have an fstab entry, now. Thanks again whobanil for the suggestion.

Offline

#13 2013-03-31 07:13:03

whobanil
Member
From: United States
Registered: 2013-03-20
Posts: 11

Re: [SOLVED] Wrong mount permissions in KDE

You're welcome!

Offline

#14 2015-10-30 15:50:48

z1gm4
Member
Registered: 2014-12-29
Posts: 1

Re: [SOLVED] Wrong mount permissions in KDE

Thank you so much whoabnil!!!! i have the same issue here, and doesn't know how to fix it !! smile

Offline

#15 2015-11-01 17:07:38

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,787
Website

Re: [SOLVED] Wrong mount permissions in KDE

Please don't necrobump, z1gm4.

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB