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

I'm on Ubuntu 11.10, and I want to share a folder on an automounted NTFS partition (/dev/sda4) over the network. The purpose of this network is to share files between computers, it contains mostly Windows computers. I use this /dev/sda4 partition both from Windows 7 and Ubuntu. Using Nautilus, I right-click the directory, then I click 'Sharing Options', then I mark the three checkboxes. When I try to apply the settings though, it says 'Couldn't change the rights of the folder "foldername"'.

I've put the output of sudo blkid and cat /etc/fstab below.

sudo blkid

/dev/sda2: LABEL="Windows" UUID="481319C261268D8D" TYPE="ntfs" 
/dev/sda3: UUID="23dac5e8-aae7-43ac-964c-c8a5a033b0d7" TYPE="ext4" 
/dev/sda4: LABEL="Data" UUID="00F1B269675B86AE" TYPE="ntfs" 
/dev/sda5: UUID="6de8b757-f17e-4e36-935c-a3fd6012c628" TYPE="ext4" 
/dev/sda6: UUID="d504bae2-fad6-4f6a-b489-7719ad0fe3b3" TYPE="swap" 

cat /etc/fstab

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda3 during installation
UUID=23dac5e8-aae7-43ac-964c-c8a5a033b0d7 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda6 during installation
UUID=d504bae2-fad6-4f6a-b489-7719ad0fe3b3 none            swap    sw              0       0
/dev/sda4 /media/Data ntfs defaults,umask=007,gid=46 0 0 

How can I share this folder?


After a bit of searching, I found the solution myself:

First, I had to give myself the ownership over /dev/sda4, and I had to give group and others read and execute permission. I did that by changing the partition entry in /etc/fstab.

To do that, I had to know my uid and gid. So the first thing I did was writing the following command in a Terminal:

id $USER

This will give an output like this:

UID=1000(myname) GID=1000(myname) groups=1000(myname),4(adm),24(cdrom), ...

So now I knew that both my uid and my gid were 1000.

Do you already know the name of the NTFS partition? If not, type this command in a Terminal:

sudo blkid

and write down the NTFS partition on a piece of paper.

Now, to change the permissions, I edited /etc/fstab with the nano text editor. So, the next command you have to type in a terminal is:

sudo nano /etc/fstab

Go all the way down and type this line:

/dev/sda4 /media/Data ntfs defaults,umask=0022,uid=YourUIDHere,gid=YourGIDHere 0 0

(You should replace /dev/sda4 by the NTFS partition that you wrote down earlier).

Explanation: umask=0022 sets the directory's (d) permissions permissions to drwxr-xr-x, to make sure that the user (me) can read, write and execute (rwx) while the group and others can only read and execute (r-x) the directory, which is what I wanted.

After that, I could mark the three checkboxes without any errors, and the folder would be shared over the network. Because I was not sure whether the sharing settings would be kept after a restart, I unchecked the checkboxes and added some lines in /etc/samba/smb.conf instead. I did that this way:

In a terminal, I typed sudo nano /etc/samba/smb.conf

I scrolled down to the last line, and pasted the following there:

[MyShare]
    comment = My Share
    path = /media/Data/FolderToBeShared
    browseable = yes
    guest ok = yes
    read only = yes
    create mask = 0755

I saved the file, and then rebooted. The folder was accessible from the network now.


just mount the ntfs dir as:

-o uid=current_user,gid=current_usergroup

get the current user and current user group as pointed by Exeleration-G:

id MyUserName