Ubuntu: USB drive auto-mounted by user but gets write permissions for root only



Question:

I am trying to use my ext4 USB drive but Ubuntu 13 is currently mounting it with write permission only for root so with my normal user I can't write to it, without sudo.

The first place I checked was dconf-editor which has the following options

  • automount
  • automount-open
  • autorun-never
  • autorun-x-content-ignore
  • autorun-x-content-open-folder
  • autorun-x-content-start-app

and it seems to me there should be an option in there to control if I can write to the mounted USB drive, but no.

I also made sure my user is in the relevant groups: fuse and plugdev

I've searched most of the internet and can't find a solution to change the permissions given by the mount operation. There's literally nobody out there having this problem incredibly. A ton of people have issues because their drives mounts totally read-only, but not this way with only root write permission.

I can't see any way of controlling what happens. I looked at setting the mount options using gnome-disks but drew a blank.

It's not in fstab but it does appear in the mount list or /etc/mtab:

/dev/sdb1 /media/adam/WDPassport2T ext4 rw,nosuid,nodev,uhelper=udisks2 0 0  

This is what appears in syslog if it helps:

kernel: [111522.196770] usb 2-1: USB disconnect, device number 6  kernel: [111525.384020] usb 2-1: new high-speed USB device number 7 using ehci-pci  kernel: [111525.565220] usb 2-1: New USB device found, idVendor=1058, idProduct=0820  kernel: [111525.565225] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=5  kernel: [111525.565227] usb 2-1: Product: My Passport 0820  kernel: [111525.565229] usb 2-1: Manufacturer: Western Digital  kernel: [111525.565231] usb 2-1: SerialNumber:  575832314141334A34383631  kernel: [111525.565729] usb-storage 2-1:1.0: USB Mass Storage device detected  kernel: [111525.566203] scsi9 : usb-storage 2-1:1.0  mtp-probe: checking bus 2, device 7: "/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1"  mtp-probe: bus: 2, device: 7 was not an MTP device  kernel: [111526.564697] scsi 9:0:0:0: Direct-Access     WD       My Passport 0820 1007 PQ: 0 ANSI: 6  kernel: [111526.565063] scsi 9:0:0:1: Enclosure         WD       SES Device       1007 PQ: 0 ANSI: 6  kernel: [111526.568096] sd 9:0:0:0: Attached scsi generic sg2 type 0  kernel: [111526.568202] ses 9:0:0:1: Attached Enclosure device  kernel: [111526.568263] ses 9:0:0:1: Attached scsi generic sg3 type 13  kernel: [111531.263108] sd 9:0:0:0: [sdb] 3906963456 512-byte logical blocks: (2.00 TB/1.81 TiB)  kernel: [111531.265100] sd 9:0:0:0: [sdb] Write Protect is off  kernel: [111531.265105] sd 9:0:0:0: [sdb] Mode Sense: 47 00 10 08  kernel: [111531.266473] sd 9:0:0:0: [sdb] No Caching mode page found  kernel: [111531.266479] sd 9:0:0:0: [sdb] Assuming drive cache: write through  kernel: [111531.272224] sd 9:0:0:0: [sdb] No Caching mode page found  kernel: [111531.272230] sd 9:0:0:0: [sdb] Assuming drive cache: write through  kernel: [111531.284885]  sdb: sdb1  kernel: [111531.288219] sd 9:0:0:0: [sdb] No Caching mode page found  kernel: [111531.288223] sd 9:0:0:0: [sdb] Assuming drive cache: write through  kernel: [111531.288227] sd 9:0:0:0: [sdb] Attached SCSI disk  kernel: [111531.751588] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)  udisksd[3131]: Mounted /dev/sdb1 at /media/adam/WDPassport2T on behalf of uid 1000  


Solution:1

A possible reason could be that you formatted/created the storage disk with a tool with root privilege and so the file-system created was owned by the root.

Let's have a look at the o/p of your ls commands:

$ ls -ld /media/adam/WDPassport2T  drwxr-xr-x 4 root root 4096 Jan 15 16:57 /media/adam/WDPassport2T  $ ls -l /media/adam/WDPassport2T  total 20   drwxr-xr-x 2 root root 4096 Jan 15 16:57 backuppc   drwx------ 2 root root 16384 Jan 15 15:37 lost+found  

The file-system is owned by the root, as indicated by ls -ld for your mount WDPassport2T and the permission string drwxr-xr-x shows the owner root has the RW permissions while, the members of group root along with the world/others will only have R-permission.

To solve you could change the permissions with chmod or just change the ownership recursively, and this is what I've shown below:

sudo chown <username>:<groupname> -R /path/to/target  

which in your case would be:

sudo chown adam:adam -R /media/adam/WDPassport2T/  

Now if you need, you may also set the permissions with chmod:

find /media/adam/WDPassport2T/ -type f -execdir chmod 666 -Rv {} +  

(which gives owner, group and the world RW permissions for all the files in the target.)

find /media/adam/WDPassport2T/ -type d -execdir chmod 777 -Rv {} +  

(which gives owner, group and the world RWX permissions for all the directories in the target.)

Reference:

Official Ubuntu Documentation: File Permissions


Solution:2

Have you tried re-formating the drive with your own permissions?

First, check your user id:

sudo id -u red  

It should give "1000"

Next, unmout the drive in filemanager.

Be careful, you will lose all your data with the next comand

sudo mkfs.ext4 /dev/sdx1 -E root_owner=1000:1000  

Mount the drive and you should be able to write files and folders


Solution:3

Most partitioning & formatting tools (like Gparted) requires the root privileges.

File systems like ext4, ext3 stores file ownership information with the pen drive itself. (But the ntfs, fat32, fat16 does not have a security like that)

In this case you have to change the permission by using the following command in the terminal.

chown -hR nobody:nogroup /media/adam/WDPassport2T/  

by setting the user as "nobody" & the group as "nogroup" it will fix the similar issues with permissions / ownership when plugged the disk into another box.

for more info see the manual page for chown command (use "man chown" )


Solution:4

The file-system is owned by the root, as indicated by ls -ld for your mount WDPassport2T and the permission string drwxr-xr-x shows the owner root has the RW permissions while, the members of group root along with the world/others will only have R-permission.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »