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 build NFS server under Linux server

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

Share

Shulou(Shulou.com)05/31 Report--

The knowledge of this article "how to build a NFS server under the Linux server" is not understood by most people, so the editor summarizes the following, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to build a NFS server under a Linux server" article.

First, install and configure nfs server

1 > for the nfs server to provide services, you must start inet, portmap,nfs, and mount

These four daemons are kept running in the background.

2 > Plan the partition or directory to be shared

3 > define parameters for the client

4 > configure nfs main configuration file: / etc/exports

5 > restart the nfs service

1. Syntax of the configuration / etc/exports file

# vi / etc/exports

/ sharedir-maproot=daemon host2

/ sharedir2-ro-network 192.168.1.0

Or use the following format

/ sharedir host3 (option)

/ sharedir 192.168.1.12 Compact 24 (option)

The first paragraph: for a shared directory, be sure to have an absolute path.

The second paragraph: some parameters, such as:-maproot=daemon indicates that if the visitor is a root user, it will be converted to a daemon user;-ro: indicates read-only permission.

The third paragraph: indicates that the client allowed to access can be a host, such as host2; or a network segment. The host can be represented by a domain name or ip. The domain name supports wildcards but does not include dots. For example, * .example.net, it can mean e1.example.net or e2.example.net, etc., but not s1.e1.example.net.

The third format means that those read-write, read-only and other parameters can be written in parentheses and separated by commas.

2. Activate services portmap and nfsd

After portmap is activated, a sunrpc service with port number 111will appear

# service portmap restart

# service nfs restart

3. Client configuration

3.1 enable portmap service

3.2 Mount a shared directory using the mount command

Mount-t type-o option device dir

# mount-t nfs-o hard 192.168.1.22:/sharedir / tmp/

In addition to using the mount command, users can also mount it using / etc/fstab or autofs.

II. Nfs server configuration example

Nfs server-side configuration:

1. First check whether the following software packages are installed on the server side

# rpm-qa | grep nfs

Nfs-utils-1.0.9-16.e15

Nfs-utils-lib-1.0.8-7.2

two。 Configure nfs server-side configuration file: / etc/exports

/ sharedir: is a shared directory with permissions restricted by share permissions (rw) and local permissions.

192.168.1.22 Compact 24: allow all machines in the 192.168.1.0 network segment to access

# vim / etc/exports

# cat / etc/exports

/ sharedir 192.168.1.22 Compact 24 (rw)

3. Restart the nfs service

# service nfs restart

Nfs client configuration:

1. Confirm the installation of the portmap package

# rpm-qa | grep portmap

Portmap-4.0-65.2.2.1

two。 Enable the portmap service

# service portmap restart

3. View a nfs server shared directory

192.168.1.22: the ip address of the nfs server

# showmount-e 192.168.1.22

Export list for 192.168.1.22:

/ sharedir 192.168.1.22/24

4. Mount the shared directory of the server

-t nfs: indicates the file system format of the mounted file, or it can be omitted

# mount-t nfs 192.168.1.22:/sharedir / mnt/

The above is about the content of this article on "how to build a NFS server under the Linux server". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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