Mount an NFS file system on a Linux ECS instance - Apsara File Storage NAS (2023)

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.

  1. Connect to the ECS instance. For more information, seeconnection methods.
  2. 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:
    1. sudo apt-get update
    2. sudo apt-get install nfs-common
    Debian
  3. 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.

  1. 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 versionspecifies 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.
  2. run ormount itCommand to see the assembly result.

    If you see command output similar to the example below, the mount was successful.Mount an NFS file system on a Linux ECS instance - Apsara File Storage NAS (1)Once the filesystem is mounted, you can run thedf-hCommand 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.

  3. 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.Mount an NFS file system on a Linux ECS instance - Apsara File Storage NAS (2)

    (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.

  1. 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.Mount an NFS file system on a Linux ECS instance - Apsara File Storage NAS (3)

    (Video) Setup AWS EFS Elastic File System | Setup NFS in AWS | Extend Cloud Storage to Onpremise

    If you want to enable automount for CentOS 6.x, follow these steps:

    1. run orchkconfg netfs enabledcommand to enable netfs service at startup.
    2. open the/etc/netconfigconfig and comment out the information related to inet6.Mount an NFS file system on a Linux ECS instance - Apsara File Storage NAS (4)
  2. 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 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 thechkconfg netfs enabledcommand to enable netfs service at startup.
    • If you want to enable automount for Ubuntu, run the following command:
      [ ! -f /etc/rc.local ] && echo '#!/bin/bash' > /etc/rc.local; echo "mount -a -t nfs" >> /etc/rc.local; chmod +x /etc/rc.local
      Add,x-systemd.automountuntil the end ofnoresvportmount option and do not change "0 0" in the command.
    • If you want to enable automount for Alibaba Cloud Linux, run the following command:
      [ ! -f /etc/rc.local ] && echo '#!/bin/bash' > /etc/rc.local; echo "mount -a -t nfs" >> /etc/rc.local; chmod +x /etc/rc.local
      Add,x-systemd.automount,x-systemd.requires=systemd-resolved.service,x-systemd.after=systemd-resolved.serviceuntil the end ofnoresvportmount 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.
  3. run orrestartcommand 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 thedf-hCommand to view mounted NAS file systems after restarting the ECS instance.

FAQs

How to mount the NFS file system in Linux? ›

Manually Mounting an NFS File Systems #
  1. First, create a directory to serve as the mount point for the remote NFS share: sudo mkdir /var/backups. ...
  2. 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.
Aug 23, 2019

Which command is used to mount NFS file system in Linux? ›

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? ›

Mounting the NFS Share
  1. Make sure that the NFS Client is installed. Open a Powershell command prompt. Run the appropriate command for your situation: ...
  2. Mount the share using the following command, after making the required modifications: mount -o anon nfs.share.server.name:/share-name X:

What options are used for mounting an NFS file system? ›

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? ›

Installing the NFS client
  1. Connect to your EC2 instance. Note the following about connecting to the instance: ...
  2. (Optional) Get updates and reboot. ...
  3. After the reboot, reconnect to your EC2 instance.
  4. Install the NFS client. ...
  5. Start the NFS service using the following commands. ...
  6. Verify that the NFS service started, as follows.

How to mount NAS storage in Linux? ›

Mounting a Shared Folder on a Linux Computer
  1. Open a terminal with root privileges.
  2. Run the following command: mount <NAS Ethernet Interface IP>:/share/<Shared Folder Name> <Directory to Mount> Tip: ...
  3. Specify your NAS username and password.

How do you mount a mount in Linux? ›

Identifying and Mounting a Drive using the Linux Terminal
  1. Identify the USB drive using the lsblk command. ...
  2. Create a directory to mount the USB drive into. ...
  3. Mount the USB drive to the /media/pendrive directory using the mount command. ...
  4. Check the drive has been mounted by re-running lsblk.
May 28, 2022

How do I use mount command in Linux? ›

The mount command allows users to mount, i.e., attach additional child file systems to a particular mount point on the currently accessible file system. The command passes the mount instructions to the kernel, which completes the operation.
...
mount Command Options.
OptionDescription
-MMoves a subtree to another location.
12 more rows
Jun 21, 2022

How do I troubleshoot NFS mount issue? ›

Solution
  1. 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. ...
  2. Ensure that the firewall allows NFS traffic to pass through. ...
  3. 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? ›

Troubleshooting NFS Mount Issues in Linux
  1. Install the required nfs packages if not already installed on the server # rpm -qa | grep nfs-utils. # yum install nfs-util.
  2. Use the mount command to mount exported file systems. ...
  3. Update /etc/fstab to mount NFS shares at boot time.
Jan 9, 2020

How check mount storage in Linux? ›

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).

Which storage type can be mounted using the NFS protocol to many EC2 instances simultaneously? ›

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? ›

Mounting a Shared Folder on a Linux Computer
  1. Open a terminal with root privileges.
  2. Run the following command: mount <NAS Ethernet Interface IP>:/share/<Shared Folder Name> <Directory to Mount> Tip: ...
  3. Specify your NAS username and password.

Can you mount NFS? ›

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? ›

Quick Tutorial #1: Setting Up an NFS Server with an NFS Share
  1. Installing NFS Server. ...
  2. Create Root NFS Directory. ...
  3. Define Access for NFS Clients in Export File. ...
  4. Make the NFS Share Available to Clients. ...
  5. Installing NFS Client Packages. ...
  6. Mounting the NFS File Share Temporarily. ...
  7. Mounting NFS File Shares Permanently.
Dec 10, 2020

How do I map a NAS drive in Linux? ›

Mapping a Drive to a Linux Account
  1. Click the Start menu -> File Explorer.
  2. Click This PC.
  3. Click on Computer -> Map Network Drive.
  4. In the “Drive” drop-down box, choose the drive-letter you want to use for this particular directory.
  5. Type in the full path to the directory into the “Folder” field.
Jan 12, 2022

Does Linux automatically mount drives? ›

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? ›

Map a network drive in Windows
  1. Open File Explorer from the taskbar or the Start menu, or press the Windows logo key + E.
  2. Select This PC from the left pane. ...
  3. In the Drive list, select a drive letter. ...
  4. In the Folder box, type the path of the folder or computer, or select Browse to find the folder or computer. ...
  5. Select Finish.

What is command mount in Linux? ›

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.

Videos

1. Introduction to Amazon Elastic File System (EFS) - Cloud File Storage on AWS
(Amazon Web Services)
2. AWS re:Invent 2019: [REPEAT] Network file system (NFS) evolved: Deep dive on Amazon EFS (STG304-R)
(AWS Events)
3. Amazon Elastic File System - Scalable, Elastic, Cloud-Native File System for Linux
(Amazon Web Services)
4. AWS Storage - EBS vs S3 vs EFS
(AWS Training Center)
5. AWS Storage - S3 vs EBS vs EFS Comparison
(Go Cloud Architects)
6. Alibaba Cloud Computing Certified Associate Complete Course / Tutorial
(Alpha Tutorials - Cloud)

References

Top Articles
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated: 11/01/2023

Views: 6034

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.