Difference between revisions of "Setting up NFS for file sharing"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
Line 7: Line 7:


<br>
<br>
{{!}}-
{{!}} style="text-align: center; width: 60px;" colspan="3" {{!}} [[File:Logo Debian.png{{!}}60px{{!}}link=https://www.debian.org/{{!}}center{{!}}middle{{!}}frameless]]<br><br>
{{!}}}
{{!}}}


==Install NFS Server==
== Install NFS Server ==


* <code>sudo apt install nfs-kernel-server</code>
* <code>sudo apt install nfs-kernel-server</code>
Line 32: Line 34:


* <code>sudo vi /etc/init.d/nfs-kernel-server</code>
* <code>sudo vi /etc/init.d/nfs-kernel-server</code>
and add:
and add:  
  ##########################
  ##########################
  echo "Starting out by making sure EVERYTHING is mounted..."
  echo "Starting out by making sure EVERYTHING is mounted..."
Line 46: Line 47:


  '''/path/to/be/shared''' *(rw,async,no_root_squash,no_subtree_check''',fsid=1010''')
  '''/path/to/be/shared''' *(rw,async,no_root_squash,no_subtree_check''',fsid=1010''')
<span style="color: rgb(186, 55, 42); font-size: 14pt;" >'''AND''' it '''STILL''' doesn't start at boot!!!</span>
 
<span style="color: rgb(186, 55, 42); font-size: 14pt;">'''AND''' it '''STILL''' doesn't start at boot!!!</span>


But, you can force it to start after booting by logging into the machine & telling it:
But, you can force it to start after booting by logging into the machine & telling it:
Line 52: Line 54:
* <code>sudo /etc/init.d/nfs-kernel-server start</code>
* <code>sudo /etc/init.d/nfs-kernel-server start</code>


==Connecting to the NFS Server==
== Connecting to the NFS Server ==
You'll need NFS installed
You'll need NFS installed
* <code>sudo apt install nfs-common</code>
* <code>sudo apt install nfs-common</code>
or
or
* <code>sudo apt install nfs-kernel-server</code>
* <code>sudo apt install nfs-kernel-server</code>
Then you can check what's shared from any particular machine:
Then you can check what's shared from any particular machine:
* <code>showmount -e '''[ServerName or Address]'''</code>
* <code>showmount -e '''[ServerName or Address]'''</code>
** (requires sudo on Debian...)
** (requires sudo on Debian...)
will show you what's shared from a machine
will show you what's shared from a machine


===Setting up & mounting a share===
=== Setting up & mounting a share ===
(A note for dopey people, don't cut and paste add your own network path - Dodgy)
(A note for dopey people, don't cut and paste add your own network path - Dodgy)


Line 77: Line 76:
* <code>sudo mount -a</code>
* <code>sudo mount -a</code>


==TBD==
== TBD ==


* Learn what flags do what in '''/etc/exports'''  
* Learn what flags do what in '''/etc/exports'''
* Browsing in the GUI would be nice...  
* Browsing in the GUI would be nice...
* Look into automounting (including graceful failure modes)  
* Look into automounting (including graceful failure modes)


== Some Links ==
== Some Links ==

Revision as of 12:47, 19 October 2022

Proven on:
Logo Debian.png
11 (bullseye)


Logo Debian.png


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

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

Setting up & mounting a share

(A note for dopey people, don't cut and paste add your own network path - Dodgy)

  • 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

TBD

  • Learn what flags do what in /etc/exports
  • Browsing in the GUI would be nice...
  • Look into automounting (including graceful failure modes)

Some Links