Cheap VPS host selection
Provide server host evaluation information

How to mount nfs under linux (tutorial method for mounting nfs under linux)

NFS is one of the file systems supported by FreeBSD. It allows computers in the network to share resources through TCP/IP networks. This article will explain in detail the specific methods of attaching NFS shares under Linux. To mount an NFS share on a Linux system, first install the NFS client package. Package names vary between Linux distributions.

To install NFS clients on Ubuntu and Debian:

sudo apt update
sudo apt install nfs-common

In CentOS and RedHat:

sudo yum install nfs-utils

Manually mount NFS file system

Mounting a remote NFS share is the same as mounting a regular file system.

To mount the NFS file system on a given mount point, use the mount command in the following format:

mount [OPTION…] NFS_SERVER:EXPORTED_DIRECTORY MOUNT_POINT

Use the following steps to manually install a remote NFS share on a Linux system:

First, create a directory as the mount point for the remote NFS share:

sudo mkdir /var/backups

The mount point is the directory on the local computer where NFS shares are to be mounted.

Mount the NFS share sudo privilege by running the following command as root or user:

sudo mount -t nfs 10.10.0.10:/backups /var/backups

Where 10.10.0.10 is the IP address of the NFS server,/backup is the export of the directory where the server is located, and/var/backups is the local installation point.

On success, no output is generated.

If you want to specify other mount options, use the - o option. Multiple options can be provided as comma separated lists. To get a list of all installation options, enter man mount in the terminal.

To verify that the remote NFS volume was successfully mounted, use the mount or df - h] command.

Once the share is installed, the mount point becomes the root directory of the installed file system.

When you manually install a share, NFS share installation will not continue after a reboot.
Using/etc/fstab

Auto mount NFS file system

Typically, you need to automatically mount remote NFS directories when the system starts.

/The/etc/fstab file contains a list of entries that define where and how the file system will be installed when the system starts.

To automatically mount the NFS share when the Linux system starts, add a line to the/etc/fstab file. This line must contain the host name or IP address of the NFS server, the exported directory, and the mount point on the local computer.

Use the following procedure to automatically mount NFS shares on Linux systems:

Set the mount point for the remote NFS share:

sudo mkdir /var/backups

Open the/etc/fstab file with a text editor:

sudo nano /etc/fstab

Add the following line to the file:/etc/fstab

#

10.10.0.10:/backups /var/backups nfs defaults 0 0

Where, 10.10.0.10 NFS server IP address,/backup is the export directory, and/var/backups is the local installation point.

Run the mount command to mount the NFS share:

mount /var/backups
mount 10.10.0.10:/backups

The mount command will read the contents of/etc/fstab and install the share.

The NFS share will be automatically mounted the next time the system is rebooted.
Unmount NFS file system

The umount command detaches (unmounts) the mounted file system from the directory tree.

To unmount an mounted NFS share, use the umount command followed by the mounted directory or remote share:

umount 10.10.0.10:/backups
umount /var/backups

If there is an entry in the fstab file of the NFS bracket, delete it.

When using a mounted volume, the umount command cannot detach the share. To find out which processes are accessing NFS shares, use the fuser command:

fuser -m MOUNT_POINT

After the process is found, you can use the kill command to stop it, and then unmount the NFS share.

If you still have the problem of unmounting the share, please use the - l (– lazy) option, which allows you to unmount the file system immediately after it is no longer busy.

umount -l MOUNT_POINT

If you cannot access the remote NFS system, use the - f (– force) option to force the unmount.

umount -f MOUNT_POINT

In general, using the force option is not a good idea, because it may damage the data on the file system.

Do not reprint without permission: Cheap VPS evaluation » How to mount nfs under linux (tutorial method for mounting nfs under linux)