Difference between revisions of "Setting up NFS for file sharing"
Line 79: | Line 79: | ||
*<code>Enable-WindowsOptionalFeature -FeatureName ServicesForNFS-ClientOnly, ClientForNFS-Infrastructure -Online -NoRestart</code> | *<code>Enable-WindowsOptionalFeature -FeatureName ServicesForNFS-ClientOnly, ClientForNFS-Infrastructure -Online -NoRestart</code> | ||
Set up anonymous credentials to match the credentials of a user with full access to the NFS share from a Linux viewpoint... | Set up anonymous credentials to match the credentials of a user with full access to the NFS share from a Linux viewpoint... | ||
*<code>New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousUID -Value 1000 -PropertyType "DWord"</code> | *<code>New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousUID -Value 1000 -PropertyType "DWord"</code> | ||
*<code>New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousGID -Value 1000 -PropertyType "DWord"</code> | *<code>New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousGID -Value 1000 -PropertyType "DWord"</code> | ||
(The "AnonymousUID" & "AnonymousGID" "Value"s are the UID & GID of a user on the server with appropriate permissions...) | |||
Reboot the computer | Reboot the computer | ||
===== In a regular command shell: ===== | ===== In a regular command shell: ===== | ||
Mount the drive(s) | Mount the drive(s) |
Revision as of 17:46, 13 January 2023
11 (bullseye) | (This includes LMDE5, Proxmox, OMV...) | |
A little note about typographic conventions you'll see here |
Install NFS Server
sudo apt install nfs-kernel-server
Configure NFS Server
sudo vi /etc/exports
Add/edit:
/PATH/TO/BE/SHARED *(rw,async,no_root_squash,no_subtree_check)
For the changes to take effect, export and start NFS service.
sudo exportfs -a
sudo /etc/init.d/nfs-kernel-server start
Pretty simple...
A bit about re-sharing
Sometimes, you may want to share something that you've actually mounted from an NFS share on another machine...
A couple of things are different in this case.
First, you need to ensure that the mounts are done BEFORE you start the NFS server.
sudo vi /etc/init.d/nfs-kernel-server
and add:
########################## echo "Starting out by making sure EVERYTHING is mounted..." /usr/bin/mount -a echo "Really..." echo "This is NOT the right place to do this..." echo "But, init.d kinda sucks..." ##########################
right near the start.
Then you need to provide an fsid entry (with a unique number) for each export.
/PATH/TO/BE/SHARED *(rw,async,no_root_squash,no_subtree_check,fsid=1010)
AND it STILL doesn't start at boot!!!
But, you can force it to start after booting by logging into the machine & telling it:
sudo /etc/init.d/nfs-kernel-server start
Connecting to the NFS Server
From Linux
You'll need NFS installed
sudo apt install nfs-common
or
sudo apt install nfs-kernel-server
Then you can check what's shared from any particular machine:
showmount -e [SERVERNAME or ADDRESS]
- (requires sudo on Debian...)
will show you what's shared from a machine
sudo mkdir -p /PATH/TO/MOUNT/SHARE
sudo mount [SERVERNAME or ADDRESS]:/PATH/TO/BE/SHARED /PATH/TO/MOUNT/SHARE
Better yet tho...
sudo vi /etc/fstab
& add an entry:
[SERVERNAME or ADDRESS]:/PATH/TO/BE/SHARED /PATH/TO/MOUNT/SHARE nfs rw,user,exec 0 0
Then, you can mount anything listed in fstab but not yet mounted
sudo mount -a
From Windows (Win10)
(Tentative Working Notes)
In an Admin Powershell window:
Turn on NFS
Enable-WindowsOptionalFeature -FeatureName ServicesForNFS-ClientOnly, ClientForNFS-Infrastructure -Online -NoRestart
Set up anonymous credentials to match the credentials of a user with full access to the NFS share from a Linux viewpoint...
New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousUID -Value 1000 -PropertyType "DWord"
New-ItemProperty HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default -Name AnonymousGID -Value 1000 -PropertyType "DWord"
(The "AnonymousUID" & "AnonymousGID" "Value"s are the UID & GID of a user on the server with appropriate permissions...)
Reboot the computer
In a regular command shell:
Mount the drive(s)
mount -o nolock \\TinkerData.tinkernet.ca\home\tinker\Documents D:
mount -o nolock \\Warehouse.tinkernet.ca\mnt\Space_1\Pix P:
EVERY TIME the machine is rebooted, mount the drives... Again...
TBD
- Learn what flags do what in /etc/exports
- Browsing in the GUI would be nice...
- Look into automounting (including graceful failure modes)
- Work up some instructions for other non-Linux systems. (Synology, Kodi, Mac)