This topic describes how to mount a Network File System (NFS) file system on a Linux Elastic Compute Service (ECS) instance. After installing an NFS client on the ECS Linux instance, you can manually or automatically mount the NFS file system.
Observation
- To ensure optimal access performance, we recommend that you mount a file system using NFSv3.
- NFSv4.0 supports file locks, including range locks. If you need to modify a file on multiple Linux ECS instances at the same time, we recommend that you mount a file system with NFSv4.0.
Configuring a Linux ECS instance
If you need to mount an NFS file system on an ECS instance running Linux, you must configure the Linux ECS instance. After configuring the Linux ECS instance, you no longer need to configure the Linux ECS instance the next time you mount a file system on the instance.
- Connect to the ECS instance. For more information, seeconnection methods.
- Install an NFS client.
Operating system install command Alibaba Cloud Linux sudo yum install nfs-utils
CentOS Red Hat ubuntu Run the following commands in sequence: sudo apt-get update
sudo apt-get install nfs-common
Debian - Increase the maximum number of concurrent NFS requests.
Run the following command to set the maximum number of concurrent NFS requests to 128. For more information, seeHow do I change the maximum number of concurrent NFS requests from an NFS client?
si (lsmod | grep sunrpc); then(modinfo sunrpc | grep tcp_max_slot_table_entries) && sysctl -w sunrpc.tcp_max_slot_table_entries=128(modinfo sunrpc | grep tcp_slot_table_entries) && sysctl -w sunrpc.tcp_slot_table_entries=128fi(modinfo sunrpc | grep tcp_max_slot_table_entries) && echo "options sunrpc tcp_max_slot_table_entries=128" > > /etc/modprobe.d/sunrpc.conf(modinfo sunrpc | grep tcp_slot_table_entries) && echo "opciones sunrpc tcp_slot_table_entries=128" >> /etc/modprobe.d/sunrpc.conf
(Video) How to Create AWS EFS(Elastic File System) and mount on EC2 instance
Manually mount the NFS file system
You can use an NFS file system mount target to mount the file system on a Linux ECS instance.
- Mount the NFS file system.
- To mount a Capacity NAS file system or a Performance NAS file system, run one of the following commands.
Observation
- To ensure optimal access performance, we recommend that you mount a file system using NFSv3.
- NFSv4.0 supports file locks, including range locks. If you need to modify a file on multiple Linux ECS instances at the same time, we recommend that you mount a file system with NFSv4.0.
To use NFSv3 to mount the file system, run the following command:
sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.nas.aliyuncs.com: / /mnt
To use NFSv4 to mount the file system, run the following command:
sudo mount -t nfs -o vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.nas.aliyuncs.com:/ / mnt
(Video) How to create a Network File system(NFS) in AWS - To mount an Extreme NAS file system, run the following command:
sudo mount -t nfs -o vers=3,nolock,noacl,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.extreme.nas. aliyuncs.com:/share/mnt
The following table describes the parameters that you can set in the mount command.
Parameter Description Capacity NAS File Systems or Performance NAS File Systems:file-system-id.region.nas.aliyuncs.com:/ /mnt Extreme NAS File Systems:file-system-id.region.extreme.nas.aliyuncs.com:/share /mnt
<Domain name of a mount target>:<Name of a shared directory> <mount directory path🇧🇷 Substitute the domain name of a mount target, the name of a shared directory, and the path of a mount directory according to your business requirements. - Domain name of a mount target: To view the domain name, perform the following steps: Log in to the NAS console. In the left navigation panel, clickfile system list🇧🇷 On the page that appears, locate the file system you want to manage and clickManagein the Actions column. On the page that appears, clickmounting targets🇧🇷 In the tab that appears, view the domain name of the mount target. For more information, seeManage mount targets.
- Name of a shared directory: specifies the root directory/or a subdirectory. If you specify a subdirectory like/shared, make sure the subdirectory exists.
ObservationThe shared directory of an Extreme NAS file system must begin with/shared, for example,/sharedmi/share/subdirectory.
- mount directory path: specifies the root directory/or a subdirectory like/mntfrom a Linux ECS instance. If the mount directory is a subdirectory, make sure the subdirectory exists.
in direction to The file system protocol version. - Verso=3: Use NFSv3 to mount the file system.
- Vers=4: Use NFSv4 to mount the file system.
smaller version
specifies the minor version number of the protocol. NAS file systems support NFSv4.0. If you are using NFSv4 to mount a NAS file system, you must specify 0 as the minor version number for this parameter.
Observation
- NAS capacity file systems and NAS performance file systems support NFSv3 and NFSv4.
- Extreme NAS file systems only support NFSv3.
mounting options When mounting a file system, you can specify various mount options. Separate multiple mount options with commas (,). The following mounting options are available:
- resize: Specifies the size of the data blocks that the client reads from the file system. Recommended value: 1048576.
- size: Specifies the size of the data blocks that the client writes to the file system. Recommended value: 1048576.
ObservationTo avoid performance degradation, we recommend that you specify the maximum value (1048576) for both the rsize mount option and the wsize mount option.
- be: Specifies that applications stop accessing a file system when the file system is unavailable and wait until the file system is available. We recommend that you specify this mounting option.
- I fear that: Specifies the amount of time in deciseconds (tenths of a second) that the NFS client waits before retrying to send a request. Recommended value: 600 (60 seconds).
ObservationIf you need to modify the timeo mount option, we recommend that you specify 150 or more. The timeo mount option is measured in deciseconds (tenths of a second). For example, the value 150 indicates 15 seconds.
- relay: Specifies the number of times the NFS client tries to send a request. Recommended value: 2.
- noresvport: Specifies that a new TCP port is used to ensure network continuity between the file system and the ECS instance when the network recovers from a failure. We recommend that you specify this mounting option.
Important
- To avoid inconsistencies in the data, we recommend that you do not specify thekindlymounting option. If you specify the flexible mounting option, make sure you understand the potential risks.
- We recommend that you use the default values for other mounting options. Performance degradation can occur due to changes to some mounting options. These mount options include the size of the read or write buffer or the use of attribute caching.
- To mount a Capacity NAS file system or a Performance NAS file system, run one of the following commands.
- run or
mount it
Command to see the assembly result.If you see command output similar to the example below, the mount was successful.
Once the filesystem is mounted, you can run the
df-h
Command to view the storage capacity of the file system.If the file system could not be mounted, fix the problem. For more information, seeTroubleshoot mounting.
- After mounting the NAS file system, you can read and write data to the NAS file system on the ECS Linux instance.
You can access the file system in the same way that you access a local directory. The following figure shows an example.
(Video) How to mount/unmount Local and Network Filesystem in Linux
Automatically mount the NFS file system
When you restart the ECS instance on which a file system is mounted, mount information about the file system might be lost. To avoid this problem, you can modify the/etc/fstabconfiguration file on the ECS Linux instance to enable autoboot mounting of an NFS file system.
ObservationBefore you can configure the automatic mount, make sure that the previous manual mount was successful.
- To mount an Extreme NAS file system, run the following command:
To mount a Capacity NAS file system or Performance NAS file system, skip this step and go topaso 2.
vi /etc/systemd/system/sockets.target.wants/rpcbind.socket
open the/etc/systemd/system/sockets.target.wants/rpcbind.socketconfiguration file and comment out therpcbindIPv6-related parameters, as shown in the following figure. Otherwise, the rpcbind service will not run at startup.
(Video) Setup AWS EFS Elastic File System | Setup NFS in AWS | Extend Cloud Storage to OnpremiseIf you want to enable automount for CentOS 6.x, follow these steps:
- run or
chkconfg netfs enabled
command to enable netfs service at startup. - open the/etc/netconfigconfig and comment out the information related to inet6.
- run or
- open the/etc/fstabconfiguration file.
- To mount a capacity or performance NAS file system, run one of the following commands:
- To use NFSv3 to mount the file system, run the following command:
file-system-id.region.nas.aliyuncs.com:/ /mnt nfs vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0
- To use NFSv4 to mount the file system, run the following command:
file-system-id.region.nas.aliyuncs.com:/ /mnt nfs vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0
- To use NFSv3 to mount the file system, run the following command:
- To mount an Extreme NAS file system, run the following command:
file-system-id.region.extreme.nas.aliyuncs.com:/share /mnt nfs vers=3,nolock,noacl,proto=tcp,noresvport,_netdev 0 0
Observation
- If you want to enable automount for CentOS 6.x, run the
chkconfg netfs enabled
command to enable netfs service at startup. - If you want to enable automount for Ubuntu, run the following command:
Add[ ! -f /etc/rc.local ] && echo '#!/bin/bash' > /etc/rc.local; echo "mount -a -t nfs" >> /etc/rc.local; chmod +x /etc/rc.local
,x-systemd.automount
until the end ofnoresvport
mount option and do not change "0 0" in the command. - If you want to enable automount for Alibaba Cloud Linux, run the following command:
Add[ ! -f /etc/rc.local ] && echo '#!/bin/bash' > /etc/rc.local; echo "mount -a -t nfs" >> /etc/rc.local; chmod +x /etc/rc.local
,x-systemd.automount,x-systemd.requires=systemd-resolved.service,x-systemd.after=systemd-resolved.service
until the end ofnoresvport
mount option and do not change "0 0" in the command.
For more information, seemounting parameters🇧🇷 The following table describes other mounting options used in the previous examples.
(Video) Setup AWS Elastic File System EFS in EC2 Instances in Telugu | తెలుగులోmounting option Description _netdev Prevent auto-mount before the network is connected. 0 (the first value after noresvport) Indicates whether to back up the file system by running the dump command. A non-zero value indicates that a file system was backed up. The default value for NAS file systems is 0. 0 (the second value after noresvport) Indicates the order in which the fsck command checks the file systems at startup. The default value for the NAS file system is 0. The default value of 0 indicates that the fsck command is not executed at startup. - To mount a capacity or performance NAS file system, run one of the following commands:
- run or
restart
command to restart the ECS instance.ObservationBefore restarting the ECS instance, verify that the manual mount was successful. Otherwise, the ECS instance might not restart. If automount is enabled, you can run the
df-h
Command to view mounted NAS file systems after restarting the ECS instance.
FAQs
How to mount the NFS file system in Linux? ›
- First, create a directory to serve as the mount point for the remote NFS share: sudo mkdir /var/backups. ...
- Mount the NFS share by running the following command as root or user with sudo privileges: sudo mount -t nfs 10.10.0.10:/backups /var/backups.
To mount an NFS file system, the resource must be made available on the server by using the share command.
How do I mount an NFS system? ›- Make sure that the NFS Client is installed. Open a Powershell command prompt. Run the appropriate command for your situation: ...
- Mount the share using the following command, after making the required modifications: mount -o anon nfs.share.server.name:/share-name X:
Examples. To mount an export using NFS version 2, use the nfs file system type and specify the nfsvers=2 mount option. To mount using NFS version 3, use the nfs file system type and specify the nfsvers=3 mount option.
How to check for NFS mounts in Linux? ›Use the showmount command to display the remote NFS server mount information. If you omit the options, the default option displays hostnames of all remote mounts from the hostname NFS server. If you omit the hostname parameter, then the local hostname is used.
How to mount NFS on EC2? ›- Connect to your EC2 instance. Note the following about connecting to the instance: ...
- (Optional) Get updates and reboot. ...
- After the reboot, reconnect to your EC2 instance.
- Install the NFS client. ...
- Start the NFS service using the following commands. ...
- Verify that the NFS service started, as follows.
- Open a terminal with root privileges.
- Run the following command: mount <NAS Ethernet Interface IP>:/share/<Shared Folder Name> <Directory to Mount> Tip: ...
- Specify your NAS username and password.
- Identify the USB drive using the lsblk command. ...
- Create a directory to mount the USB drive into. ...
- Mount the USB drive to the /media/pendrive directory using the mount command. ...
- Check the drive has been mounted by re-running lsblk.
...
mount Command Options.
- Ensure that the NFS server is running correctly on all of the CES nodes and that the CES IP address used to mount is active in the CES cluster. ...
- Ensure that the firewall allows NFS traffic to pass through. ...
- Verify that the NFS client is allowed to mount the export.
What are NFS mounts used for? ›
A Network File System (NFS) allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally. This enables system administrators to consolidate resources onto centralized servers on the network.
What ports are required for NFS mount? ›NFS uses port 2049. NFSv3 and NFSv2 use the portmapper service on TCP or UDP port 111. The portmapper service is consulted to get the port numbers for services used with NFSv3 or NFSv2 protocols such as mountd, statd, and nlm.
What are the default NFS mount options in Linux? ›defaults use default options: rw, suid, dev, exec, auto, nouser, and async. This defines the settings for the defaults keyword. NFS has its own (additional) set of defaults that are implied unless you tell it otherwise. An example of this is hard vs soft , where hard is the implied value unless you specify soft .
What are two methods for mounting filesystems? ›There are two types of mounts, a remote mount and a local mount. Remote mounts are done on a remote system on which data is transmitted over a telecommunication line. Remote file systems, such as Network File System (NFS), require that the files be exported before they can be mounted.
What is the size limit for NFS mount? ›The NFS v2 uses signed 32-bit offset. Maximum file size supported is 2GB.
How do I fix mount issues in Linux? ›- Install the required nfs packages if not already installed on the server # rpm -qa | grep nfs-utils. # yum install nfs-util.
- Use the mount command to mount exported file systems. ...
- Update /etc/fstab to mount NFS shares at boot time.
That command is df -H. The -H switch is for human-readable format. The output of df -H will report how much space is used, available, percentage used, and the mount point of every disk attached to your system (Figure 1).
How do I know if my mount is working? ›Using the mount Command
One way we can determine if a directory is mounted is by running the mount command and filtering the output. The above line will exit with 0 (success) if /mnt/backup is a mount point. Otherwise, it'll return -1 (error).
You can access your Amazon EFS file system concurrently from multiple NFS clients, so applications that scale beyond a single connection can access a file system.
How mount NFS share Windows Linux? ›Install the NFS Client (Services for NFS)
The first thing we need to do is install the NFS Client which can be done by following the steps below: Step 1: Open Programs and Features. Step 2: Click Turn Windows features on or off. Step 3: Scroll down and check the option Services for NFS, then click OK.
What is NAS mount point in Linux? ›
The mount point is a directory in a local file system. If the connection to the NAS device is lost, the resource manager will continue to store objects in the mount directory, and could fill up the file system.
What is NAS storage in Linux? ›Network-attached storage (NAS) is a file-level storage architecture that makes stored data more accessible to networked devices. NAS is 1 of the 3 main storage architectures—along with storage area networks (SAN) and direct-attached storage (DAS).
What is NAS and NFS? ›NAS means network-attached storage and has become synonymous with remote file system storage (read more about NAS here). NFS is one of the protocols to access a NAS storage system over the network and the most common one in the Linux/Unix world.
How do I mount a Linux network drive in Linux? ›- Open a terminal with root privileges.
- Run the following command: mount <NAS Ethernet Interface IP>:/share/<Shared Folder Name> <Directory to Mount> Tip: ...
- Specify your NAS username and password.
For NFS version 4, the client can mount the root filesystem for the server and traverse the exported directory structure. Individual exported file systems do not have to be explicitly mounted to be accessed by the client. Establish the local mount point using the mkdir command.
How to use NFS on Linux? ›- Installing NFS Server. ...
- Create Root NFS Directory. ...
- Define Access for NFS Clients in Export File. ...
- Make the NFS Share Available to Clients. ...
- Installing NFS Client Packages. ...
- Mounting the NFS File Share Temporarily. ...
- Mounting NFS File Shares Permanently.
- Click the Start menu -> File Explorer.
- Click This PC.
- Click on Computer -> Map Network Drive.
- In the “Drive” drop-down box, choose the drive-letter you want to use for this particular directory.
- Type in the full path to the directory into the “Folder” field.
By default, Linux OS does not automount any other partition at startup other than the root and the home partition. You can mount other partitions very easily later, but you might want to enable some kind of automount feature on startup.
How do I mount a network storage? ›- Open File Explorer from the taskbar or the Start menu, or press the Windows logo key + E.
- Select This PC from the left pane. ...
- In the Drive list, select a drive letter. ...
- In the Folder box, type the path of the folder or computer, or select Browse to find the folder or computer. ...
- Select Finish.
mount command is used to mount the filesystem found on a device to big tree structure(Linux filesystem) rooted at '/'. Conversely, another command umount can be used to detach these devices from the Tree. Syntax: mount -t type device dir.
How many NFS mounts can you have? ›
All anonymous file systems share the same major number, so there can be a maximum of only 255 anonymous file systems mounted on a single host. Usually you won't need more than ten or twenty total NFS mounts on any given client.