In the options column add permissions
and auto
(and probably user
or users
)
nls=iso8859-1,permissions,users,auto
permissions
: (NTFS-3G option) Set standard permissions on created files and use standard access control.
auto
: Will be mounted at boot and from mount -a
user
: Allow an ordinary user to mount the filesystem
users
: Allow every user to mount and unmount the filesystem
Then change ownership of the filesystem:
sudo chown -R thomas:thomas /media/data
My line in /etc/fstab
/dev/sda5 /media/ntfs ntfs-3g users,permissions,auto 0 0
Mount and list permissions
sudo mount /media/ntfs
Using default user mapping
bodhi@ufbt:~$ ls -l /media
drwxr-xr-x 1 root root 4096 2012-01-04 17:08 ntfs
Change ownership and list new permissions
bodhi@ufbt:~$ sudo chown bodhi:bodhi /media/ntfs
bodhi@ufbt:~$ ls -l /media
drwxr-xr-x 1 bodhi bodhi 4096 2012-01-04 17:10 ntfs
By default, ntfs-3g mounts the partition noexec, nosuid, and nodev.
noexec
: Do not allow direct execution of any binaries on the mounted filesystem.
nosuid
: Do not allow set-user-identifier or set-group-identifier bits to take effect.
nodev
: Do not interpret character or block special devices on the file system.
To override this and allow executing files, use exec
/dev/sda5 /media/ntfs ntfs-3g exec,permissions,auto 0 0
Now we get
bodhi@ufbt:~$ ls -l /media/ntfs
-rwx------ 1 bodhi bodhi 28 2012-01-04 17:16 file
bodhi@ufbt:~$ /media/ntfs/file
It works
The fuse
mounting done by nautilus has one advantage over system-wide mounts in /etc/fstab
: it knows which user is doing the mounting. Assuming you are the only user of your client machine (which is fair enough these days), you can get your numeric UID and GID and default umask with:
$ id
uid=1001(msw) gid=1001(msw) groups=…
$ umask
0002
then you'd add these to the options group in fstab
defaults,uid=1001,gid=1001,umask=077,windows_names,locale=…
it would be wise, but not required to replace defaults
with
auto,rw,nosuid,nodev,noexec
nautilus assumes that a user mounted partition is "untrusted" so flags them this way. A foreign (i.e. NTFS) partition should probably always be viewed with such suspicion.
added in response to comment:
This is an area where cross-system semantics get weird. The mount.ntfs(8) manual defines fmask
and dmask
to try to make files created on an NTFS filesystem behave better. Can I ls
a directory not owned by me under windows? Should I be able to? Is there any relation between your UID on Linux and Windows? Dunno.
There is a usermapping=
option for mount.ntfs which supersedes uid, gid, umask, fmask, and dmask. I suggest you look into that if you want fine control on what files are assigned what permissions. I would check to see that you can even access them from the Windows side before committing too much under a usermapping mount.
Best Answer
Mounting with specific permissions
There is. Put both users in a group together. Then use that group's to set the
gid=
option and and mount your disk with the permissions you want it to have. You can control permissions withumask=
,fmask=
anddmask=
options in the mount command. Here is an example:These options can also be used in
/etc/fstab
like this:UUID=7258CB9858CB598D /media/win ntfs rw,auto,user,exec,nls=utf8,dmask=007,fmask=117,gid=46,uid=1000 0 2
.Avoiding fstab - automounting a specific disk with udev
I imagine you want to avoid fstab because the disk it not always connected on boot. If you wish to avoid fstab use a udev rule. Udev can automatically mount (and prevent Ubuntu from automounting) when the disk is connected. A rule for that may look like this:
You will need to identify the disk by it's properties. In my example I did this by
ATTRS{serial}=="UA04FLGC"
. I described how to do this in another question. The naming and location of the rules files is described there too.Give all removable disk those properties
If you want to do this with all removable disk - not just that particular one, simply leave out the serial part and be sure to assign a unique mountpoint (counting them, creating from serial, %-symbol of udev or other method). Also as stated elsewhere
ENV{mount_options}="$env{mount_options},dmask=007,fmask=117,gid=46,uid=1000"
could be an option for mounting all removable disks with certain permissions/onwership.Useful information you might already know:
Creating a group and adding users
Those are the shell commands to create a group named 'winhdd' and add a user named 'confus' to that group:
Finding out the group id
You can find the group ids of all the groups on your system in a file called
/etc/group
. The entries there look likewinhdd:x:4:confus,narur,joe
where 'confus', 'narur' and 'joe' are the user names belonging to that group, 'adm' is the group's name and '4' the group id, you're looking for. In/etc/groups
you can also check if adding the users to your group was successful. The commandgetent group winhdd
would show the line with information about the group. Theid
command gives you your group id, user id and the names and ids of all groups you belong to.Setting umask-like options
You'll want to set
dmask=
to a sensible value allowing you at least to execute (=access) directories.fmask=
is the option for file permissions.dmask=007,fmask=117,gid=46,uid=1000
allows the owner that is user number 1000 (first digit in the masks) and the the members of group number 46 (second digit in the mask) to read and write and files on the disk. Other users have no rights to do anything (hence third digit in the masks - the 7). Here are the mask values: