8

I have been trying to write onto a newly created partition My partition block is /dev/sda6

I am unable to write anything onto that partition. My Corresponding fstab file is this

/dev/disk/by-id/ata-WDC_WD5000BEVT-24A0RT0_WD-WXD1EA0TV384-part7 swap                 swap       defaults              0 0
UUID=827020aa-bccf-493e-acdc-21dd8eb98639 /                    btrfs      defaults              1 1
/dev/disk/by-id/ata-WDC_WD5000BEVT-24A0RT0_WD-WXD1EA0TV384-part8 /boot                ext4       acl,user_xattr        1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
/dev/sda6            /home/hawk/gentoo            ext4       users,gid=users,fmask=133,dmask=022                   1 2

If I format it back to any other windows based file system such as fat I am able to both read and write

manugupt1
  • 181
  • 1
  • 1
  • 3
  • I think your fmask option is too strict and gives no read permission on files to group and other. Set it to fmask=000 or just leave it out to get rw- permissions on all files. You shouldn't have executable permissions by default. –  Mar 03 '12 at 14:25
  • Also, I think the gid option only accepts group id numbers, so it should read gid=100 instead. And you should add the rw option (I forgot mentioning that). –  Mar 03 '12 at 14:47
  • No need to add rw. It's the default behaviour. It's ro that must be specified explicitly. However, users should be user. – Alexios Mar 03 '12 at 17:10

3 Answers3

6

You can't; ext[234] doesn't support the uid/gid options or any other way of overriding the on disk permissions at mount time. You must set the permissions correctly on the disk as root.

psusi
  • 17,303
1

A similar question came up to me on [How fstab mount options work together with per file defined permissions in linux and got a detailed answer by the community!

The thing with etx4 is that the mount options in fstab are used in combination to the permissions stored for each file. This is of course contrary to NTFS that does not have any linux permissions associated per file and thus takes such arguments from the fstab mount options only.

So, in order to make a file stored in an EXT4 filesystem writable by a certain user you need to both:

1) mount the disk with rw or defaults to enable writing to the filesystem in general AND

2) have a set of permissions set for each file such as the user CAN write to it, this can be achived with various ways..

a)If the file is owner by the user and write permission is granted to the owner

[sudo] chown user:user file
[sudo] chmod u+w file

b)If the file is owned by the group the user belongs to and write permission is granted to the group

[sudo] chown other_user:users file
[sudo] chmod g+w file


c) if the file is granted permission to write by anyone:

[sudo] chmod a+w file

0

I'm not sure if you are still facing this problem, but I agree with @htor on the unnecessary strict fmask (and dmask?) values - unless you know what you are doing. I don't have a real ext4 partition, but the following /etc/fstab entry works just fine for an ext3 partition:

/dev/sda1       /virtual        ext3    noatime,users,acl,user_xattr   1 2

One more point, looking at the mount point (/home/hawk/gentoo), it seems that you are mounting a partition that is used in a different distribution (Gentoo) onto your currently running distribution. If so, please make sure you use the gid= value that matches the corresponding group id of your user from the original distribution (Gentoo).

Srinidhi
  • 486