Mount NTFS partition at startup, with non-root user as owner
Solution 1
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 frommount -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
Solution 2
Use the uid
and gid
options (or use the user mapping feature) of mount.ntfs (8)
Solution 3
Mine works now perfectly when i change the fstab's line to
UUID=761C84B31C846FC3 /media/d ntfs defaults,umask=022,uid=1000 0 0
Solution 4
What about using udisks
? It can easily mount NTFS partitions with your user as owner.
Example (type it into command line):
/usr/bin/udisks --mount /dev/sda3
You can also add that command to startup applications and it will auto-mount when you log-in.
Reference: AutomaticallyMountPartitions
Tomas Aschan
I am an engineering physicist from Stockholm, Sweden, with a passionate interest in programming and software architecture. Since creating my first program at age 12 (a VB6 app that showed a smiley when a button was clicked) I've spent many hours in front of my computer, watching screen casts and reading blogs about programming as well as trying all the new concepts out in my own programs. With a Master's degree in Engineering Physics from the Royal Institute of Technology in Stockholm, Sweden, I have deepened my modelling and reasoning skills, as well as had the opportunity to try out many different technologies and tools. I am currently working as a software engineer at Spotify, mostly massaging data to enable our internal research into developer productivity.
Updated on September 18, 2022Comments
-
Tomas Aschan over 1 year
I'm currently mounting an NTFS partition at startup using the following line in /etc/fstab:
/dev/sda3 /media/data ntfs nls=iso8859-1,umask=000
To my Ubuntu 11.10 installation, it looks as if all files and folders are owned by
root
- and since NTFS doesn't really support the same rights management system anyway, there's no way I can change it after the mount is complete. No matter what I do,ls -l
anywhere on the NTFS partition will list every file and folder as owned byroot:root
.However, this causes some problems for me. Most notably, some applicaitons running under my account (called
tomas
) complain about access rights. Also, whenever I try to copy (cp
) or move (mv
) files from one of my ext3 partitions to the NTFS partition, I get error messages sayingmv: preserving times for `[path to new file]`: Operation not permitted
or, similarly
mv: preserving permissions for ...
Would mounting the partition in my name instead of root help? If so, how do I accomplish that in fstab?
Update:
I have now changed the options according to the suggestions, and arrived at this:
nls=iso8859-1,permissions,users,umask=000,uid=tomas,gid=tomas
ls -l
now shows all files owned by me instead of by root, and it seems some of the problems I had before are solved. However, not all of them.When I start Eclipse, I get an error that a file related to the android-sdk cannot be run: Permission denied.
ls -l
tells me the following about the file:-rwxrwxrwx 1 tomas tomas 159620 2011-11-29 14:50 adb*
This looks the way I want it to. But if I try to run it (
./adb
in a terminal) I also get permission denied errors. But if I run it withsudo
, it works (I believe - at least it doesn't give me an error message, but it doesn't give me any output at all, which I think it shouldn't...)Why is the above file, with execute permissions for anyone, still not executable by anyone else than
root
? How do I change the way I mount the file system so it is?
Update 2:
OK, I've now come a little bit further. By mounting with these options
nls=iso8859-1,permissions,users,auto
I got all the permissions set the way I expect them to, and
chown
andchmod
actually change settings on the files (at least according tols -l
) =DBUT my system still behaves in a weird way. The permissions for the
adb
script file come up as above, but neither I nor Eclipse can run it without "Permission denied" errors. But as far as I can see the file has all the required flags set (o=rwx
should be enough, right?). Why doesn't it work?
Update 3
OK, I got everything working on the Ubuntu side, with the following options:
nls=iso8859-1,permissions,users,auto,exec
However, when I try to access files on the partition from Windows, the security settings are all messed up. On all the files (of those few I've examined) a new account called
Account Unknown(long GUID)
has been added to the list of users, and has full rights. Rigths for most other users are decreased so that I don't have rights to do stuff I expect. Notably "Everyone" does no longer seem to have right to "Traverse folder / execute".This might be solvable by just selecting the partition and allow Everyone to do anything on the root folder, and then tell it to do it recursively, but I'd rather not as I'm afraid it will take days to complete...
-
Admin over 12 yearsFrom mount(8) :
users Allow every user to mount and unmount the filesystem. This option implies the options noexec, ... unless overridden by subsequent options, as in the option line users,exec,dev,suid)
. So addexec
to your options and I believe the permission denied issue for execution should be resolved. -
Admin over 7 yearsDid you ever get this solved after Update 3? ... I tried at one point to do a rsync backup of my linux system to an extra ntfs drive I had, but after a great deal of searching, came to the conclusion that I could never put the full array of linux file system information onto a ntfs fs. (Well perhaps I could come close as you have done above, but in the end linux doesn't map very well onto ntfs.)
-
Admin over 7 years@Elipticalview: This is long ago, and I don't have the same computer anymore. Did you try the accepted answer?
-
-
Tomas Aschan over 12 yearsHm... after adding that to fstab (making hte options column the following:
nls=iso8859-1,permissions,users,umask=000
) and rebooting I can now move and copy files without error messages. All files still show up as owned byroot:root
though, even aftersudo chown -R tomas:tomas /media/data
. It doesn't seem to be a problem for now, but out of curiosity: why is that? -
Panther over 12 yearsI think because of your
umask=000
-
psusi over 12 yearsIn other words, add uid=whoever to the fstab line
-
Tomas Aschan over 12 yearsNo,
umask=000
is equivalent tochmod 777
- umask defines all the flags you don't want to set on the files. I agree it's counterintuitive, but it's all here: ubuntuforums.org/showpost.php?p=9092899&postcount=4 -
Panther over 12 years
uid
andgid
work, but permissions are now supported in ntfs-3g, and those options over ride thepermissions
option. See: b.andre.pagesperso-orange.fr/permissions.html -
Tomas Aschan over 12 yearsI've updated my question with further info about what I've tried and the results.
-
Tomas Aschan over 12 yearsI've updated my question with further info of what I've tried and the results I got. Please take a look =)
-
Panther over 12 yearsThe permissions option should work with chown and chmod
-
Panther over 12 yearsSee the information I included in my answer.
-
Tomas Aschan over 12 yearsHa! When I added
exec
as well, everything worked! Thanks a lot! -
Tomas Aschan over 12 yearsHm... I'll have to un-mark this for the time being: it turns out, this messed up the permissions when reading the files from Windows...
-
Panther over 12 yearsCheck out the link I gave earlier: b.andre.pagesperso-orange.fr/permissions.html It shows how to map users properly. I've not used it as I do not use Windows and I hear Microsoft made some changes to ntfs with windows 7. Good luck to you.
-
Panther over 12 yearsAnd a more detailed example here: b.andre.pagesperso-orange.fr/example.html
-
Tomas Aschan over 12 yearsI've tried following the tutorials now, but I suspect I'm having problems with the mappings file. Please read my update for my a description of the symptoms.
-
binga30 over 10 yearsShould be
sudo chown -R...
rather thansudo -R chown ...
. -
Khurshid Alam almost 9 years@bodhi.zazen My fstab is
UUID=B870533B7052FF94 /media/TEMP ntfs-3g exec,permissions,users,auto,locale=en_IN 0 0
.....but with this every new directory getsdrwxrwxrwx
and file gets-rw-rw-rw-
permission. Is that ok? Usually I want 775 for directories and 664 for files. But if I change that will I be able to access file from windows? -
rbrito almost 9 yearsRight, the magic piece here is the
permissions
option (which, unfortunately,udisks
(orudisks2
) doesn't let you pass viaudisksctl
). -
endolith over 7 years"In the options column add "permissions" and auto (and probably user or users)" Can you explain what these do?
-
Panther over 7 years@endolith - see man mount. permissions allows you to set permissions, auto means it automatically mounts at boot, and users means users can mount and unmount (not just root). linux.die.net/man/8/mount
-
Panther over 7 years@endolith - tuxera.com/community/ntfs-3g-manual
-
Rajat Pandita over 7 yearsWorks fine for me!
-
Vishal Kumar Sahu about 2 yearsFor me this doesn't work at startup in Ubuntu 20 LTS drive still remains belonging to root user. I created symbolic link from home to the directory. This is weird. As same thing worked like charm when I used it as a storage mount point.