How do I give multiple users access to a Windows NTFS partition?

Alexander Sandler

I have USB hard-drive connected to my Ubuntu (11.04) machine. Every time I reboot the computer and login it mounts the hard-drive. Since the disk has NTFS on it, Linux assigns some user to be the owner of the files on the disk. So all files on the disk appear owned by one user and only that user can see the files.

I use two user accounts on my computer and often switch between them. Once I switch to other user account, I can no longer access contents of the disk because it is owned by my first user account. Is there anything can be done about it except mounting it via /etc/fstab?

Thanks.

con-f-use

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 with umask=, fmask= and dmask= options in the mount command. Here is an example:

mount -O dmask=007,fmask=117,gid=46,uid=1000 /dev/sdc1 /media/winhdd

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:

# In /etc/udev/rules.d/70-usb-winhdd-mount.rules

KERNEL=="sd?[0-9]", ATTR{removable}=="1", ATTRS{serial}=="UA04FLGC", ACTION=="add", RUN+="mount -O dmask=007,fmask=117,gid=46,uid=1000 /dev/%k /media/winhdd"

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:

groupadd winhdd
usermod -a -G winhdd confus

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 like winhdd: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 command getent group winhdd would show the line with information about the group. The id 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:

7 – no permissions     6 – execute only    5 – write only
4 – write and execute  3 – read only       2 – read and execute
1 – read and write     0 – read, write and execute

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I extend the size of an NTFS partition?

how do I give users capabilities

Mounted NTFS windows-linux shared partition works for users r-w, but access denied for programs

Deleted Windows E:\ drive ; now how do I give that partition to Ubuntu?

How do I give different users access to different rows without creating separate views in BigQuery?

How do I give access to other users if they don't have SSH keys?

How do I give access to a Former users Outlook Calendar to another User

How do I use 'chmod' on an NTFS (or FAT32) partition?

How do I share a folder on a NTFS partition over the network?

How to give access to Multiple Firestore Documents for Specific Users through Rules

How can I give two users access to a folder?

How can I use setfacl to give no access to "other" users?

How to access through terminal to a ntfs partition mounted?

I want to give access to users of their own dropbox from my java web app. How can I do that?

How do I stop Windows from stopping write access to an unmounted EFI partition on a disk that is not used by Windows?

How should I do to resize a partition taking free space from ntfs partition?

How do I give users the ability to make their private playlist?

Give same access to folders/files for multiple users

I changed permissions on a drive and now Windows Backup says "Access is denied." How do I give it read access?

How can I resize NTFS partition in GParted?

How should I prevent data corruption on an NTFS partition shared by Windows and Linux?

How can I write a Windows (NTFS) .img file to a partition and add it to grub?

How do I find Windows users and groups who have sysadmin access to SQL Server Express?

Ubuntu not detecting NTFS partition on second HDD. How do I make it detect it?

How do I mount another NTFS partition of an external hard drive running Ubuntu?

With fstab, how do I automatically mount an NTFS partition with full permissions for every user?

I can't get access to NTFS partition : This location could not be displayed

How to give access to a database to only specific users?

How to give users temporary access to specific links?