Difference between revisions of "Network File System (NFS)"

From RHS Wiki
Jump to navigation Jump to search
Line 45: Line 45:
  
 
=== NFS Volume At Boot Time ===
 
=== NFS Volume At Boot Time ===
 +
==== via /etc/fstab ====
 
  sudo nano /etc/fstab
 
  sudo nano /etc/fstab
 
/etc/fstab
 
/etc/fstab
Line 52: Line 53:
 
Mount  
 
Mount  
 
  mount -a
 
  mount -a
 +
 +
==== via SystemD ====
 +
sudo apt-get install nfs-client
 +
sudo modprobe nfs
 +
sudo echo NFS | tee -a /etc/modules
 +
 +
sudo nano /etc/systemd/system/mnt-things.mount
 +
content:
 +
<nowiki>[Unit]
 +
Description=Things devices
 +
After=network.target
 +
 +
[Mount]
 +
What=172.16.24.192:/mnt/things
 +
Where=/mnt/things
 +
Type=nfs
 +
Options=_netdev,auto
 +
 +
[Install]
 +
WantedBy=multi-user.target</nowiki>
 +
 +
Start mount service
 +
systemctl daemon-reload
 +
systemctl start mnt-media.mount
 +
systemctl status mnt-things.mount

Revision as of 16:46, 18 October 2018

Debian

Server

Install

sudo apt install nfs-kernel-server nfs-common

Config files:

  • /etc/idmapd.conf
  • /etc/default/nfs-common
  • /etc/exports
  • /etc/default/nfs-kernel-server

Exporting Directories

Create Directories

mkdir /home/client1
chown nobody:nogroup /home/client1
chmod 755 /home/client1
mkdir /var/www
chown root:root /var/www
chmod 755 /var/www 

Add to export

sudo nano /etc/exports

/etc/exports

# Save all files with user:group = nobody:nogroup
/home/client1           192.168.0.0/24 (rw,sync,no_subtree_check)
# Preserve files ownership and permissions (no_root_squash allows root to access folder)
/var/www        192.168.0.101/32 (rw,sync,fsid=0,crossmnt,no_subtree_check,no_root_squash)

Restart the nfs server

/etc/init.d/nfs-kernel-server restart

Client

Install

sudo apt install nfs-common

List available exports on NFS server

sudo showmount -e 192.168.0.103

Mount nfs volume

Create a directory to mount the volume

mkdir -p /mnt/nfs/home/client1
mkdir -p /var/www

Mount NFS Volume

mount 192.168.0.100:/home/client1 /mnt/nfs/home/client1
mount 192.168.0.100:/var/www /var/www

NFS Volume At Boot Time

via /etc/fstab

sudo nano /etc/fstab

/etc/fstab

192.168.0.100:/home/client1  /mnt/nfs/home/client1   nfs      rw,sync,hard,intr  0     0
192.168.0.100:/var/www  /var/www   nfs      rw,sync,hard,intr  0     0

Mount

mount -a

via SystemD

sudo apt-get install nfs-client
sudo modprobe nfs
sudo echo NFS | tee -a /etc/modules
sudo nano /etc/systemd/system/mnt-things.mount

content:

[Unit]
Description=Things devices
After=network.target

[Mount]
What=172.16.24.192:/mnt/things
Where=/mnt/things
Type=nfs
Options=_netdev,auto

[Install]
WantedBy=multi-user.target

Start mount service

systemctl daemon-reload
systemctl start mnt-media.mount
systemctl status mnt-things.mount