Score:0

How do I give network share users permissions to access mounted NTFS drives?

dk flag

I have a machine I've just set up running Ubuntu 22.04.2, and have 3 NTFS hard drives mounted in the filesystem. I'm running a Plex server on the machine so have run into issues already with NTFS drives, which apparently screw with the permissions system. The only way I was able to successfully give Plex access to my drives was to add the plex user to plugdev (which doesn't seem adviseable) but now I am having the same issue with a network share. Ideally I want to have all my drives available on the network, but since adding them as network shares seems to not work, they are under a parent folder which I have turned into a network share. I can access the parent folder from my Windows PC but don't have appropriate permissions to access any of the mounted drives. I've looked around for solutions but there aren't many and I haven't found any that work, so learning from the Plex issue I tried creating a samba user, adding them to plugdev and then logging in with their credentials on the Windows machine but that failed as well.

I'm pretty new to Linux and my choice of sticking with my NTFS drives seems to keep biting me in the ass, but I have 10tb of stuff that I don't want to have to move off and then back onto them after reformatting, so I'm hoping there's a way fix these permission issues.

Edit: testparm -s gives:

Loaded services file OK.
Weak crypto is allowed

Server role: ROLE_STANDALONE

# Global parameters
[global]
    log file = /var/log/samba/log.%m
    logging = file
    map to guest = Bad User
    max log size = 1000
    obey pam restrictions = Yes
    pam password change = Yes
    panic action = /usr/share/samba/panic-action %d
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    passwd program = /usr/bin/passwd %u
    server role = standalone server
    server string = %h server (Samba, Ubuntu)
    unix password sync = Yes
    usershare allow guests = Yes
    idmap config * : backend = tdb


[printers]
    browseable = No
    comment = All Printers
    create mask = 0700
    path = /var/spool/samba
    printable = Yes


[print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers

net usershare info --long gives:

path=/media/maddie
comment=
usershare_acl=Everyone:F,
guest_ok=y

[test]
path=/media/maddie
comment=
usershare_acl=Everyone:F,
guest_ok=n

info_fn: file /var/lib/samba/usershares/media tres is not a well formed usershare file.
info_fn: Error was Path is not a directory.
info_fn: file /var/lib/samba/usershares/media uno is not a well formed usershare file.
info_fn: Error was Path is not a directory.
[Cathleen]
path=/media/maddie
comment=
usershare_acl=Everyone:F,
guest_ok=y

info_fn: file /var/lib/samba/usershares/media dos is not a well formed usershare file.
info_fn: Error was Path is not a directory.

Also in case it helps clear up exactly what the situation with my disks is here's /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name         devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdb4 during installation
UUID=bf960de8-2057-4851-bc1e-0f9d5909495e /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sdb5 during installation
#UUID=EC82-3A04  /boot/efi       vfat    umask=0077      0       1
# /media/media-dos was on /dev/sda2 during installation
# /media/media-tres was on /dev/sdb2 during installation
# /media/media-uno was on /dev/sdd2 during installation
UUID=4E3ECAE03ECABFE7 /media/maddie/media-dos ntfs defaults,umask=007,gid=46,nosuid,nodev,nofail 0 1
UUID=EA5C0C235C0BE961 /media/maddie/media-tres ntfs defaults,umask=007,gid=46,nosuid,nodev,nofail 0 1
UUID=98082E22082E003C /media/maddie/media-uno ntfs defaults,umask=007,gid=46,nosuid,nodev,nofail 0 1
Morbius1 avatar
es flag
The amount of information needed to answer the question is too long to list in a comment. Please edit your question and add the output of the following commands: `testparm -s` `net usershare info --long` `cat /etc/fstab`
rustol avatar
dk flag
done. let me know what else I can add
Morbius1 avatar
es flag
You ran 3 separate command sequences together on one line for some reason so let's do this again. What is the output of this command: `testparm -s`
Morbius1 avatar
es flag
And what is the output of this command: `net usershare info --long`
rustol avatar
dk flag
Done. Sorry, I completely missed the spaces there
Score:1
es flag

I don't think you are going to like my answer because my recommendation is to go in an entirely different direction.

[1] Stop using the file manager to create samba shares.

I would go to /var/lib/samba/usershares and delete all the files you have there. Each file is a share definition and although that will remove all your samba shares it will not impact anything else on your system.

[2] Then I would create a parent folder for these NTFS partitions that is NOT /media/maddie.

That folder has special permissions on it that allows only maddie access to what is under it.

Instead I would create something like /media/Storage:

sudo mkdir /media/Storage

Then I ( as in maddie ) would take possession of that folder:

sudo chown maddie /media/Storage

[2a] Missed a step. Create the mount point for each of the ntfs partitions. For example:

sudo mkdir /media/Storage/media-uno

[3] Then in fstab I would have these NTFS partitions mount under /media/Storage with maddie as owner.

For example:

Unmount media-uno:

sudo umount /media/maddie/media-uno

Change your fstab declaration from this:

UUID=98082E22082E003C /media/maddie/media-uno ntfs defaults,umask=007,gid=46,nosuid,nodev,nofail 0 1

To this:

UUID=98082E22082E003C /media/Storage/media-uno ntfs defaults,umask=007,uid=maddie,gid=46,nofail 0 0

Then remount it with this:

sudo mount -a

Verify you can access that partition locally before moving to the next step.

[4] Create a samba share of the /media/Storage folder directly in /etc/samba/smb.conf

I would recommend creating a guest accessible share first - we can make this more complicated if required. You do that by adding at the end of the smb.conf file the share definition that looks something like this:

[Storage]
path = /media/Storage
read only = No
guest ok = Yes
force user = maddie

Save the file then restart samba:

sudo service smbd restart

Then access the Storage share from your Windows machine. Eventually all these non system ntfs partitions will show up under the Storage share as you modify fstab for the remaining partitions.

rustol avatar
dk flag
Thank you so much, all of this seems to work (I'm happy to be rid of the 'maddie' folder) and although I can't connect on my machine I have verified it works with another PC, so that's now a windows problem I'm more able to figure out.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.