Start NFS server on Raspberry Pi

Source: Internet
Author: User

1. What is NFS?

(slightly) http://vbird.dic.ksu.edu.tw/linux_server/linux_redhat9/0330nfs.php

2. Install Nfs-kernel-server and Rpcbind (alternative portmap) and start the Rpcbind and Nfs-kernel-server services.

Apt-get Install Nfs-common Nfs-kernel-server

sudo apt-get install Portmap

[Email protected] ~ $ sudo service rpcbind start
[OK] Starting Rpcbind daemon ....
[Email protected] ~ $ ps Ax | grep rpcbind
4130? Ss 0:00/sbin/rpcbind-w
4152 pts/0 s+ 0:00 grep--color=auto rpcbind

Create a catalogue to share and download
# Mkdir/home/partimag

Modify the Setup file/etc/exports
Add the following column
# Vim/etc/exports
/home/partimag 192.168.66.0/24 (Rw,sync,no_subtree_check)

Activate NFS Server
#/etc/init.d/nfs-kernel-server Start
* Exporting directories for NFS kernel daemon ... [OK]
 * starting NFS kernel daemon                                                                                                                                                                          [OK]
The check was a success.
# showmount-e localhost
Export list for localhost:
/home/partimag 192.168.66.0/24

[Email protected] ~ $ showmount-e localhost
Export list for localhost:
/home/pi/nfs_server *

[Email protected] ~ $ sudo mount-t NFS 127.0.0.1:/home/pi/nfs_server/mnt-o nolock
[Email protected] ~ $ cd/mnt/
[Email protected]/mnt $ ls
[Email protected]/mnt $ >nfs.txt
[Email protected]/mnt $ ls
Nfs.txt
[Email protected]/mnt $ cd/home/pi/nfs_server/
[Email protected] ~/nfs_server $ ls
Nfs.txt

Modify the/etc/exports file in which the NFS server directory is added. An NFS server can share multiple NFS directories, and in the/etc/exports file, each directory is set up exclusively on a single line, written in the following format:

NFS Shared directory path client IP or name (parameter 1, parameter 2,..., parameter n)

Description

Q The NFS shared directory can be any directory of the host, and it is best to set the permissions to 777 for ease of use.

The Q client refers to the IP or hostname of the client that can access the shared directory, either the specified IP or host name. If you are using IP, you can use a wildcard character. If a client with IP 192.168.1.x can be accessed, it can be written as 192.168.1.*, and if set to *, it means that any client can access it.

The Q access parameter can be one or more, separated by commas. Possible parameters and descriptions such as REF _ref286733518 \h table  5.108d0c9ea79f9bace118c8200aa004ba90b02000000080000000e0000005f005200650066003200380036003700330033003500310038000000 are listed.

Table STYLEREF 1 \s 5. SEQ table \* ARABIC \s 1 1 NFS setup parameters and description

Parameters

Description

Ro

Read-only access

rw

Read/write access

Sync

All data is written to the share on request

Async

NFS can respond to requests before writing data

Secure

NFS is sent via secure TCP/IP port below 1024

Insecure

NFS is sent over 1024 ports

Wdelay

If multiple users are writing to the NFS directory, the group is written to (default)

No_wdelay

Write immediately if multiple users are writing to the NFS directory, without this setting when using async

Hide

Do not share its subdirectories in the NFS shared directory

No_hide

Subdirectories for shared NFS directories

Subtree_check

Force NFS to check the permissions of the parent directory if a subdirectory such as/usr/bin is shared (default)

No_subtree_check

Do not check parent directory permissions

All_squash

UID and GID mappings for shared files anonymous user anonymous, suitable for common directories

No_all_squash

Preserve UID and GID for shared files (default)

Root_squash

All requests from the root user are mapped to the same permissions as the anonymous user (default)

No_root_squash

Root user has full administrative access to the root directory

Anonuid=xxx

Specify the UID of an anonymous user in the NFS server/etc/passwd file

Anongid=xxx

Specify the GID for anonymous users in the NFS server/etc/passwd file

Assuming that the NFS shared directory is/HOME/KY/NFS, allowing all clients access, the/etc/exports file can be written as:

/home/ky/nfs * (Rw,sync,no_subtree_check, No_root_squash)

If NFS has been started, modify the/etc/exports file and execute the following command, the new settings will take effect:

[Email protected]:~$ Exportfs-ra

Verify the Server for NFS locally. Mount the NFS server directory to a different directory on this machine and you can see the files in the NFS server directory under the mount point directory.

[Email protected]:~$ ls/home/ky/nfs/

Aaaa

[Email protected]:~$ sudo mount-t NFS 127.0.0.1:/home/ky/nfs/mnt

[Email protected]:~$ ls/mnt

Aaaa

[Email protected]:~$ sudo umount/mnt/

Use the Development Board to verify that the NFS server is available. Launch the Development Board, enter the system, configure the IP address of the Development Board, Mount the NFS Directory for NFS server with the Mount command:

target# mount-t NFS 192.168.1.3:/home/ky/nfs/mnt-o nolock

target# ls/mnt

Kingyee

target# umount/mnt/

After the mount succeeds, you can see the files on the NFS server in the/MNT directory of the Development Board.

Description, using the board with the client system installed on the virtual Machine for NFS mounts, the virtual network card needs to be set to bridged mode, and a static IP address is recommended.

If you need to add a new NFS shared directory in use, you can modify the/etc/exports file directly. After modifying the file, you can use the EXPORTFS command to read the/etc/exports file and re-share the output without restarting the NFS service. The EXPORTFS command syntax is as follows:

Exportfs [-aruv]

Option Description:

-A: All mount (or uninstall)/etc/exports settings;

-R: Re-mount the/etc/exports settings;

-U: Uninstalls a directory;

-V: Displays the shared directory at the time of output.

Start NFS server on Raspberry Pi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.