mobile hard disk is read only when mounted by dolphin

i have a mobile hard disk, its file system is ext4. when i plugged into my machine, dolphin prompted me to mount , so i clicked to mount them.
but i found the mounted mobile hard disk is not writable.


> ll
total 4
drwxr-xr-x 3 root root 4096 Jul 23 13:54 MHD1

if *MHD1 *partition is automatically changed to 777 after mounted, then the problem will get fixed. and i guess dolphin / KDE maybe have an internal or external mount policy which i can customize . but i don’t find it.

please help, thanks !

Well, you have it formatted as ext4 and owned by root. This filesystem uses **nix permissions which are respected. That can easily be changed if required though.

For comparison, I have a vfat partitioned storage device that mounts via udisks2/KDE, and so it mounts like this

 ll /var/run/media/dean/
total 8
drwx------ 12 dean users 8192 Jan  1  1970 SP UFD U2

it seems that i can use polkit actions / rules to change owner and / or access privilege, but i am not familiar with polkit, i haven’t a clear solution yet.

No, polkit is used to control access, not for changing ownership.

Here, read this old thread. It might help clarify the necessary…
https://forums.opensuse.org/showthread.php/489272-USB-drive-ext4-partitions-are-mounted-as-root-root

is it possible that running chmod when an action is performed ?
but first of all, $MOUNT_POINT_ABS_PATH ( such as /run/media/bruce/MHD1 ) can be passed in by polkit .


  <action id="org.freedesktop.udisks2.filesystem-mount-other-seat">
    <description>Mount a filesystem from a device plugged into another seat</description>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
      <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/chown bruce:users $MOUNT_POINT_ABS_PATH</annotate>
      <annotate key="org.freedesktop.policykit.exec.allow_gui">false</annotate>
    </defaults>
  </action>

seems to be an impossible job.

Why don’t you simply change ownership/permissions of the directories/files on the external storage device?

There is no difference between this mounted (Linux file system) partition and any other of the kind. This means that the ownership/permissions of the mountpoint do the same as ownership/permisions of any other directory. Same for all file/directories in the file system.

Thus when you post

drwxr-xr-x 3 root root 4096 Jul 23 13:54 MHD1

(which I assume is about the mount point, you never said or showed hat), it means that root kan search, read and write in the directory and that others can not write.

Thus, when you say it is “readonly” that probably is not true (you can show that with the mount command), but you probably tried to write somwhere inside the directory as end-uer and that failed of course. As root it has to be possible to write there (did you try?).

My advices would be:

  1. read something about ownership by user and group and permission bits;
  2. create an entry in /etc/fstab for the mount (e.g. through YaST), then you can decide yourself where the mountpoint should be;
  3. first decide what the usage of the file system will be, for the system, for one of the users? Then you can plan mountpoint, ownership, etc. accordingly.

Also this ifno might help: https://en.opensuse.org/SDB%3ABasics_of_partitions,_filesystems,_mount_points

@hcvv thanks for your advice.
actually i know about file / directories’ ownership and access bits very much. i also know how to manually mount or automatically mount with /etc/fstab.
what i just wanna know is that whether it is possible to auto-mount removable hard disks within dolphin / krusader / system tray notification by a simple click which a newbie linux user can do.
after all, /etc/fstab usually fits for mounting fixed hard disks (contrast to removable hard disks).

i researched polkit and like @deano_ferrari already pointed out, polkit can decide who can mount , can not decide how to mount.

so finally my solution comes ( i know it not for newbie users):


> cat /etc/fstab 
......
UUID=385acbee-ebab-42e4-ae38-499fd4841e40 /mnt/sdb1            ext4       user,acl,nofail       1 2
UUID=e48ca8d7-5e36-46aa-9ec2-77dca3184d9a /mnt/sdb2            ext4       user,acl,nofail       1 2
UUID=dc188773-62ac-4377-b549-1827ef3d43e8 /mnt/sdb3            ext4       user,acl,nofail       1 2

nofail option ensures there will be no failure even if my removable hard disk doesn’t exist while booting system.
and then i have to manually change /mnt/sdb1 's ownership.

i don’t wanna format my hard disk to NTFS because ntfs-3g works in user mode and consumes too much CPU ( 40% when copying a 4G-size file ) , and ntfs is slower ( 30MB/s constrast to 60MB/s ) when copying a 4G-size file


> ll /mnt/
drwxr-xr-x 3 bruce users 4096 7月  23 19:28 sdb1
drwxr-xr-x 3 bruce users 4096 7月  23 13:54 sdb2
drwxr-xr-x 3 bruce users 4096 7月  23 14:01 sdb3
drwx------ 2 bruce users 4096 7月  12 17:17 veracrypt1
> cat /etc/fstab 
......
UUID=385acbee-ebab-42e4-ae38-499fd4841e40 /mnt/sdb1            ext4       user,acl,nofail       1 2
UUID=e48ca8d7-5e36-46aa-9ec2-77dca3184d9a /mnt/sdb2            ext4       user,acl,nofail       1 2
UUID=dc188773-62ac-4377-b549-1827ef3d43e8 /mnt/sdb3            ext4       user,acl,nofail       1 2

there is a weird thing happens with this code snippet
if this hard disk is already plugged in before booting system, my system will automatically mount all these three partitions.
but when i plugin my removable hard disk after system already booted, my system will also automatically mount all these three partitions, and i bruce user can write !
and i do not enable automatic mounting of removable media
http://i.imgur.com/yVFlGeI.png

You told the system to mount when present. What is so strange?? The system will use the fstab file if it has an entry for the partition(s). If you don’t want the partitions mounted don’t put them in the fstab

yes ,you are right.
if there is no explicit noauto option, this entry will be automatically mounted while booting . and if the hard disk does not exist, the boot sequence will be halted. and the entry will be automatically mounted after the disk is plugged in
some posts in stackoverflow said there is an option named nobootwait can fix boot sequence hanging , but this option doesn’t work in openSUSE 13.2.

Well, use noauto. That is normal when the disk is not always available at boot.
Do nnot use /dev/sdxn in your fstab entry/ies, but /dev/disk/by-id or other that identify the partitions without doubt.

And use user (or users) to allow any user to mount (or mount and unmount) it.

I do noy know if the desktop(s) will still show pop-ups when the device is connected. When not, create a mount and an unmount script for the user that can of course be started using some nice icons on his desktop.

That is what I probably would do.

On 2015-07-23 13:36, BruceAuyeung wrote:
>
> @hcvv thanks for your advice.
> actually i know about file / directories’ ownership and access bits
> very much. i also know how to manually mount or automatically mount
> with -/etc/fstab-.
> what i just wanna know is that whether it is possible to auto-mount
> removable hard disks within dolphin / krusader / system tray
> notification by a simple click which a newbie linux user can do.

The usual trick is to create directories in that “hard disk” with the
appropriate permissions and ownership, and not use the root directory of
that “disk”.

Notice that with automatic mounting, the mount point is volatile.


Cheers / Saludos,

Carlos E. R.

(from 13.1 x86_64 “Bottle” (Minas Tirith))