Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to mount NFS share under Linux

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to mount NFS sharing under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

NFS is one of the file systems supported by FreeBSD, which allows computers in the network to share resources over the TCP/IP network.

Install the NFS client package

To mount a NFS share on a Linux system, you first need to install the NFS client package. Package names vary from Linux to Linux distribution.

Install the NFS client on Ubuntu and Debian:

Sudo apt updatesudo apt install nfs-common

In CentOS and RedHat:

Sudo yum install nfs-utils manually mounts the NFS file system

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

To mount the NFS file system at 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 the NFS share is 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 directory export where the server is located, and / var/backups is the local mount point.

When successful, no output is generated.

If you want to specify other mount options, use the-o option. You can provide multiple options as a comma-separated list. For a list of all installation options, enter man mount in the terminal.

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

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

When you manually install a share, the NFS share installation does not persist after a reboot.

Use / etc/fstab

Automatic mount of NFS file system

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

The / etc/fstab file contains a list of entries that define where and how to mount the file system when the system boots.

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

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

Set up the mount point for the remote NFS share:

Sudo mkdir / var/backups

Open the / etc/fstab file using 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, / var/backups is the local mount point.

Run the mount command to mount the NFS share:

Mount / var/backupsmount 10.10.0.10:/backups

The mount command reads the contents of / etc/fstab and installs the share.

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

Unmount the NFS file system

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

To uninstall an installed NFS share, use the umount command, followed by the directory or remote share that has been installed:

Umount 10.10.0.10:/backupsumount / var/backups

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

"when using mounted volumes, the umount command cannot detach the share." To find out which processes are accessing the NFS share, use the fuser command:

Fuser-m MOUNT_POINT

Once a process is found, you can use the kill command to stop it, and then uninstall the NFS share.

"if you still have problems unmounting a share, use the-l (--lazy) option, which allows you to unmount a file system as soon as 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 uninstall.

Umount-f MOUNT_POINT

In general, it is not a good idea to use the force option, as it can corrupt data on the file system.

Thank you for reading this article carefully. I hope the article "how to mount NFS sharing under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report