Announcement

Collapse
No announcement yet.

Can not access SD cards as user

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Can not access SD cards as user

    Hi, I have a strange behaviour for 20.04:

    On my desktop PC I can not access any longer my SD CARDs as normal user. As root I can, but changing rights to user will not work. Even Gparted has problems - when reformatting I have to reboot before it works. But even then I still can not acces those cards. I have the same Kubuntu version on my laptop and there it works. I have excluded SD Card as a problem (on my laptop it works flawless) and also the build in card reader on my desktop - when using an external USB card reader the effect is the same.

    The difference I found (which would explain the behaviour on my desktop PC)
    desktop : owner: root
    Laptop : owner: username

    Why is it mounted in the first case for root and in the second for user? I have checked the settings for removable media in the system settings of KDE, it says "automatic mount" and only the two lower buttons are checked on both PCs. /etc/fstab are the same - not much in and nothing regarding /sd*

    #2
    Removable devices aren't normally mounted in fstab. UDEV handles removables.

    What does "ll /media" return? It should look something like:

    drwxr-x----+ 1 root root <date> <your username>

    Then when you insert a device and open it with Dolphin, your should see a new folder under /media/<username> as the device name and it should have permissions of:

    drwxrwxrwx

    and have your owner/group ownership. Check both systems and report what's different

    Please Read Me

    Comment


      #3
      SD cards are normally formatted with the FAT32 file system, with VFAT long file names. That file system does not have ownership or permissions, and the owner and permissions to use are set at mount time. There's a mount option that specifies a "umask", confusingly the inverse of the permissions in octal. Somehow, the SD card has been mounted with owner root and permissions mask 022; these are fixed for the whole device and can't be changed with chown or chmod.

      To correct this, you could use sudo commands to unmount the device, and mount again specifying -o umask=0. But, it shouldn't be like this. I suspect that KDE is remembering the device, and automatically remounting with the root ownership.

      I suggest removing it, then going to system settings, removable storage and see if you can tell KDE to forget it there. If that doesn't work, I'd try unmounting it with sudo umount, then clicking on the device in dolphin to trigger a normal udev mount, which should make the owner your user.
      Last edited by jlittle; Jun 21, 2020, 09:15 PM. Reason: typo
      Regards, John Little

      Comment


        #4
        Uhh, sorry for the late reply - my apologies...
        jlittle: well, this did not work.
        oshunlvr: not sure what you mean with "ll /media". A "ls / -l" shows: "drwxr-xr-x 13 root root 4096 Jun 10 20:03 media" When doing the check with Dolphin the card is mounted under /media/<username>/NameofSDcard BUT "User: root" and "Group: root" and no access for me as user.

        Comment


          #5
          What happens when you type "ll /media" ? ll is two lower case L's. It's a standard shortcut for "ls -l"

          Those permissions are correct for /media. What you need to check is the permissions of your user folder under /media. With no media inserted, the permissions should as I showed above. The plus sign is critical.

          If the plus sign is there and username folder is your username, enter this in Konsole:

          sudo getfacl /media/username/

          replace username with your actual folder name.

          You should get this is response:

          getfacl: Removing leading '/' from absolute path names
          # file: media/username/
          # owner: root
          # group: root
          user::rwx
          user:username:r-x
          group::---
          mask::r-x
          other::---


          This is what gives your user access to the sdcard. If this is all in place, then depending on the filesystem the sdcard itself may need to be reset.

          Please Read Me

          Comment


            #6
            Hi oshunluvr,
            well, for "ll /media" I get - with no card inserted:
            --------------------------------------------------------------------------
            drwxr-xr-x 13 root root 4096 Jun 10 20:03 ./
            drwxr-xr-x 22 root root 4096 Jun 13 11:28 ../
            lrwxrwxrwx 1 root root 45 Jul 9 2019 .directory -> /etc/kubuntu-default-settings/directory-media
            lrwxrwxrwx 1 root root 42 Jul 9 2019 .hidden -> /etc/kubuntu-default-settings/hidden-media
            drwxr-xr-x 2 root root 4096 Nov 24 2019 isoimage/
            drwxr-x---+ 2 root root 4096 Apr 3 14:15 root/
            lrwxrwxrwx 1 root root 4 Jun 10 20:03 usb -> usb0/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb0/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb1/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb2/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb3/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb4/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb5/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb6/
            drwxr-xr-x 2 root root 4096 Jun 10 20:03 usb7/
            drwxr-x---+ 15 Benutzer users 4096 Jul 7 13:36 Benutzer/
            ----------------------------------------------------------------------------
            the getfacl shows:
            --------------------------------------------------------------------------
            sudo getfacl /media/Benutzer/
            getfacl: Entferne führende '/' von absoluten Pfadnamen
            # file: media/Benutzer/
            # owner: Benutzer
            # group: users
            user::rwx
            user:Benutzer:r-x
            group::---
            mask::r-x
            other::---
            --------------------------------------------------------------------------
            Interestingly it does not say "root root" as owner, it is always "Benutzer users". When inserting a SD card nothing changes.

            Comment


              #7
              Yeah, that's a lot of USB folders and your folder isn't set right. I can't say for sure that't the issue but it sure seems like it could be.

              Please Read Me

              Comment


                #8
                Well, but why was there no problem with 19.04 ? I do not know for sure if there always has been this structure, but the problems came up with the upgrade from 19.04 to 20.04 ...and why does this change the ownership from root to Benutzer for /media ? On my laptop I do not have so many USB folders, but the /media/Benutzer shows "owner: root group: root" and there it works to access the SD card as user... well I am lost...

                BTW: changing user/group to root like on the laptop for the SDCard works, but has not effect - can not do anything on the directory/files
                Last edited by Ndimensional; Jul 08, 2020, 08:48 AM.

                Comment


                  #9
                  I have seen this once before. I hate to tell you to do something that would make it worse, but I'd start by deleting everything in /media/ except the the hidden links (.directory and .hidden). Then log out and back in. It may just fix itself.

                  You may have to recreate the
                  Benutzer folder with the proper ACL settings.

                  Please Read Me

                  Comment


                    #10
                    I tested this with a new user and the first time you mount an external device, it creates the folder. Maybe if you clean out the /media folder, log out, log back in and mount a thumb drive it will re-create the folder correctly.

                    If the folder comes back but not correctly, we'll have to dig deeper

                    Please Read Me

                    Comment


                      #11
                      Well, took a moment. I had to take a disk image, just in case.
                      Then I did a "rmdir *" in "/media/Benutzer". But could not remove all the directories - "... device busy or ressoucre blocked". But I could explicitly remove "rmdir UM2SD8GB". Then first logged out/in - also tried to reboot. Each time now the folder is recreated when I insert a SD card - but I still can not access this as a normal user. Again, as root it is o.k. The folder is recreated as: drwxr-xr-x 2 root root 32768 Jan 1 1970 UM2SD8GB also did
                      getfacl UM2SD8GB
                      # file: UM2SD8GB
                      # owner: root
                      # group: root
                      user::rwx
                      group::r-x
                      other::r-x

                      Well, what I still do not understand: it says "user::rwx" and is mounted in "/media/user" - even though I have no access as user. By the way, when mounted via Vmware as a removable device, it is accessible in Win7-VM as normal user.

                      Will try to unload all the different devices in the "/media/Benutzer" and then to remove them. But can not do this today...

                      BTW: thank you very much for your persistence and help ! I would like to answer much faster, but have only little time for my problems...

                      Comment


                        #12
                        Originally posted by Ndimensional View Post
                        ... But could not remove all the directories - "... device busy or resoucre blocked".
                        If any process has a directory as its "current working directory", that makes it busy. There's ways to track down what is holding it open, particularly the fuser command.
                        Originally posted by Ndimensional View Post
                        # file: UM2SD8GB
                        # owner: root
                        # group: root
                        user::rwx
                        group::r-x
                        other::r-x
                        Well, what I still do not understand: it says "user::rwx"
                        This is a kludge from ancient Unix usage. The word "user" here is very misleading, it should be "owner", but the letter "o" is taken. So root has rwx, and the actual user has r-x. Dolphin gets this right, if you check the properties of a file, and click the permissions tab.
                        Originally posted by Ndimensional View Post
                        and is mounted in "/media/user" - even though I have no access as user.
                        It definitely is not supposed to do that.
                        Google has pulled up something, do you have a package called "usbmount" installed? It should not be.
                        Regards, John Little

                        Comment


                          #13
                          Awsome ! Removing usbmount did the job. I have access now ! And yes, usbmount was not installed on my laptop where I did not have the problem. Not sure why I installed usbmount, but it was recommended quite some time ago for some problem with usb - but unfortunately I do not remember. And I hope that it is no longer necessary up from now. May be something in 19.04 made it necessary...

                          Again all of you: thank you very much for your help !

                          Comment

                          Working...
                          X