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

Building skills of nfs Server under Linux

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "the skills of building nfs server under Linux". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the skills of building nfs server under Linux".

When using linux for embedded development, in order to facilitate the development, the development board is usually mounted to the host's file system, and then the code is placed in the directory shared to the development board, and then run through the development board.

First check to see if the nfs package, yum list installed | grep nfs, is installed. If installed, the following settings can be made.

Nfs server-side configuration:

1. First create a shared directory: create a share directory under the root directory. Execute mkdir / share

two。 Then edit the exports file: vim / etc/exports

If the directory has not been shared through nfs before, and the file is empty, enter the following content into it:

The code is as follows:

/ share * (sync,rw,no_root_squash)

Each part explains:

/ share is the name of the directory to be shared by the local machine.

* to allow external access to the ip address of the local shared directory.

Sync saves the data in a memory buffer before writing to disk if necessary.

Rw has read and write access to the local shared directory for external hosts

No_root_squash first matches the local user for the visiting user, and then maps to anonymous user or user group after the match fails.

The remaining options for each of the above sections are:

1->. How the client is specified

The host that specifies the ip address: 192.168.0.100

Specify all hosts in the subnet: 192.168.0.0amp 24 or 192.168.0.0Universe 255.255.255.0

The host of the specified domain name: nfs.test.com

All hosts in the specified domain: * .test.com

All hosts: *

2->. Option description

Ro: shared directory is read-only

Rw: shared directory is readable and writable

All_squash: all access users are mapped to anonymous users or user groups

No_all_squash (default): the visiting user matches the local user first, and then maps to anonymous user or user group after the match fails

Root_squash (default): maps visiting root users to anonymous users or user groups

No_root_squash: visiting root users keep root account privileges

Anonuid=: specifies the local user UID of the anonymous access user, which defaults to nfsnobody (65534)

Anongid=: specifies the local user group GID for anonymous access users, which defaults to nfsnobody (65534)

Secure (default): restricts clients to connect to the server only from tcp/ip ports less than 1024

Insecure: allows clients to connect to the server from a tcp/ip port greater than 1024

Sync: write data synchronously to memory buffers and disks, which is inefficient, but can ensure data consistency.

Async: save the data in a memory buffer before writing to disk if necessary

Wdelay (default): check whether there are related write operations, and if so, perform these writes together to improve efficiency

No_wdelay: if there is a write operation, it should be performed immediately. It should be used with sync.

Subtree_check (default): if the output directory is a subdirectory, the nfs server will check the permissions of its parent directory

No_subtree_check: even if the output directory is a subdirectory, the nfs server does not check the permissions of its parent directory.

High efficiency

3. Make the settings take effect: exportfs-ra or service nfs restart

4. Check the output of the shared directory through the command: exportfs-v

Nfs client configuration:

The client can view the external shared directory of the remote server through showmount-e ip.

1. Start the nfs service

two。 Set up mount point, mkdir / mnt/nfs

3. Mount: mount-t nfs ip:/share / mnt/nfs

4. Uninstall: umount / mnt/nfs

The ip in step 3 indicates the host ip of the shared directory, that is, the server ip. You can use localhost instead of ip address to indicate that the directory of this machine is mounted to another directory with nfs.

You can write the mount information to the / etc/fstab file to automatically mount the nfs service in the following format:

Ip:/share / mnt/share nfs defaults 0 0

Where:

Ip:/share is the ip address and shared directory of the remote host

/ mnt/share is the directory to be mounted to the local directory

Nfs is the file system type

Defaults 0 0 is the mount option

Use the mount | grep nfs command to display the nfs directory that is currently mounted on the host.

Unmount the mounted directory: umount / mnt/nfs

Thank you for reading, the above is the content of "Building skills of nfs Server under Linux". After the study of this article, I believe you have a deeper understanding of the skills of building nfs server under Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Servers

Wechat

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

12
Report