[SOLVED] Possible solutions to automatically mounting NTFS drive with read/write access?

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
ppp7032
Level 1
Level 1
Posts: 3
Joined: Thu Jul 22, 2021 8:05 am

[SOLVED] Possible solutions to automatically mounting NTFS drive with read/write access?

Post by ppp7032 »

I'm trying to set up automatic mounting of an MBR NTFS internal hard drive partition with read/write access to the non-root user. Changing mount options in the 'Disks' app didn't work, and I read somewhere that NTFS drives are never actually mounted automatically by the fstab unless you also try to access them. Regardless I found this console command that works:

Code: Select all

sudo mount -t ntfs-3g -o defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000 /dev/sdb1 /mnt/Server
where /mnt/Server is a folder I made manually. I made a bash script that runs this command however this is not currently a very user friendly solution. I've tried various ways to either modify the fstab, get the command itself to run at startup, and getting the script to run at startup. Any of these three ways of solving the problem would be acceptable. This includes messing around with /etc/rc.local and making a system service (which apparently mounted the partition but then subsequently unmounted it), among others.

Whichever of the three possible ways of fixing the issue you think would be easiest to implement, or are the most sure would work, just give a solution to that one.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
rossdv8
Level 7
Level 7
Posts: 1736
Joined: Wed Apr 23, 2014 4:48 am
Location: Within 2,000 kilometres of Alice Springs, Australia
Contact:

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by rossdv8 »

Are these options on the 'Disks' program you tried?
The Auto-open files and Auro-run programs might be useful.
Screenshot_2021-07-22_22-33-51-resized.png
Current main OS: MInt 21.3 with KDE Plasma 5.27 (using Compiz as WM) - Kernel: 6.5.0-15 on Lenovo m900 Tiny, i5-6400T (intel HD 530 graphics) 16GB RAM.
Sharks usually only attack you if you are wet
ppp7032
Level 1
Level 1
Posts: 3
Joined: Thu Jul 22, 2021 8:05 am

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by ppp7032 »

That menu seems to be regarding removable storage whereas my issue is with an internal HDD. Here is an image of the Disks app I was referring to. I tried the 'mount at startup option' you can see in the image but it does nothing. This is why I believe the easiest fix would be to just make the command in the original post, or the script that contains it run at startup. I just don't know how to do that.
Attachments
Screenshot from 2021-07-22 13-59-45.png
br1anstorm
Level 5
Level 5
Posts: 602
Joined: Mon Nov 24, 2014 8:53 am

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by br1anstorm »

There are forum members more expert than me who I'm sure will chip in to offer advice - notably AndyMH, who is exceptionally helpful. In fact you might like to look at this thread https://forums.linuxmint.com/viewtopic ... 0&t=352588 for ideas and options. I too was looking at ways of auto-mounting an internal SSD on which at least one partition is to be formatted NTFS.

The wise advice is not to use Disks, but rather use terminal commands to sort out "ownership" of the drive or partition as required (in order to permit read/write), decide on a mount point, then edit fstab to enable auto-mounting.

Hope this helps....
User avatar
Kris345
Level 5
Level 5
Posts: 536
Joined: Mon Jun 22, 2020 10:22 am
Location: New England

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by Kris345 »

This is something I do to one of my ntfs partitions simply because it has the "tbird" folder and I use that folder both by windows and by Mint.
from my notes: Your uuid's will be different of course. noatime means it doesn't have to be there.

automount E:
sudo blkid – to check E
/dev/nvme0n1p6: LABEL="E" UUID="01D749C6C7CAFC00" TYPE="ntfs" PARTUUID="d8d62147-5d9e-48a0-2b5e-dc1199f8a437"
sudo mkdir /media/E ←------
sudo apt install gedit
and add this to fstab: sudo gedit /etc/fstab
UUID=01D749C6C7CAFC00 /media/E ntfs-3g defaults,noatime,windows_names,locale=en_US.utf8 0 0
Save fstab
-->reboot<--
You will have to re-point-to local folder in Tbird, and any E doc stuffs.

BE VERY CAREFUL EDITING fstab or else you might find yourself booting to a live Mint stick and correcting it to get Mint to boot.
-- ASUS Prime Z790-V WIFI, I9-12900k, UEFI/GPT, 32GB, Sam 980 Pro 1T M.2 .
-- ThinkPad P15s-Gen1-20T4-002KUS, i7-10510U, UEFI/GPT, 16GB, Sammy 970 EVO Plus 500GB M.2.
-laserjets: HP M254dw color, HP P1606dn. Epson Perfection 2480 flatbed scanner -
JezekiljMonk
Level 3
Level 3
Posts: 106
Joined: Mon Dec 30, 2019 7:33 am
Contact:

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by JezekiljMonk »

Please, try this

Image

or like this

Image

I believe the Filesystem type: ntfs-3g is very important here

If it doesn't work please check

Code: Select all

getfacl /mnt/
and

Code: Select all

getfacl /mnt/4AB6F85...


Fill in the the full path to the folder. I prefer to place my HDDs in /mount/<my-user-name>, not in /mnt/

When it comes to running a script that can automatically after log-in mount your drive I have posted a solution here

https://www.linuxquestions.org/question ... ost6219765

Hope something will help
altair4
Level 20
Level 20
Posts: 11453
Joined: Tue Feb 03, 2009 10:27 am

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by altair4 »

Please don't mount anything under /media/your-user-name and under no circumstances should you ever use the "permissions" option on an NTFS partition if you ever hope to use that partition with WIndows in the future.

Kris345's answer is more mainstream.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
User avatar
AndyMH
Level 21
Level 21
Posts: 13715
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by AndyMH »

br1anstorm wrote: Sat Jul 24, 2021 6:26 pm There are forum members more expert than me who I'm sure will chip in to offer advice - notably AndyMH, who is exceptionally helpful. In fact you might like to look at this thread https://forums.linuxmint.com/viewtopic ... 0&t=352588 for ideas and options. I too was looking at ways of auto-mounting an internal SSD on which at least one partition is to be formatted NTFS.

The wise advice is not to use Disks, but rather use terminal commands to sort out "ownership" of the drive or partition as required (in order to permit read/write), decide on a mount point, then edit fstab to enable auto-mounting.
You've done my work for me :D. You can use disks, I just don't like it and I wouldn't use it to automount partitions - it makes messy entries in fstab.

The fstab equivalent of:

Code: Select all

sudo mount -t ntfs-3g -o defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000 /dev/sdb1 /mnt/Server
would be:

Code: Select all

UUID=xxxx	/mnt/Server	ntfs	defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000	0	2
replace xxxx with the UUID for sdb1 - you find it with blkid. You don't need ntfs-3g, ntfs is an alias for it. You also don't need all those options, I normally just use defaults,uid=1000,gid=1000. windows_names can be a useful option - it stops linux saving files with characters in filenames that are invalid in windows but okay in linux. I don't bother.

You can use /dev/sdb1 instead of the UUID, but the UUID is preferable (what happens if you boot and sdb has become sdc? Device allocation is not fixed in linux).
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1372
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by ricardogroetaers »

ppp7032 wrote: Thu Jul 22, 2021 8:19 am I'm trying to set up automatic mounting of an MBR NTFS internal hard drive partition with read/write access to the non-root user.
Please post the exit from the commands:
id
lsblk -fi
sudo parted -l
cat /etc/fstab

Tell me:
- Which ntfs partition you want to ride.
- The name you would like for the assembly point, for example, Server, Cat, dog, data, .....
lucassilver420
Level 1
Level 1
Posts: 7
Joined: Wed May 26, 2021 5:08 pm

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by lucassilver420 »

Can I post here with similar problem instead of making a new thread?

I used to have my NTFS drive mounted by clicking on it in file browser, it just worked and I was able to read and write to it. Then I leaned more and edited the fstab file to auto mount the drive to a different location than /media. That worked well as well, I was able to read and write on it. This is the fstab entry I added.

Code: Select all

UUID=4CFEE673FEE654AC /data  auto nouid,nodev,nofail,x-gvfs-show 0 0
It worked fine until today, after booting and trying to install a steam game(it runs off the NTFS drive) I got a write error. I digged a little bit and then checked properties for the drive, clicked permissions tab and it says: Owner root, Group root, Folder access root. File acess just shows "---".

I tried this in fstab

Code: Select all

UUID=4CFEE673FEE654AC	/data	ntfs	defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000	0	2
Now under drive properties and permissions tab it displays my user name as owner, group and Folder access but file access still shows "---". I still can read the files and folders but can't create or delete files.

I hashed out the entries from fstab and let the system mount the drive after booting after clicking the drive icon. It does that with ownership under my username but Folder and file access still show "---" and I cannot write or delete files on this drive.

I'm not sure what way to look at.
Last edited by lucassilver420 on Sat Aug 07, 2021 11:50 am, edited 1 time in total.
User avatar
AndyMH
Level 21
Level 21
Posts: 13715
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by AndyMH »

lucassilver420 wrote: Sat Aug 07, 2021 11:27 am I'm not sure what way to look at.
You need the options for uid=1000,gid=1000 in the fstab entry for write access. I would also add ntfs into the fstab entry as per my previous. Linux will guess at the filesystem type, but no guarantees...

Linux 'fakes' the permissions for ntfs partitions and uid & gid tell the system the user and group that own the partition. 1000 is the first user created by mint, the next would be 1001. You can replace uid=1000 with uid=fred if that is your username.

EDIT - mounting under /data - did you create the folder and assign ownership to you. You might be better with /home/you/data.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
lucassilver420
Level 1
Level 1
Posts: 7
Joined: Wed May 26, 2021 5:08 pm

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by lucassilver420 »

AndyMH wrote: Sat Aug 07, 2021 11:45 am
lucassilver420 wrote: Sat Aug 07, 2021 11:27 am I'm not sure what way to look at.
You need the options for uid=1000,gid=1000 in the fstab entry for write access. I would also add ntfs into the fstab entry as per my previous. Linux will guess at the filesystem type, but no guarantees...

Linux 'fakes' the permissions for ntfs partitions and uid & gid tell the system the user and group that own the partition. 1000 is the first user created by mint, the next would be 1001. You can replace uid=1000 with uid=fred if that is your username.

EDIT - mounting under /data - did you create the folder and assign ownership to you. You might be better with /home/you/data.

Thanks, check my stealth update. The data folder was created automatically I think after editing fstab for the first time.

Edit:

Ok I tried to create a folder for the drive but I cannot create any. Also you were right the data folder is under root ownership. Seems like the whole filesystem is under root ownership now, I can't create any files or folders on my main drive/filesystem. Could that have something to do with recent updates? I do have timeshift.
User avatar
AndyMH
Level 21
Level 21
Posts: 13715
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by AndyMH »

Except for /home/you (and I think maybe /media/you) everything else is owned by root and you have to be root to create/delete files or folders. To create folders as root - just right click on the folder above and 'open as root' in your file manager.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
lucassilver420
Level 1
Level 1
Posts: 7
Joined: Wed May 26, 2021 5:08 pm

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by lucassilver420 »

AndyMH wrote: Sat Aug 07, 2021 12:00 pm Except for /home/you (and I think maybe /media/you) everything else is owned by root and you have to be root to create/delete files or folders. To create folders as root - just right click on the folder above and 'open as root' in your file manager.
Makes sense.

I tried this in fstab

Code: Select all

UUID=4CFEE673FEE654AC	/data	ntfs	defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000	0	2
Now under drive properties and permissions tab it displays my user name as owner, group and Folder access but file access still shows "---". I still can read the files and folders but can't create or delete files.
User avatar
AndyMH
Level 21
Level 21
Posts: 13715
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by AndyMH »

Assuming you are dual booting with win have you turned of fast boot in win? With it on win never really shuts down and locks the filesystems = read only to linux.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
lucassilver420
Level 1
Level 1
Posts: 7
Joined: Wed May 26, 2021 5:08 pm

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by lucassilver420 »

AndyMH wrote: Sat Aug 07, 2021 6:19 pm Assuming you are dual booting with win have you turned of fast boot in win? With it on win never really shuts down and locks the filesystems = read only to linux.
Holy Jesus, that's it! I should've stated I use dual boot. I was going crazy trying to fix something that didn't need fixing for hours yesterday. Thank you so much my friend :D
ppp7032
Level 1
Level 1
Posts: 3
Joined: Thu Jul 22, 2021 8:05 am

Re: Possible solutions to automatically mounting NTFS drive with read/write access?

Post by ppp7032 »

AndyMH wrote: Thu Aug 05, 2021 6:21 pm
br1anstorm wrote: Sat Jul 24, 2021 6:26 pm There are forum members more expert than me who I'm sure will chip in to offer advice - notably AndyMH, who is exceptionally helpful. In fact you might like to look at this thread https://forums.linuxmint.com/viewtopic ... 0&t=352588 for ideas and options. I too was looking at ways of auto-mounting an internal SSD on which at least one partition is to be formatted NTFS.

The wise advice is not to use Disks, but rather use terminal commands to sort out "ownership" of the drive or partition as required (in order to permit read/write), decide on a mount point, then edit fstab to enable auto-mounting.
You've done my work for me :D. You can use disks, I just don't like it and I wouldn't use it to automount partitions - it makes messy entries in fstab.

The fstab equivalent of:

Code: Select all

sudo mount -t ntfs-3g -o defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000 /dev/sdb1 /mnt/Server
would be:

Code: Select all

UUID=xxxx	/mnt/Server	ntfs	defaults,noatime,utf8,dmask=002,fmask=111,uid=1000,gid=1000	0	2
replace xxxx with the UUID for sdb1 - you find it with blkid. You don't need ntfs-3g, ntfs is an alias for it. You also don't need all those options, I normally just use defaults,uid=1000,gid=1000. windows_names can be a useful option - it stops linux saving files with characters in filenames that are invalid in windows but okay in linux. I don't bother.

You can use /dev/sdb1 instead of the UUID, but the UUID is preferable (what happens if you boot and sdb has become sdc? Device allocation is not fixed in linux).
So I basically forgot about this until today as I had a hacky workaround and was content. It's about time this saga came to an end.

Today I upgraded the system to Linux Mint 22 and Linux kernel version 5.15 (which includes a new built-in NTFS driver) while working on this system. I then tried your solution as it seemed to make the most sense in this thread and it worked completely as intended. I can't remember if I tried your solution a year ago or not so I technically cannot be sure whether the issue was solved by your solution or the new Linux kernel. However, I'd lean towards the former. Thank you for your help and my apologies for the late response/implementation.
Locked

Return to “Storage”