Digital Marketing

Mount an NFS Volume in Linux

# mount -t nfs nfs_volume local_dir options
or
# mount.nfs nfs_volume local_dir options

for example:

mount -t nfs 192.168.1.100:/backup /mnt/db2

If you have problem, you might need to mount nfs4 instead.

mount -t nfs4 192.168.1.100:/backup /mnt/db2

If permission denied, edit the /etc/exports file, for example

/opt/docroot/     192.168.1.0/16(rw,sync,no_root_squash)

192.168.1.0/16 ⇒ range of networks NFS permits accesses
rw ⇒ writable
sync ⇒ synchronize
no_root_squash ⇒ enable root privilege
no_all_squash ⇒ enable users' authority

$ sudo systemctl restart  nfs.service
( OR $ service nfs restart )

If you get the following error:

mount.nfs: No such device

Try adding the option:  -o nolock

# mount -t nfs4 nfs_volume local_dir options  -o nolock

You can put it in /etc/fstab for auto mount when server restart:

Example:

192.168.0.40:/opt/docroot/ /var/www/html/  nfs  defaults        0 0

Mount it without restarting server by running:

$ sudo mount -a

See also:

How to fix: mount: wrong fs type, bad option, bad superblock


Also pay attention to your firewall setting.

$ sudo -i firewall-cmd --add-service=nfs --permanent
success
$ sudo -i firewall-cmd --reload
success

See also:

How to configure firewall on CentOS /Oracle Linux/ Red Hat 7


How to fix: NFS: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)


To test you can successfully connect to the NFS server:

$ telnet 192.168.1.100 nfs
Trying 192.168.1.100...
Connected to 192.168.1.100.
Escape character is '^]'.

Connection closed by foreign host.

$ telnet 192.168.1.100 2049
Trying 192.168.1.100...
Connected to 192.168.1.100.

Escape character is '^]'.




Comments

Popular posts from this blog

MySQL Sandbox with the Sakila sample database