1

On Ubuntu 20.04.6 LTS I want to share a USB drive connected to a DD-WRT router using NFS, but I cannot have writing permission for a regular user. The NFS share is indeed setup read/write in the router.

dd-wrt screenshot

I included the following line in /etc/fstab .

192.168.3.1:/mnt/sda4 /home/john/smbnas nfs rw,user,noauto 0 0

...which allows all users to mount the share. Unfortunately I get the following output from ls -l when I mount the folder:

drwxr-xr-x 19 root  root 

....so the folder belongs to root and is not writable by others. I tried the following change in /etc/fstab .

192.168.3.1:/mnt/sda4 /home/john/smbnas nfs rw,user,noauto,uid=1000,gid=1000 0 0

but I get this error:

mount.nfs: an incorrect mount option was specified

I am running Ubuntu 20.04. Changing the mount point to /mnt or /media has no effect. I get the same permissions as before.

What am I doing wrong here? What should I do to get mount and write access for regular users?

karel
  • 122,695
  • 134
  • 305
  • 337
  • 1
    You've provided no Ubuntu product/release details, so we're limited to generic advice that should work on all systems (rather than specific advice for your unstated system). Have you tried mounting it in a different location and not within $HOME (as there are more restrictions there!). Common mount points with fewer restrictions are inside /mnt, /media ... but you don't even need to use the existing directory structure either (though you can run into different permissions issues for 'confined' apps don't forget!) – guiverc Mar 17 '25 at 22:42
  • 1
    Thanks for the feedback. I am running Ubuntu 20.04.6 LTS. Changing the mount point to /mnt or /media has no effect, I get same permissions as before – Alex Malora Mar 18 '25 at 05:55

1 Answers1

0

NFS maps UID/GID's directly, so the local user UID must match the permissions on the remote side.

First, figure out what your users UID is by running id -u; id -g on your machine. This will give you two numbers - UID and GID

Second, connect to the DD-WRT system via e.g. SSH, and log in as root. Run chown UID:GID /mnt/sda4/ to change owner of the shared directory to your user. UID:GID is the two numbers you got when running id.

vidarlo
  • 23,571
  • Thanks for the hint. I don't really like the idea of chown in the dd-wrt box, which I prefer to play with the less possible. I solved my problem by dropping NFS and switching to sshfs. After setting up the dd-wrt box for that, I can mount the share with sshfs root@192.168.3.1:/tmp/mnt/sda4 /home/franco/nas and get read/write permission for the regular user – Alex Malora Mar 20 '25 at 19:40
  • SSHFS has severe drawbacks, especially on a low powered router. I doubt the CPU can handle network speed encryption. In addition, SSHing to the root user is a rather large security vulnerability. Strictly speaking you're not chowning anything on the dd-wrt box, but rather the storage. The ownership is stored in the filesystem, not in the operating system. – vidarlo Mar 20 '25 at 19:54