Transferring files over LAN
Problem
I host my NC instance through cloudflare tunnel. However, if I want to transfer something through my LAN instead of over the internet, nextcloud does not have a native solution for that.
Solution
Here is my thought process:
- Since my nextcloud data drive is just an NFS share from TrueNAS Core, I should be able to mount it on my PC and transfer files that way
- After that, the file should magically appear in my nextcloud instance… right?
Problem 1: Mounting NFS share on Windows
Since my files are on my Windows PC, I cannot mount NFS share directly like I can with SMB. Of course, the logical solution would be to use WSL2.
To even mount NFS shares, there are several steps to be performed:
- Download
nfs-common
(Reference: https://www.truenas.com/docs/scale/23.10/scaletutorials/shares/addingnfsshares/#connecting-to-the-nfs-share)1
sudo apt install nfs-common
- If you try to mount the share now, there would likely be this error:
1 2
mount.nfs: rpc.statd is not running but is required for remote locking. mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
- If you try to mount the share now, there would likely be this error:
- Run the following commands
1 2
sudo /etc/init.d/rpcbind start sudo /etc/init.d/nfs-common start
- After which, trying to mount again would give a permission error
1
mount.nfs: access denied by server while mounting ...
- After which, trying to mount again would give a permission error
- On TrueNAS, Click Services –> NFS (pencil icon) –> Allow non-root mount
- You should now be able to mount the nextcloud data drive
Problem 2: Making files appear in the nextcloud instance
After mounting the NFS share and transferring whatever file you wanted, you would expect the file to appear on nextcloud itself. However, that’s not the case. There are extra steps to perform.
-
Ensure nextcloud has the permissions to read your file. Using
ls -la
, check on the other nextcloud files to identify the owner. If you are like me and using the nextcloud AIO docker image, the owner is likely the userwww-data
- Change owner using the
chown
command1
chown -R www-data /folder/to/change
-
Using
docker ps
, identity the container running nextcloud. Similarly, if you are using the nextcloud AIO docker image, the container running nextcloud is named:nextcloud-aio-nextcloud
- Using
docker exec
, enter into the container’s shell1
docker exec -it nextcloud-aio-nextcloud /bin/bash
- Run the following command to rescan all files
1
sudo -u www-data -E php occ files:scan --all
The file will now appear in your nextcloud instance!
Cleanup
For security purposes, you might want to deactivate the “Allow non-root mount” option from Problem 1: Mounting NFS share on Windows.