How do I share a folder on a NTFS partition over the network?
Solution 1
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.
Solution 2
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
Related videos on Youtube
Exeleration-G
I'm not a professional, I'm just trying to help other people with the knowledge I gained myself.
Updated on September 18, 2022Comments
-
Exeleration-G about 1 year
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
andcat /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?
-
Admin almost 12 yearsWhen you say "over the network" what do you mean, what kind of computers are going to be there? Windows? Then you need samba, only Linux? Then NFS is recommended... Give us more info.
-
Admin almost 12 yearsI think permissions in
fstab
needs to be changed. Try the same procedure with removedgid
(don't forget to remount), and tell us if it helped. -
Admin almost 12 yearsI have updated the question. Removing
gid
from/etc/fstab
makes the last line look like this:/dev/sda4 /media/Data ntfs defaults,umask=007 0 0
./dev/sda4
isn't mounted on startup,sudo mount /dev/sda4 /media/Data
gives me the following output:Mount is denied because the NTFS volume is already exclusively opened. The volume may be already mounted, or another software may use it which could be identified for example by the help of the 'fuser' command.
-
-
Exeleration-G almost 12 yearsThat would be
ln -s
, right? Trying it out right now. -
Patrick almost 10 yearsBrilliant. As a complete linux/ubuntu novice I was banging my head against the wall for 2 days because If this had been a windows machine I would have had it done in 10 minutes.
-
Enrique Moreno Tent about 9 yearsCan you edit this answer with all the commands you had to write, please? I am not sure I understand what you mean with "give myself ownership over
/dev/sda4
". -
Exeleration-G about 9 yearsSure, but afterwards, please give me an update on whether the instructions worked for you. I'm not using a NTFS partition anymore so I can't check by myself.
-
Nitish Kumar Diwakar over 2 yearsdidn't worked..
-
Nitish Kumar Diwakar about 2 yearsDidn't worked for me in Fedora 34.