Pages

Tuesday, December 20, 2011

Ubuntu: Sharing folders from NTFS partitions

The fastest way to share files and folders on an Ubuntu machine is probably samba. This works much like the Windows File sharing mechanism (Righ-click on the folder and hit 'share'). However this may not work correctly if your data is on an NTFS drive. To fix this, read on...




Symptom:
Sharing has been set up through samba. The client machine can see your share but not view or access its contents ("Error: Unable to mount"). This is because Linux is very particular about file permissions. For sharing, all users need to be given access (Permissions should be: "rwx r-x r-x" for all shared files).
NTFS partitions do not have permissions attributes, as a result of which it is not possible to use the chmod command to change the permissions.

Solution:
The only way to change permissions is at mount-time. This can either be done via the fstab file, or through the command line. An excellent explanation is given here.

A few additional comments are warranted here:

1. The uid and gid values determine who is the owner of the mounted partition and which group it belongs to.

2. Umask is a 4-digit octal number which specifies which permissions are TO BE REMOVED. Yes that is correct. Read that again if you want. By default everyone has  read, write and execute permissions.

The first digit is for directory flag. LEAVE THIS at 0.
The second is owner permissions, the third for group permissions and the fourth for other users' permissions.
For all these,
0 means all permissions are retained (rwx),
1 means only execute permission is revoked
2 means only write permission is revoked
4 means only read permission is revoked
7 means all permissions are revoked, etc.

If you are not familiar with the this method of setting permissions please see the manual for chmod and its octal permission numbers.

No comments: