Montage NFS
Serveur
sudo apt-get install nfs-kernel-server -y
sudo find /media/Disk1/ -type d -exec chmod 755 {} \;
sudo find /media/Disk1/ -type f -exec chmod 644 {} \;
sudo vi /etc/exports
/mnt/nfsshare *(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1000)
This application updates the current table of exports available to the NFS server.
sudo exportfs -ra
Client
sudo apt-get install nfs-common
sudo systemctl start rpcbind
sudo systemctl status rpcbind
sudo systemctl start nfs-common
sudo systemctl status nfs-common
$ sudo systemctl enable nfs-common
Synchronizing state of nfs-common.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nfs-common
Failed to enable unit: Unit file /lib/systemd/system/nfs-common.service is masked.
It appears that the unit file has a symbolic link to /dev/null:
$ file /lib/systemd/system/nfs-common.service
/lib/systemd/system/nfs-common.service: symbolic link to /dev/null
I was able to unmask the service by removing the file:
$ sudo rm /lib/systemd/system/nfs-common.service
Then reloading the daemon:
$ sudo systemctl daemon-reload
As we can see the nfs-common
service is not running:
$ sudo systemctl status nfs-common
● nfs-common.service - LSB: NFS support files common to client and server
Loaded: loaded (/etc/init.d/nfs-common; generated; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
Let’s go ahead and start the service:
$ sudo systemctl start nfs-common
$ sudo systemctl status nfs-common
● nfs-common.service - LSB: NFS support files common to client and server
Loaded: loaded (/etc/init.d/nfs-common; generated; vendor preset: enabled)
Active: active (running) since Sat 2017-12-09 08:59:47 SAST; 2s ago
Docs: man:systemd-sysv-generator(8)
Process: 7382 ExecStart=/etc/init.d/nfs-common start (code=exited, status=0/SUCCESS)
CPU: 162ms
CGroup: /system.slice/nfs-common.service
└─7403 /usr/sbin/rpc.idmapd
sudo mount -t nfs 192.168.1.250:/media/Disk1/ /mnt/nas
sudo apt-get install autofs
sudo vi /etc/auto.master
/mnt /etc/mycloud.nfs uid=501,gid=1000 --timeout=6000 --ghost
sudo sudo vi /etc/mycloud.nfs
nas -fstype=nfs,rw,hard,nolock,noauto,x-systemd.automount 192.168.1.250:/media/Disk1
sudo systemctl restart autofs.service