Forums » Tutorial and setups »
Saving recordings to NAS remote drive - permission denied - NFS
Added by Left Nothing about 4 years ago
Hi,
After spending hours trying to get this to work, doing lots of googling, I'm stuck... I've just installed tvheadend onto a Pi3 (which is running HOOBS), I'd like to set the recording system path to a NFS share on my NAS drive, however trying to configure it is proving a challenge - Here's what I've done with results & error:
Setup NFS share on my NAS (192.168.1.1) for remote storage
nano /etc/exports
I added following line:
/shares/recordings 192.168.1.0/24(rw,no_subtree_check)
After saving the file, I ran:
exportfs -a /etc/init.d/nfs-kernel-server restart
On my Pi3 192.168.1.2 running tvheadend
nano /etc/fstab
I added the following line
192.168.1.1:/shares/recordings /mnt/recordings nfs noauto,x-systemd.automount 0 0
After saving I ran:
sudo mount -a sudo systemctl daemon-reload sudo systemctl restart remote-fs.target
If I then type ls /mnt/recordings I can see the contents of the NAS drive as expected when logged in as HOOBS user. However, if I change the recording system path in tvheadend, when trying to record it just ends saying failed to create file. Investigating the permissions, on the Pi3 whilst logged in as HOOBS I type sudo su hts and then ls /mnt/recordings I get an error as follows:
ls: cannot open directory '/mnt/recordings': Permission denied
If I type ls -l -d /mnt/recordings I get
drwxrwxrwx 3 root hoobs 65536 Sep 8 19:50 /mnt/recordings
I read the last 'rwx' indicates I should have permission so I'm now confused and don't understand why the hts user is not able to view the contents? What am I missing / doing wrong? HOOBS user can view the contents but hts user (used by tvheadend) can't. I've tried adding hts to the hoobs group which didn't make any difference. Any help very much appreciated!!! :-)
Replies (5)
RE: Saving recordings to NAS remote drive - permission denied - NFS - Added by Dave Pickles about 4 years ago
I'm not an expert on NFS but I'll try to help.
I suspect the problem is with permissions on the server end. When a client requests a file using NFS, it passes the UID and GID of the local user across to the server, and these are checked against the UID and GID of the file being requested. You will need to allow read/write access to /shares/recordings by the UID of the hts user on your client; one way would be to add a user hts on the server making sure the UID is the same as on the client.
RE: Saving recordings to NAS remote drive - permission denied - NFS - Added by Dave H about 4 years ago
Is this NFS3 or NFS4?
Like Dave says, it looks like a permissions problem and as he says with NFS its the underlying UID and GID that matter. So try using ls -n instead of ls -l.
I would do an ls -an of the directory on the NAS and of the mounted directory on the pi. Then let's look at that.
RE: Saving recordings to NAS remote drive - permission denied - NFS - Added by Left Nothing about 4 years ago
I tried to make changes to folder permissions on the NAS with;
sudo chown -R nobody:hts /shares/recordings/
But that didn't help, so as a temporary "fix" I changed the GID/UID to 0 in /etc/passwd for hts user on the pi3 (to give root permission), which "fixed" the issue but is not something I want to leave in place, so, here's the output from ls -an on both devices:
Output from ls -an /shares On NAS
drwxr-xr-x 6 99 65534 65536 Sep 12 19:27 recordings
Output from ls -an /mnt on pi
drwxr-xr-x 6 99 65534 65536 Sep 12 19:27 recordings
Not sure how to tell if it's NFS 3 or 4 or what command I'd use to make a user with the same UID? - I'm a still bit of a novice in Linux!
RE: Saving recordings to NAS remote drive - permission denied - NFS - Added by Dave H about 4 years ago
"Output from ls -an /shares On NAS"
No, that isn't the full output! It's normal to list the command that you used, together with the output. Like this example:
# ls -an /opt
total 0
drwxr-xr-x 1 0 0 62 Sep 14 10:54 .
drwxr-xr-x 1 0 0 184 Apr 21 2019 ..
drwxr-xr-x 1 0 0 0 Feb 17 2018 bin
drwxr-xr-x 1 0 0 600 Sep 14 10:54 calibre
and I actually wanted you to run
# ls -an /shares/recordings
and
$ sudo ls -an /mnt/recordings
though I don't really care about more than the first one or two actual recodings.
There are many ways to check the version. Try, on the pi:
$ sudo grep nfs /proc/mounts
FWIW, on my machine the hts user UID is 470 and its GID is video (33). The video GID I think is important to allow me to actually play the videos. Certainly having 'nobody' as the owner of the files or directory doesn't sound right.
You can use the 'usermod' command to change the UID and/or GID. You'll need to manually change the ownership of any files outside the user's home directory.
RE: Saving recordings to NAS remote drive - permission denied - NFS - Added by Left Nothing about 4 years ago
Sorry, I was trying to be concise, here's the full output from pi3
$ sudo ls -an /mnt/recordings total 930372 drwxr-xr-x 6 99 65534 65536 Sep 12 19:27 . drwxr-xr-x 5 0 0 4096 Sep 9 22:09 .. drwxr-xr-x 2 99 65534 65536 Sep 8 10:24 .AppleDouble drwxrwxr-x 2 65534 44 65536 Sep 10 19:57 'BBC ONE HD' drwxrwxr-x 2 65534 44 65536 Sep 13 18:27 'Channel 4 HD' -rwxr-xr-x 1 99 65534 4096 Sep 8 06:04 ._.DS_Store -rwxr-xr-x 1 99 65534 6148 Sep 9 02:35 .DS_Store drwxrwxr-x 2 65534 44 65536 Sep 12 19:56 'ITV HD' -rw-rw-r-- 1 65534 44 951938564 Sep 10 18:00 Pointless.ts -rwxr-xr-x 1 99 65534 11 Sep 8 08:14 test2.txt -rwxr-xr-x 1 99 65534 13 Sep 8 10:53 test4.txt -rwxr-xr-x 1 99 65534 21 Sep 8 08:00 test.txt
sudo grep nfs /proc/mounts 192.168.1.1:/shares/recordings /mnt/recordings nfs rw,noatime,vers=3,rsize=32768,wsize=32768,namlen=255,soft,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.1.1,mountvers=3,mountport=58710,mountproto=udp,local_lock=none,addr=192.168.1.1 0 0
And here's the output from the NAS
# ls -an /shares/recordings total 930432 drwxr-xr-x 6 99 65534 65536 Sep 12 19:27 . drwxrwxr-x 16 0 1000 65536 Sep 8 05:21 .. drwxr-xr-x 2 99 65534 65536 Sep 8 10:24 .AppleDouble -rwxr-xr-x 1 99 65534 6148 Sep 9 02:35 .DS_Store -rwxr-xr-x 1 99 65534 4096 Sep 8 06:04 ._.DS_Store drwxrwxr-x 2 65534 44 65536 Sep 10 19:57 BBC ONE HD drwxrwxr-x 2 65534 44 65536 Sep 13 18:27 Channel 4 HD drwxrwxr-x 2 65534 44 65536 Sep 12 19:56 ITV HD -rw-rw-r-- 1 65534 44 951938564 Sep 10 18:00 Pointless.ts -rwxr-xr-x 1 99 65534 21 Sep 8 08:00 test.txt -rwxr-xr-x 1 99 65534 11 Sep 8 08:14 test2.txt -rwxr-xr-x 1 99 65534 13 Sep 8 10:53 test4.txt
sudo grep nfs /proc/mounts /dev/sda4 /nfs ext4 rw,noatime,nodiratime,barrier=1,data=ordered 0 0 rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0 nfsd /proc/fs/nfsd nfsd rw,relatime 0 0
I read a page somewhere which suggested setting the owner as 'nobody' to prevent issues with NFS and permissions so thought it worth a try on the NAS :), there's
not currently a 'hts' user on the NAS, only the pi.