

# Accessing file systems
<a name="accessing-fs"></a>

Using Amazon FSx, you can burst your compute-intensive workloads from on-premises into the Amazon Web Services Cloud by importing data over Direct Connect or VPN. You can access your Amazon FSx file system from on-premises, copy data into your file system as-needed, and run compute-intensive workloads on in-cloud instances.

In the following section, you can learn how to access your Amazon FSx for Lustre file system on a Linux instance. In addition, you can find how to use the file `fstab` to automatically remount your file system after any system restarts.

Before you can mount a file system, you must create, configure, and launch your related AWS resources. For detailed instructions, see [Getting started with Amazon FSx for Lustre](getting-started.md). Next, you can install and configure the Lustre client on your compute instance.

**Topics**
+ [Lustre file system and client kernel compatibility](lustre-client-matrix.md)
+ [Installing the Lustre client](install-lustre-client.md)
+ [Mounting from an Amazon Elastic Compute Cloud instance](mounting-ec2-instance.md)
+ [Configuring EFA clients](configure-efa-clients.md)
+ [Mounting from Amazon Elastic Container Service](mounting-ecs.md)
+ [Mounting Amazon FSx file systems from on-premises or a peered Amazon VPC](mounting-on-premises.md)
+ [Mounting your Amazon FSx file system automatically](mount-fs-auto-mount-onreboot.md)
+ [Mounting specific filesets](mounting-from-fileset.md)
+ [Unmounting file systems](unmounting-fs.md)
+ [Working with Amazon EC2 Spot Instances](working-with-ec2-spot-instances.md)

# Lustre file system and client kernel compatibility
<a name="lustre-client-matrix"></a>

We highly recommend using the Lustre version for your FSx for Lustre file system that is compatible with the Linux kernel versions of your client instances.

## Amazon Linux clients
<a name="amz-linux-clients"></a>


| Operating system | OS version | Minimum kernel version | Maximum kernel version | Lustre client version | Lustre file system version | 
| --- | --- | --- | --- | --- | --- | 
|  |  |  |  |  | 2.10 | 2.12 | 2.15 | 
| Amazon Linux 2023 | 6.12 | \$1 | \$1 | 2.15 | no | yes | yes | 
|  | 6.1 | 6.1.79-99.167 | 6.1.79-99.167\$1 | 2.15 | no | yes | yes | 
| Amazon Linux 2 | 5.10 | 5.10.144-127.601 | 5.10.144-127.601\$1 | 2.12 | yes | yes | yes | 
|  |  |  | <5.10.144-127.601 | 2.10 | yes | yes | no | 
|  | 5.4 | 5.4.214-120.368 | 5.4.214-120.368\$1 | 2.12 | yes | yes | yes | 
|  |  |  | <5.4.214-120.368 | 2.10 | yes | yes | no | 
|  | 4.14 | 4.14.294-220.533 | 4.14.294-220.533\$1 | 2.12 | yes | yes | yes | 
|  |  |  | <4.14.294-220.533 | 2.10 | yes | yes | no | 

## Ubuntu clients
<a name="ubuntu-clients"></a>


| Operating system | OS version | Minimum kernel version | Maximum kernel version | Lustre client version | Lustre file system version | 
| --- | --- | --- | --- | --- | --- | 
|  |  |  |  |  | 2.10 | 2.12 | 2.15 | 
| Ubuntu | 24 | 6.14.0-1012 | 6.14.0\$1 | 2.15 | no | yes | yes | 
|  |  | 6.8.0-1024 | 6.8.0\$1 | 2.15 | no | yes | yes | 
|  | 22 | 6.8.0-1017 | 6.8.0\$1 | 2.15 | no | yes | yes | 
|  |  | 6.5.0-1023 | 6.5.0\$1 | 2.15 | no | yes | yes | 
|  |  | 6.2.0-1017 | 6.2.0\$1 | 2.15 | no | yes | yes | 
|  |  | 5.15.0-1015-aws | 5.15.0-1051-aws | 2.12 | yes | yes | yes | 
|  | 20 | 5.15.0-1015-aws | 5.15.0\$1 | 2.12 | yes | yes | yes | 
|  |  | 5.4.0-1011-aws | 5.13.0-1031-aws | 2.10 | yes | yes | no | 

## RHEL/CentOS/Rocky Linux clients
<a name="rhel-clients"></a>


| Operating system | OS version | Architecture | Minimum kernel version | Maximum kernel version | Lustre client version | Lustre file system version | 
| --- | --- | --- | --- | --- | --- | --- | 
|  |  |  |  |  |  | 2.10 | 2.12 | 2.15 | 
| RHEL/Rocky Linux | 9.7 | Arm \$1 x86 | 5.14.0-611.5.1 | 5.14.0-611\$1 | 2.15 | no | yes | yes | 
|  | 9.6 | Arm \$1 x86 | 5.14.0-570.12.1 | 5.14.0-570\$1 | 2.15 | no | yes | yes | 
|  | 9.5 | Arm \$1 x86 | 5.14.0-503.19.1 | 5.14.0-503\$1 | 2.15 | no | yes | yes | 
|  | 9.4 | Arm \$1 x86 | 5.14.0-427.13.1 | 5.14.0-427\$1 | 2.15 | no | yes | yes | 
|  | 9.3 | Arm \$1 x86 | 5.14.0-362.18.1 | 5.14.0-362.18.1 | 2.15 | no | yes | yes | 
|  | 9.0 | Arm \$1 x86 | 5.14.0-70.13.1 | 5.14.0-70.30.1 | 2.15 | no | yes | yes | 
| RHEL/CentOS/Rocky Linux | 8.10 | Arm \$1 x86 | 4.18.0-553 | 4.18.0-553\$1 | 2.12 | yes | yes | yes | 
|  | 8.9 | Arm \$1 x86 | 4.18.0-513\$1 | 4.18.0-513\$1 | 2.12 | yes | yes | yes | 
|  | 8.8 | Arm \$1 x86 | 4.18.0-477\$1 | 4.18.0-477\$1 | 2.12 | yes | yes | yes | 
|  | 8.7 | Arm \$1 x86 | 4.18.0-425\$1 | 4.18.0-425\$1 | 2.12 | yes | yes | yes | 
|  | 8.6 | Arm \$1 x86 | 4.18.0-372\$1 | 4.18.0-372\$1 | 2.12 | yes | yes | yes | 
|  | 8.5 | Arm \$1 x86 | 4.18.0-348\$1 | 4.18.0-348\$1 | 2.12 | yes | yes | yes | 
|  | 8.4 | Arm \$1 x86 | 4.18.0-305\$1 | 4.18.0-305\$1 | 2.12 | yes | yes | yes | 
| RHEL/CentOS | 8.3 | Arm \$1 x86 | 4.18.0-240\$1 | 4.18.0-240\$1 | 2.10 | yes | yes | no | 
|  | 8.2 | Arm \$1 x86 | 4.18.0-193\$1 | 4.18.0-193\$1 | 2.10 | yes | yes | no | 
|  | 7.9 | x86 | 3.10.0-1160\$1 | 3.10.0-1160\$1 | 2.12 | yes | yes | yes | 
|  | 7.8 | x86 | 3.10.0-1127\$1 | 3.10.0-1127\$1 | 2.10 | yes | yes | no | 
|  | 7.7 | x86 | 3.10.0-1062\$1 | 3.10.0-1062\$1 | 2.10 | yes | yes | no | 
| CentOS | 7.9 | Arm | 4.18.0-193\$1 | 4.18.0-193\$1 | 2.12 | yes | yes | yes | 
|  | 7.8 | Arm | 4.18.0-147\$1 | 4.18.0-147\$1 | 2.12 | yes | yes | yes | 

# Installing the Lustre client
<a name="install-lustre-client"></a>

To mount your Amazon FSx for Lustre file system from a Linux instance, first install the open-source Lustre client. Then, depending on your operating system version, use one of the following procedures. For kernel support information, see [Lustre file system and client kernel compatibility](lustre-client-matrix.md).

If you are using a Lustre client with EFA (Elastic Fabric Adapter), see [Configuring EFA clients](configure-efa-clients.md).

If your compute instance isn't running the Linux kernel specified in the installation instructions, and you can't change the kernel, you can build your own Lustre client. For more information, see [Compiling Lustre](http://wiki.lustre.org/Compiling_Lustre) on the Lustre Wiki.

## Amazon Linux
<a name="lustre-client-amazon-linux"></a>

### To install the Lustre client on Amazon Linux 2023
<a name="install-lustre-client-amazon-linux-2023"></a>

1. Open a terminal on your client.

1. Determine which kernel is currently running on your compute instance by running the following command.

   ```
   uname -r
   ```

1. Review the system response and compare it to the following minimum kernel requirement for installing the Lustre client on Amazon Linux 2023:
   + 6.12 kernel minimum requirement - 6.12\$1
   + 6.1 kernel minimum requirement - 6.1.79-99.167.amzn2023

   If your EC2 instance meets the minimum kernel requirement, proceed to the step and install the Lustre client.

   If the command returns a result less than the kernel minimum requirement, update the kernel and reboot your Amazon EC2 instance by running the following command.

   ```
   sudo dnf -y update kernel && sudo reboot
   ```

   Confirm that the kernel has been updated using the **uname -r** command.

1. Download and install the Lustre client with the following command.

   ```
   sudo dnf install -y lustre-client
   ```

### To install the Lustre client on Amazon Linux 2
<a name="install-lustre-client-amazon-linux-2"></a>

1. Open a terminal on your client.

1. Determine which kernel is currently running on your compute instance by running the following command.

   ```
   uname -r
   ```

1. Review the system response and compare it to the following minimum kernel requirements for installing the Lustre client on Amazon Linux 2:
   + 5.10 kernel minimum requirement - 5.10.144-127.601.amzn2
   + 5.4 kernel minimum requirement - 5.4.214-120.368.amzn2
   + 4.14 kernel minimum requirement - 4.14.294-220.533.amzn2

   If your EC2 instance meets the minimum kernel requirements, proceed to the step and install the Lustre client.

   If the command returns a result less than the kernel minimum requirement, update the kernel and reboot your Amazon EC2 instance by running the following command.

   ```
   sudo yum -y update kernel && sudo reboot
   ```

   Confirm that the kernel has been updated using the **uname -r** command.

1. Download and install the Lustre client with the following command.

   ```
   sudo amazon-linux-extras install -y lustre
   ```

   If you are unable to upgrade the kernel to the kernel minimum requirement, you may install the legacy 2.10 client with the following command.

   ```
   sudo amazon-linux-extras install -y lustre2.10
   ```

### To install the Lustre client on Amazon Linux
<a name="install-lustre-client-amazon-linux"></a>

1. Open a terminal on your client.

1. Determine which kernel is currently running on your compute instance by running the following command. The Lustre client requires Amazon Linux kernel `4.14, version 104` or higher. 

   ```
   uname -r
   ```

1. Do one of the following:
   + If the command returns `4.14.104-78.84.amzn1.x86_64` or a higher version of 4.14, download and install the Lustre client using the following command.

     ```
     sudo yum install -y lustre-client
     ```
   +  If the command returns a result less than `4.14.104-78.84.amzn1.x86_64`, update the kernel and reboot your Amazon EC2 instance by running the following command. 

     ```
     sudo yum -y update kernel && sudo reboot
     ```

     Confirm that the kernel has been updated using the **uname -r** command. Then download and install the Lustre client as described previously.

## CentOS, Rocky Linux, and Red Hat
<a name="lustre-client-rhel"></a>

### To install the Lustre client on Red Hat and Rocky Linux 9.0 or 9.3–9.7
<a name="install-lustre-client-RH9"></a>

You can install and update Lustre client packages that are compatible with Red Hat Enterprise Linux (RHEL) and Rocky Linux from the Amazon FSx Lustre client yum package repository. These packages are signed to help ensure that they have not been tampered with before or during download. The repository installation fails if you don't install the corresponding public key on your system.

**To add the Amazon FSx Lustre client yum package repository**

1. Open a terminal on your client.

1. Install the Amazon FSx rpm public key by using the following command.

   ```
   curl https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-rpm-public-key.asc -o /tmp/fsx-rpm-public-key.asc
   ```

1. Import the key by using the following command.

   ```
   sudo rpm --import /tmp/fsx-rpm-public-key.asc
   ```

1. Add the repository and update the package manager using the following command.

   ```
   sudo curl https://fsx-lustre-client-repo.s3.amazonaws.com/el/9/fsx-lustre-client.repo -o /etc/yum.repos.d/aws-fsx.repo
   ```

**To configure the Amazon FSx Lustre client yum repository**

The Amazon FSx Lustre client yum package repository is configured by default to install the Lustre client that is compatible with the kernel version that initially shipped with the latest supported Rocky Linux and RHEL 9 release. To install a Lustre client that is compatible with the kernel version you are using, you can edit the repository configuration file.

This section describes how to determine which kernel you are running, whether you need to edit the repository configuration, and how to edit the configuration file.

1. Determine which kernel is currently running on your compute instance by using the following command.

   ```
   uname -r
   ```

1. Do one of the following:
   + If the command returns `5.14.0-611*`, you don't need to modify the repository configuration. Continue to the **To install the Lustre client** procedure.
   +  If the command returns `5.14.0-570*`, you must edit the repository configuration so that it points to the Lustre client for the Rocky Linux and RHEL 9.6 release.
   +  If the command returns `5.14.0-503*`, you must edit the repository configuration so that it points to the Lustre client for the Rocky Linux and RHEL 9.5 release.
   +  If the command returns `5.14.0-427*`, you must edit the repository configuration so that it points to the Lustre client for the Rocky Linux and RHEL 9.4 release.
   +  If the command returns `5.14.0-362.18.1`, you must edit the repository configuration so that it points to the Lustre client for the Rocky Linux and RHEL 9.3 release.
   +  If the command returns `5.14.0-70*`, you must edit the repository configuration so that it points to the Lustre client for the Rocky Linux and RHEL 9.0 release.

1. Edit the repository configuration file to point to a specific version of RHEL using the following command. Replace *`specific_RHEL_version`* with the RHEL version you need to use.

   ```
   sudo sed -i 's#9#specific_RHEL_version#' /etc/yum.repos.d/aws-fsx.repo
   ```

   For example, to point to release 9.6, substitute `specific_RHEL_version` with `9.6` in the command, as in the following example.

   ```
   sudo sed -i 's#9#9.6#' /etc/yum.repos.d/aws-fsx.repo
   ```

1. Use the following command to clear the yum cache.

   ```
   sudo yum clean all
   ```

**To install the Lustre client**
+ Install the packages from the repository using the following command.

  ```
  sudo yum install -y kmod-lustre-client lustre-client
  ```

#### Additional information (Rocky Linux and Red Hat 9.0 and newer)
<a name="lustre-client-RH9-additional-info"></a>

The commands preceding install the two packages that are necessary for mounting and interacting with your Amazon FSx file system. The repository includes additional Lustre packages, such as a package containing the source code and packages containing tests, and you can optionally install them. To list all available packages in the repository, use the following command.

```
yum --disablerepo="*" --enablerepo="aws-fsx" list available
```

To download the source rpm, containing a tarball of the upstream source code and the set of patches that we've applied, use the following command.

```
 sudo yumdownloader --source kmod-lustre-client
```

When you run yum update, a more recent version of the module is installed if available and the existing version is replaced. To prevent the currently installed version from being removed on update, add a line like the following to your `/etc/yum.conf` file.

```
installonlypkgs=kernel, kernel-PAE, installonlypkg(kernel), installonlypkg(kernel-module), 
              installonlypkg(vm), multiversion(kernel), kmod-lustre-client
```

 This list includes the default install only packages, specified in the `yum.conf` man page, and the `kmod-lustre-client` package.

### To install the Lustre client on CentOS and Red Hat 8.2–8.10 or on Rocky Linux 8.4–8.10
<a name="install-lustre-client-RH8.2"></a>

You can install and update Lustre client packages that are compatible with Red Hat Enterprise Linux (RHEL), Rocky Linux, and CentOS from the Amazon FSx Lustre client yum package repository. These packages are signed to help ensure that they have not been tampered with before or during download. The repository installation fails if you don't install the corresponding public key on your system.

**To add the Amazon FSx Lustre client yum package repository**

1. Open a terminal on your client.

1. Install the Amazon FSx rpm public key by using the following command.

   ```
   curl https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-rpm-public-key.asc -o /tmp/fsx-rpm-public-key.asc
   ```

1. Import the key by using the following command.

   ```
   sudo rpm --import /tmp/fsx-rpm-public-key.asc
   ```

1. Add the repository and update the package manager using the following command.

   ```
   sudo curl https://fsx-lustre-client-repo.s3.amazonaws.com/el/8/fsx-lustre-client.repo -o /etc/yum.repos.d/aws-fsx.repo
   ```

**To configure the Amazon FSx Lustre client yum repository**

The Amazon FSx Lustre client yum package repository is configured by default to install the Lustre client that is compatible with the kernel version that initially shipped with the latest supported CentOS, Rocky Linux, and RHEL 8 release. To install a Lustre client that is compatible with the kernel version you are using, you can edit the repository configuration file.

This section describes how to determine which kernel you are running, whether you need to edit the repository configuration, and how to edit the configuration file.

1. Determine which kernel is currently running on your compute instance by using the following command.

   ```
   uname -r
   ```

1. Do one of the following:
   + If the command returns `4.18.0-553*`, you don't need to modify the repository configuration. Continue to the **To install the Lustre client** procedure.
   +  If the command returns `4.18.0-513*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS, Rocky Linux, and RHEL 8.9 release.
   +  If the command returns `4.18.0-477*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS, Rocky Linux, and RHEL 8.8 release.
   +  If the command returns `4.18.0-425*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS, Rocky Linux, and RHEL 8.7 release.
   +  If the command returns `4.18.0-372*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS, Rocky Linux, and RHEL 8.6 release.
   +  If the command returns `4.18.0-348*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS, Rocky Linux, and RHEL 8.5 release.
   +  If the command returns `4.18.0-305*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS, Rocky Linux, and RHEL 8.4 release.
   +  If the command returns `4.18.0-240*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS and RHEL 8.3 release.
   +  If the command returns `4.18.0-193*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS and RHEL 8.2 release.

1. Edit the repository configuration file to point to a specific version of RHEL using the following command.

   ```
   sudo sed -i 's#8#specific_RHEL_version#' /etc/yum.repos.d/aws-fsx.repo
   ```

   For example, to point to release 8.9, substitute `specific_RHEL_version` with `8.9` in the command.

   ```
   sudo sed -i 's#8#8.9#' /etc/yum.repos.d/aws-fsx.repo
   ```

1. Use the following command to clear the yum cache.

   ```
   sudo yum clean all
   ```

**To install the Lustre client**
+ Install the packages from the repository using the following command.

  ```
  sudo yum install -y kmod-lustre-client lustre-client
  ```

#### Additional information (CentOS, Rocky Linux, and Red Hat 8.2 and newer)
<a name="lustre-client-RH8.2-additional-info"></a>

The commands preceding install the two packages that are necessary for mounting and interacting with your Amazon FSx file system. The repository includes additional Lustre packages, such as a package containing the source code and packages containing tests, and you can optionally install them. To list all available packages in the repository, use the following command. 

```
yum --disablerepo="*" --enablerepo="aws-fsx" list available
```

To download the source rpm, containing a tarball of the upstream source code and the set of patches that we've applied, use the following command.

```
 sudo yumdownloader --source kmod-lustre-client
```

When you run yum update, a more recent version of the module is installed if available and the existing version is replaced. To prevent the currently installed version from being removed on update, add a line like the following to your `/etc/yum.conf` file.

```
installonlypkgs=kernel, kernel-PAE, installonlypkg(kernel), installonlypkg(kernel-module), 
              installonlypkg(vm), multiversion(kernel), kmod-lustre-client
```

 This list includes the default install only packages, specified in the `yum.conf` man page, and the `kmod-lustre-client` package.

### To install the Lustre client on CentOS and Red Hat 7.7, 7.8, or 7.9 (x86\$164 instances)
<a name="install-lustre-client-Centos-7"></a>

You can install and update Lustre client packages that are compatible with Red Hat Enterprise Linux (RHEL) and CentOS from the Amazon FSx Lustre client yum package repository. These packages are signed to help ensure they have not been tampered with before or during download. The repository installation fails if you don't install the corresponding public key on your system.

**To add the Amazon FSx Lustre client yum package repository**

1. Open a terminal on your client.

1. Install the Amazon FSx rpm public key using the following command.

   ```
   curl https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-rpm-public-key.asc -o /tmp/fsx-rpm-public-key.asc
   ```

1. Import the key using the following command.

   ```
   sudo rpm --import /tmp/fsx-rpm-public-key.asc
   ```

1. Add the repository and update the package manager using the following command.

   ```
   sudo curl https://fsx-lustre-client-repo.s3.amazonaws.com/el/7/fsx-lustre-client.repo -o /etc/yum.repos.d/aws-fsx.repo
   ```

**To configure the Amazon FSx Lustre client yum repository**

The Amazon FSx Lustre client yum package repository is configured by default to install the Lustre client that is compatible with the kernel version that initially shipped with the latest supported CentOS and RHEL 7 release. To install a Lustre client that is compatible with the kernel version you are using, you can edit the repository configuration file. 

This section describes how to determine which kernel you are running, whether you need to edit the repository configuration, and how to edit the configuration file.

1. Determine which kernel is currently running on your compute instance by using the following command.

   ```
   uname -r
   ```

1. Do one of the following:
   + If the command returns `3.10.0-1160*`, you don't need to modify the repository configuration. Continue to the **To install the Lustre client** procedure.
   +  If the command returns `3.10.0-1127*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS and RHEL 7.8 release.
   +  If the command returns `3.10.0-1062*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS and RHEL 7.7 release.

1. Edit the repository configuration file to point to a specific version of RHEL using the following command.

   ```
   sudo sed -i 's#7#specific_RHEL_version#' /etc/yum.repos.d/aws-fsx.repo
   ```

   To point to release 7.8, substitute `specific_RHEL_version` with `7.8` in the command.

   ```
   sudo sed -i 's#7#7.8#' /etc/yum.repos.d/aws-fsx.repo
   ```

   To point to release 7.7, substitute `specific_RHEL_version` with `7.7` in the command.

   ```
   sudo sed -i 's#7#7.7#' /etc/yum.repos.d/aws-fsx.repo
   ```

1. Use the following command to clear the yum cache.

   ```
   sudo yum clean all
   ```

**To install the Lustre client**
+ Install the Lustre client packages from the repository using the following command.

  ```
  sudo yum install -y kmod-lustre-client lustre-client
  ```

#### Additional information (CentOS and Red Hat 7.7 and newer)
<a name="lustre-client-Centos-7-additional-info"></a>

The commands preceding install the two packages that are necessary for mounting and interacting with your Amazon FSx file system. The repository includes additional Lustre packages, such as a package containing the source code and packages containing tests, and you can optionally install them. To list all available packages in the repository, use the following command. 

```
yum --disablerepo="*" --enablerepo="aws-fsx" list available
```

To download the source rpm containing a tarball of the upstream source code and the set of patches that we've applied, use the following command.

```
 sudo yumdownloader --source kmod-lustre-client
```

When you run yum update, a more recent version of the module is installed if available, and the existing version is replaced. To prevent the currently installed version from being removed on update, add a line like the following to your `/etc/yum.conf` file.

```
installonlypkgs=kernel, kernel-big‐mem, kernel-enterprise, kernel-smp,
              kernel-debug, kernel-unsupported, kernel-source, kernel-devel, kernel-PAE,
              kernel-PAE-debug, kmod-lustre-client
```

 This list includes the default install only packages, specified in the `yum.conf` man page, and the `kmod-lustre-client` package.

### To install the Lustre client on CentOS 7.8 or 7.9 (Arm-based AWS Graviton-powered instances)
<a name="install-lustre-client-Centos-7-arm"></a>

You can install and update Lustre client packages from the Amazon FSx Lustre client yum package repository that are compatible with CentOS 7 for Arm-based AWS Graviton-powered EC2 instances. These packages are signed to help ensure they have not been tampered with before or during download. The repository installation fails if you don't install the corresponding public key on your system.

**To add the Amazon FSx Lustre client yum package repository**

1. Open a terminal on your client.

1. Install the Amazon FSx rpm public key using the following command.

   ```
   curl https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-rpm-public-key.asc -o /tmp/fsx-rpm-public-key.asc
   ```

   ```
   curl https://fsx-lustre-client-repo-public-keys.s3.amazonaws.cn/fsx-rpm-public-key.asc -o /tmp/fsx-rpm-public-key.asc
   ```

1. Import the key using the following command.

   ```
   sudo rpm --import /tmp/fsx-rpm-public-key.asc
   ```

1. Add the repository and update the package manager using the following command.

   ```
   sudo curl https://fsx-lustre-client-repo.s3.amazonaws.com/centos/7/fsx-lustre-client.repo -o /etc/yum.repos.d/aws-fsx.repo
   ```

**To configure the Amazon FSx Lustre client yum repository**

The Amazon FSx Lustre client yum package repository is configured by default to install the Lustre client that is compatible with the kernel version that initially shipped with the latest supported CentOS 7 release. To install a Lustre client that is compatible with the kernel version you are using, you can edit the repository configuration file. 

This section describes how to determine which kernel you are running, whether you need to edit the repository configuration, and how to edit the configuration file.

1. Determine which kernel is currently running on your compute instance by using the following command.

   ```
   uname -r
   ```

1. Do one of the following:
   + If the command returns `4.18.0-193*`, you don't need to modify the repository configuration. Continue to the **To install the Lustre client** procedure.
   +  If the command returns `4.18.0-147*`, you must edit the repository configuration so that it points to the Lustre client for the CentOS 7.8 release.

1. Edit the repository configuration file to point to the CentOS 7.8 release using the following command.

   ```
   sudo sed -i 's#7#7.8#' /etc/yum.repos.d/aws-fsx.repo
   ```

1. Use the following command to clear the yum cache.

   ```
   sudo yum clean all
   ```

**To install the Lustre client**
+ Install the packages from the repository using the following command.

  ```
  sudo yum install -y kmod-lustre-client lustre-client
  ```

#### Additional information (CentOS 7.8 or 7.9 for Arm-based AWS Graviton-powered EC2 instances)
<a name="lustre-client-Centos-7-arm-additional-info"></a>

The commands preceding install the two packages that are necessary for mounting and interacting with your Amazon FSx file system. The repository includes additional Lustre packages, such as a package containing the source code and packages containing tests, and you can optionally install them. To list all available packages in the repository, use the following command. 

```
yum --disablerepo="*" --enablerepo="aws-fsx" list available
```

To download the source rpm, containing a tarball of the upstream source code and the set of patches that we've applied, use the following command.

```
 sudo yumdownloader --source kmod-lustre-client
```

When you run yum update, a more recent version of the module is installed if available, and the existing version is replaced. To prevent the currently installed version from being removed on update, add a line like the following to your `/etc/yum.conf` file.

```
installonlypkgs=kernel, kernel-big‐mem, kernel-enterprise, kernel-smp,
              kernel-debug, kernel-unsupported, kernel-source, kernel-devel, kernel-PAE,
              kernel-PAE-debug, kmod-lustre-client
```

 This list includes the default install only packages, specified in the `yum.conf` man page, and the `kmod-lustre-client` package.

## Ubuntu with Default Page Size (4KB)
<a name="lustre-client-ubuntu"></a>

### To install the Lustre client on Ubuntu 18.04, 20.04, 22.04, or 24.04 with the default page size (4KB)
<a name="install-lustre-client-Ubuntu"></a>

You can get Lustre packages from the Amazon FSx Ubuntu repository. To validate that the contents of the repository have not been tampered with before or during download, a GNU Privacy Guard (GPG) signature is applied to the metadata of the repository. Installing the repository fails unless you have the correct public GPG key installed on your system.

1. Open a terminal on your client.

1. Follow these steps to add the Amazon FSx Ubuntu repository:

   1. If you have not previously registered an Amazon FSx Ubuntu repository on your client instance, download and install the required public key. Use the following command.

      ```
      wget -O - https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-ubuntu-public-key.asc | gpg --dearmor | sudo tee /usr/share/keyrings/fsx-ubuntu-public-key.gpg >/dev/null
      ```

   1. Add the Amazon FSx package repository to your local package manager using the following command.

      ```
      sudo bash -c 'echo "deb [signed-by=/usr/share/keyrings/fsx-ubuntu-public-key.gpg] https://fsx-lustre-client-repo.s3.amazonaws.com/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/fsxlustreclientrepo.list && apt-get update'
      ```

1. Determine which kernel is currently running on your client instance, and update as needed. For a list of the required kernels for the Lustre client on Ubuntu for both x86-based EC2 instances and Arm-based EC2 instances powered by AWS Graviton processors, see [Ubuntu clients](lustre-client-matrix.md#ubuntu-clients).

   1. Run the following command to determine which kernel is running.

      ```
      uname -r
      ```

   1. Run the following command to update to the latest Ubuntu kernel and Lustre version and then reboot.

      ```
      sudo apt install -y linux-aws lustre-client-modules-aws && sudo reboot
      ```

       If your kernel version is greater than the minimum kernel version for both x86-based EC2 instances and Graviton-based EC2 instances, and you don’t want to update to the latest kernel version, you can install Lustre for the current kernel with the following command. 

      ```
      sudo apt install -y lustre-client-modules-$(uname -r)
      ```

      The two Lustre packages that are necessary for mounting and interacting with your FSx for Lustre file system are installed. You can optionally install additional related packages such as a package containing the source code and packages containing tests that are included in the repository.

   1. List all available packages in the repository by using the following command. 

      ```
      sudo apt-cache search ^lustre
      ```

   1. (Optional) If you want your system upgrade to also always upgrade Lustre client modules, make sure that the `lustre-client-modules-aws` package is installed using the following command.

      ```
      sudo apt install -y lustre-client-modules-aws
      ```

**Note**  
If you get a `Module Not Found` error, see [To troubleshoot missing module errors](#ubuntu-missing-module).

### To troubleshoot missing module errors
<a name="ubuntu-missing-module"></a>

If you get a `Module Not Found` error while installing on any version of Ubuntu, do the following:

Downgrade your kernel to the latest supported version. List all available versions of the lustre-client-modules package and install the corresponding kernel. To do this, use the following command.

```
sudo apt-cache search lustre-client-modules
```

For example, if the latest version that is included in the repository is `lustre-client-modules-5.4.0-1011-aws`, do the following:

1. Install the kernel that this package was built for using the following commands.

   ```
   sudo apt-get install -y linux-image-5.4.0-1011-aws
   ```

   ```
   sudo sed -i 's/GRUB_DEFAULT=.\+/GRUB\_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-1011-aws"/' /etc/default/grub
   ```

   ```
   sudo update-grub
   ```

1. Reboot your instance using the following command.

   ```
   sudo reboot
   ```

1. Install the Lustre client using the following command.

   ```
   sudo apt-get install -y lustre-client-modules-$(uname -r)
   ```

## Ubuntu with 64KB Page Size
<a name="lustre-client-ubuntu-64k"></a>

### To install the Lustre client on Ubuntu24.04 (ARM64) with 64KB Page Size
<a name="install-lustre-client-ubuntu-64k"></a>

You can get Lustre packages from the Amazon FSx Ubuntu repository. To validate that the contents of the repository have not been tampered with before or during download, a GNU Privacy Guard (GPG) signature is applied to the metadata of the repository. Installing the repository fails unless you have the correct public GPG key installed on your system.

1. Open a terminal on your client.

1. Verify that your instance is using a 64KB page size. The output should be `65536`.

   ```
   getconf PAGESIZE
   ```

   

1. Follow these steps to add the Amazon FSx Ubuntu repository:

   1. If you have not previously registered an Amazon FSx Ubuntu repository on your client instance, download and install the required public key. Use the following command.

      ```
      wget -O - https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-ubuntu-public-key.asc | gpg --dearmor | sudo tee /usr/share/keyrings/fsx-ubuntu-public-key.gpg >/dev/null
      ```

   1. Add the Amazon FSx package repository to your local package manager using the following command.

      ```
      sudo bash -c 'echo "deb [signed-by=/usr/share/keyrings/fsx-ubuntu-public-key.gpg] https://fsx-lustre-client-repo.s3.amazonaws.com/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/fsxlustreclientrepo.list && apt-get update'
      ```

1. Determine which kernel is currently running on your client instance, and update as needed. Your Ubuntu 24 kernel version must be `6.14.0-1018-aws-64k` or later.

   1. Run the following command to determine which kernel is running.

      ```
      uname -r
      ```

   1. Run the following command to update to the latest Ubuntu kernel and Lustre version and then reboot.

      ```
      sudo apt install -y linux-aws-64k lustre-client-modules-aws-64k && sudo reboot
      ```

      If your kernel version is greater than `6.14.0-1018-aws-64k` for the Graviton-based EC2 instances, and you don’t want to update to the latest kernel version, you can install Lustre for the current kernel with the following command.

      ```
      sudo apt install -y lustre-client-modules-$(uname -r)
      ```

      The two Lustre packages that are necessary for mounting and interacting with your FSx for Lustre file system are installed. You can optionally install additional related packages such as a package containing the source code and packages containing tests that are included in the repository.

   1. List all available packages in the repository by using the following command.

      ```
      sudo apt-cache search ^lustre
      ```

   1. (Optional) If you want your system upgrade to also always upgrade Lustre client modules, make sure that the `lustre-client-modules-aws-64k` package is installed using the following command.

      ```
      sudo apt install -y lustre-client-modules-aws-64k
      ```

## SUSE Linux
<a name="lustre-client-suse"></a>

### To install the Lustre client on SUSE Linux 12 SP3, SP4, or SP5
<a name="install-lustre-client-SUSE-Linux"></a>

**To install the Lustre client on SUSE Linux 12 SP3**

1. Open a terminal on your client.

1. Install the Amazon FSx rpm public key by using the following command.

   ```
   sudo wget https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-sles-public-key.asc
   ```

1. Import the key by using the following command.

   ```
   sudo rpm --import fsx-sles-public-key.asc
   ```

1. Add the repository for the Lustre client using the following command.

   ```
   sudo wget https://fsx-lustre-client-repo.s3.amazonaws.com/suse/sles-12/SLES-12/fsx-lustre-client.repo
   ```

1. Download and install the Lustre client with the following commands.

   ```
   sudo zypper ar --gpgcheck-strict fsx-lustre-client.repo
   sudo sed -i 's#SLES-12#SP3#' /etc/zypp/repos.d/aws-fsx.repo
   sudo zypper refresh
   sudo zypper in lustre-client
   ```

**To install the Lustre client on SUSE Linux 12 SP4**

1. Open a terminal on your client.

1. Install the Amazon FSx rpm public key by using the following command.

   ```
   sudo wget https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-sles-public-key.asc
   ```

1. Import the key by using the following command.

   ```
   sudo rpm --import fsx-sles-public-key.asc
   ```

1. Add the repository for the Lustre client using the following command.

   ```
   sudo wget https://fsx-lustre-client-repo.s3.amazonaws.com/suse/sles-12/SLES-12/fsx-lustre-client.repo
   ```

1. Do one of the following:
   + If you installed SP4 directly, download and install the Lustre client with the following commands.

     ```
     sudo zypper ar --gpgcheck-strict fsx-lustre-client.repo
     sudo sed -i 's#SLES-12#SP4#' /etc/zypp/repos.d/aws-fsx.repo
     sudo zypper refresh
     sudo zypper in lustre-client
     ```
   + If you migrated from SP3 to SP4 and previously added the Amazon FSx repository for SP3, download and install the Lustre client with the following commands.

     ```
     sudo zypper ar --gpgcheck-strict fsx-lustre-client.repo
     sudo sed -i 's#SP3#SP4#' /etc/zypp/repos.d/aws-fsx.repo
     sudo zypper ref
     sudo zypper up --force-resolution lustre-client-kmp-default
     ```

**To install the Lustre client on SUSE Linux 12 SP5**

1. Open a terminal on your client.

1. Install the Amazon FSx rpm public key by using the following command.

   ```
   sudo wget https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-sles-public-key.asc
   ```

1. Import the key by using the following command.

   ```
   sudo rpm --import fsx-sles-public-key.asc
   ```

1. Add the repository for the Lustre client using the following command.

   ```
   sudo wget https://fsx-lustre-client-repo.s3.amazonaws.com/suse/sles-12/SLES-12/fsx-lustre-client.repo
   ```

1. Do one of the following:
   + If you installed SP5 directly, download and install the Lustre client with the following commands.

     ```
     sudo zypper ar --gpgcheck-strict fsx-lustre-client.repo
     sudo zypper refresh
     sudo zypper in lustre-client
     ```
   + If you migrated from SP4 to SP5 and previously added the Amazon FSx repository for SP4, download and install the Lustre client with the following commands.

     ```
     sudo sed -i 's#SP4#SLES-12' /etc/zypp/repos.d/aws-fsx.repo
     sudo zypper ref
     sudo zypper up --force-resolution lustre-client-kmp-default
     ```

**Note**  
You might need to reboot your compute instance for the client to finish installing.

# Mounting from an Amazon Elastic Compute Cloud instance
<a name="mounting-ec2-instance"></a>

You can mount your file system from an Amazon EC2 instance.

**To mount your file system from Amazon EC2**

1. Connect to your Amazon EC2 instance.

1. Make a directory on your FSx for Lustre file system for the mount point with the following command.

   ```
   $ sudo mkdir -p /fsx
   ```

1. Mount the Amazon FSx for Lustre file system to the directory that you created. Use the following command and replace the following items:
   + Replace `file_system_dns_name` with the actual file system's DNS name.
   + Replace `mountname` with the file system's mount name. This mount name is returned in the `CreateFileSystem` API operation response. It's also returned in the response of the **describe-file-systems** AWS CLI command, and the [DescribeFileSystems](https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileSystems.html) API operation.

   ```
   sudo mount -t lustre -o relatime,flock file_system_dns_name@tcp:/mountname /fsx
   ```

    This command mounts your file system with two options, `-o relatime` and `flock`: 
   +  `relatime` – While the `atime` option maintains `atime` (inode access times) data for each time a file is accessed, the `relatime` option also maintains `atime` data, but not for each time that a file is accessed. With the `relatime` option enabled, `atime` data is written to disk only if the file has been modified since the `atime` data was last updated (`mtime`), or if the file was last accessed more than a certain amount of time ago (6 hours by default). Using either the `relatime` or `atime` option will optimize the [file release](file-release.md) processes.
**Note**  
If your workload requires precise access time accuracy, you can mount with the `atime` mount option. However, doing so can impact workload performance by increasing the network traffic required to maintain precise access time values.  
If your workload does not require metadata access time, using the `noatime` mount option to disable updates to access time can provide a performance gain. Be aware that `atime` focused processes like file release or releasing data validity will be inaccurate in their release.
   +  `flock` – Enables file locking for your file system. If you don't want file locking enabled, use the `mount` command without `flock`. 

1. Verify that the mount command was successful by listing the contents of the directory to which you mounted the file system, /mnt/fsx by using the following command.

   ```
   $ ls /fsx
   import-path  lustre
   $
   ```

   You can also use the `df` command, following.

   ```
   $ df
   Filesystem                    1K-blocks    Used  Available Use% Mounted on
   devtmpfs                        1001808       0    1001808   0% /dev
   tmpfs                           1019760       0    1019760   0% /dev/shm
   tmpfs                           1019760     392    1019368   1% /run
   tmpfs                           1019760       0    1019760   0% /sys/fs/cgroup
   /dev/xvda1                      8376300 1263180    7113120  16% /
   123.456.789.0@tcp:/mountname 3547698816   13824 3547678848   1% /fsx
   tmpfs                            203956       0     203956   0% /run/user/1000
   ```

   The results show the Amazon FSx file system mounted on /fsx.

# Configuring EFA clients
<a name="configure-efa-clients"></a>

Use the following procedures to set up your Lustre client to access an FSx for Lustre file system via Elastic Fabric Adapter (EFA).

EFA is supported on Lustre clients running the following operating systems:
+ Amazon Linux 2023 (AL2023)
+ Red Hat Enterprise Linux (RHEL) 9.5 or newer
+ Ubuntu 22.04 or newer with kernel version 6.8\$1

EFA is supported on Lustre clients listed below. For more information, see [Installing the Lustre client](install-lustre-client.md).

EFA is supported on Nitro v4 (or higher) EC2 instances that support EFA, excluding the trn2 instance family. See [Supported instance types](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa.html#efa-instance-types) in the *Amazon EC2 User Guide*.

**Topics**
+ [Step 1: Install required drivers](#install-required-drivers)
+ [Step 2: Configure EFA for the Lustre client](#install-efa-on-client)
+ [Step 3: EFA interfaces](#add-efa-interfaces)

## Step 1: Install required drivers
<a name="install-required-drivers"></a>

**Note**  
If you are using a [Deep Learning AMI](https://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html), you can skip this step as the Lustre client, EFA driver and NVIDIA GPUDirect Storage (GDS) driver are pre-installed.

### Install the Lustre client and EFA driver
<a name="install-lustre-client-efa-driver"></a>

**To quickly install the Lustre client and EFA driver**

1. Download and unzip the file containing the installation script:

   ```
   curl -O https://docs.aws.amazon.com/fsx/latest/LustreGuide/samples/install-fsx-lustre-client.zip
   unzip install-fsx-lustre-client.zip
   ```

1. Change to the `install-fsx-lustre-client` folder and run the installation script:

   ```
   cd install-fsx-lustre-client
   sudo ./bin/install-fsx-lustre-client.sh --install-lustre --install-efa
   ```

   The script automatically does the following:
   + Installs the Lustre client
   + Installs the EFA driver
   + Verifies the Lustre client and EFA driver installation

   For a list of options and usage examples you can use with the `install-fsx-lustre-client.sh` script, see the `README.md` file in the zip file.

### Install the GDS driver (optional)
<a name="install-gds-driver"></a>

This step is only required if you plan to use NVIDIA GPUDirect Storage (GDS) with FSx for Lustre.

Requirements:
+ Amazon EC2 P5, P5e, P5en, or P6-B200 instance
+ NVIDIA GDS driver version 2.24.2 or higher

**To install the NVIDIA GPUDirect Storage driver on your client instance**

1. Clone the NVIDIA GDS repository:

   ```
   git clone https://github.com/NVIDIA/gds-nvidia-fs.git
   ```

1. Build and install the driver:

   ```
   cd gds-nvidia-fs/src/
   export NVFS_MAX_PEER_DEVS=128
   export NVFS_MAX_PCI_DEPTH=16
   sudo -E make
   sudo insmod nvidia-fs.ko
   ```

## Step 2: Configure EFA for the Lustre client
<a name="install-efa-on-client"></a>

To access an FSx for Lustre file system using an EFA interface, you must install the Lustre EFA modules and configure EFA interfaces.

### Quick setup
<a name="quick-setup"></a>

**To quickly configure your Lustre client**

1. Connect to your Amazon EC2 instance.

1. Download and unzip the file containing the configuration script:

   ```
   curl -O https://docs.aws.amazon.com/fsx/latest/LustreGuide/samples/configure-efa-fsx-lustre-client.zip
   unzip configure-efa-fsx-lustre-client.zip
   ```

1. Change to the `configure-efa-fsx-lustre-client` folder and run the setup script:

   ```
   cd configure-efa-fsx-lustre-client
   # for regular IO
   sudo ./setup.sh
   
   # for NVIDIA GPUDirect Storage (GDS) IO
   sudo ./setup.sh --optimized-for-gds
   ```

   The script automatically does the following:
   + Imports Lustre modules
   + Configures TCP and EFA interfaces
   + Creates a systemd service for automatic configuration on reboot

   For a list of options and usage examples you can use with the `setup.sh` script, see the `README.md` file in the zip file.

### Managing the systemd service manually
<a name="manage-systemd-service"></a>

The systemd service file is created at /etc/systemd/system/configure-efa-fsx-lustre-client.service. The following are some helpful systemd-related commands:

```
# Check status
sudo systemctl status configure-efa-fsx-lustre-client.service

# View logs
sudo journalctl -u configure-efa-fsx-lustre-client.service
# View warnings/errors from dmesg
sudo dmesg
```

For more information, see the `README.md` file in the zip file.

### Auto-mount configuration (optional)
<a name="auto-mount-configuration"></a>

For information on automatically mounting your Amazon FSx for Lustre file system on boot, see [Mounting your Amazon FSx file system automatically](mount-fs-auto-mount-onreboot.md).

## Step 3: EFA interfaces
<a name="add-efa-interfaces"></a>

Each FSx for Lustre file system has a maximum limit of 1024 EFA connections across all client instances.

The `configure-efa-fsx-lustre-client.sh` script automatically configures EFA interfaces based on the instance type.


| Instance Type | Default Number of EFA Interfaces | 
| --- | --- | 
| p6e-gb200.36xlarge | 8 | 
| p6-b200.48xlarge | 8 | 
| p5en.48xlarge | 8 | 
| p5e.48xlarge | 8 | 
| p5.48xlarge | 8 | 
| Other instances with multiple network cards | 2 | 
| Other instances with a single network card | 1 | 

Each configured EFA interface on a client instance counts as one connection against the 1024 EFA connection limit when connected to an FSx for Lustre file system.

### Managing EFA interfaces manually
<a name="manage-interfaces-manually"></a>

Instances with more EFA interfaces typically support higher throughput. You can customize the number of interfaces to optimize performance for your specific workloads, as long as you stay within the total EFA connection limit.

You can manually manage EFA interfaces using the following commands:

1. View available EFA interfaces:

   ```
   for interface in /sys/class/infiniband/*; do
       if [ ! -e "$interface/device/driver" ]; then continue; fi
       driver=$(basename "$(realpath "$interface/device/driver")")
       if [ "$driver" != "efa" ]; then continue; fi
       echo $(basename $interface)
   done
   ```

1. View currently configured interfaces:

   ```
   sudo lnetctl net show
   ```

1. Add an EFA interface:

   ```
   sudo lnetctl net add --net efa --if device_name --peer-credits 32
   ```

   Replace *device\$1name* with an actual device name from the list in step 1.

1. Remove an EFA interface:

   ```
   sudo lnetctl net del --net efa --if device_name
   ```

   Replace *device\$1name* with an actual device name from the list in step 2.

# Mounting from Amazon Elastic Container Service
<a name="mounting-ecs"></a>

You can access your FSx for Lustre file system from an Amazon Elastic Container Service (Amazon ECS) Docker container on an Amazon EC2 instance. You can do so by using either of the following options:

1. By mounting your FSx for Lustre file system from the Amazon EC2 instance that is hosting your Amazon ECS tasks, and exporting this mount point to your containers.

1. By mounting the file system directly inside your task container.

For more information about Amazon ECS, see [What is Amazon Elastic Container Service?](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html) in the *Amazon Elastic Container Service Developer Guide*.

We recommend using option 1 ([Mounting from an Amazon EC2 instance hosting Amazon ECS tasks](#mounting-from-ecs-ec2)) because it provides better resource use, especially if you start many containers (more than five) on the same EC2 instance or if your tasks are short-lived (less than 5 minutes). 

Use option 2 ([Mounting from a Docker container](#mounting-from-docker)), if you're unable to configure the EC2 instance, or if your application requires the container's flexibility.

**Note**  
Mounting FSx for Lustre on an AWS Fargate launch type isn't supported.

The following sections describe the procedures for each of the options for mounting your FSx for Lustre file system from an Amazon ECS container.

**Topics**
+ [Mounting from an Amazon EC2 instance hosting Amazon ECS tasks](#mounting-from-ecs-ec2)
+ [Mounting from a Docker container](#mounting-from-docker)

## Mounting from an Amazon EC2 instance hosting Amazon ECS tasks
<a name="mounting-from-ecs-ec2"></a>

This procedure shows how you can configure an Amazon ECS on EC2 instance to locally mount your FSx for Lustre file system. The procedure uses `volumes` and `mountPoints` container properties to share the resource and make this file system accessible to locally running tasks. For more information, see [Launching an Amazon ECS Container Instance](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html) in the *Amazon Elastic Container Service Developer Guide*. 

This procedure is for an Amazon ECS-Optimized Amazon Linux 2 AMI. If you are using another Linux distribution, see [Installing the Lustre client](install-lustre-client.md).

**To mount your file system from Amazon ECS on an EC2 instance**

1. When launching Amazon ECS instances, either manually or using an Auto Scaling group, add the lines in the following code example to the end of the **User data** field. Replace the following items in the example:
   + Replace `file_system_dns_name` with the actual file system's DNS name.
   + Replace `mountname` with the file system's mount name.
   + Replace `mountpoint` with the file system's mount point, which you need to create.

   ```
   #!/bin/bash
   
   ...<existing user data>...
   
   fsx_dnsname=file_system_dns_name
   fsx_mountname=mountname
   fsx_mountpoint=mountpoint
   amazon-linux-extras install -y lustre
   mkdir -p "$fsx_mountpoint"
   mount -t lustre ${fsx_dnsname}@tcp:/${fsx_mountname} ${fsx_mountpoint} -o relatime,flock
   ```

1. When creating your Amazon ECS tasks, add the following `volumes` and `mountPoints` container properties in the JSON definition. Replace `mountpoint` with the file system's mount point (such as `/mnt/fsx`).

   ```
   {
       "volumes": [
              {
                    "host": {
                         "sourcePath": "mountpoint"
                    },
                    "name": "Lustre"
              }
       ],
       "mountPoints": [
              {
                    "containerPath": "mountpoint",
                    "sourceVolume": "Lustre"
              }
       ],
   }
   ```

## Mounting from a Docker container
<a name="mounting-from-docker"></a>

The following procedure shows how you can configure an Amazon ECS task container to install the `lustre-client` package and mount your FSx for Lustre file system in it. The procedure uses an Amazon Linux (`amazonlinux`) Docker image, but a similar approach can work for other distributions.

**To mount your file system from a Docker container**

1. On your Docker container, install the `lustre-client` package and mount your FSx for Lustre file system with the `command` property. Replace the following items in the example:
   + Replace `file_system_dns_name` with the actual file system's DNS name.
   + Replace `mountname` with the file system's mount name.
   + Replace `mountpoint` with the file system's mount point.

   ```
   "command": [
     "/bin/sh -c \"amazon-linux-extras install -y lustre; mount -t lustre file_system_dns_name@tcp:/mountname mountpoint -o relatime,flock;\""
   ],
   ```

1. Add `SYS_ADMIN` capability to your container to authorize it to mount your FSx for Lustre file system, using the `linuxParameters` property.

   ```
   "linuxParameters": {
     "capabilities": {
         "add": [
           "SYS_ADMIN"
         ]
      }
   }
   ```

# Mounting Amazon FSx file systems from on-premises or a peered Amazon VPC
<a name="mounting-on-premises"></a>

You can access your Amazon FSx file system in two ways. One is from Amazon EC2 instances located in an Amazon VPC that's peered to the file system's VPC. The other is from on-premises clients that are connected to your file system's VPC using Direct Connect or VPN.

You connect the client's VPC and your Amazon FSx file system's VPC using either a VPC peering connection or a VPC transit gateway. When you use a VPC peering connection or transit gateway to connect VPCs, Amazon EC2 instances that are in one VPC can access Amazon FSx file systems in another VPC, even if the VPCs belong to different accounts.

Before using the following the procedure, you need to set up either a VPC peering connection or a VPC transit gateway. 

A *transit gateway* is a network transit hub that you can use to interconnect your VPCs and on-premises networks. For more information about using VPC transit gateways, see [Getting Started with Transit Gateways](https://docs.aws.amazon.com/vpc/latest/tgw/tgw-getting-started.html) in the *Amazon VPC Transit Gateways Guide*.

A *VPC peering connection* is a networking connection between two VPCs. This type of connection enables you to route traffic between them using private Internet Protocol version 4 (IPv4) or Internet Protocol version 6 (IPv6) addresses. You can use VPC peering to connect VPCs within the same AWS Region or between AWS Regions. For more information on VPC peering, see [What is VPC Peering?](https://docs.aws.amazon.com/vpc/latest/peering/Welcome.html) in the *Amazon VPC Peering Guide*.

You can mount your file system from outside its VPC using the IP address of its primary network interface. The primary network interface is the first network interface returned when you run the `aws fsx describe-file-systems` AWS CLI command. You can also get this IP address from the Amazon Web Services Management Console.

The following table illustrates IP address requirements for accessing Amazon FSx file systems using a client that's outside of the file system's VPC.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/fsx/latest/LustreGuide/mounting-on-premises.html)

If you need to access your Amazon FSx file system that was created before December 17, 2020 using a non-private IP address range, you can create a new file system by restoring a backup of the file system. For more information, see [Protecting your data with backups](using-backups-fsx.md).

**To retrieve the IP address of the primary network interface for a file system**

1. Open the Amazon FSx console at [https://console.aws.amazon.com/fsx/](https://console.aws.amazon.com/fsx/).

1. In the navigation pane, choose **File systems**.

1. Choose your file system from the dashboard.

1. From the file system details page, choose **Network & security**.

1. For **Network interface**, choose the ID for your primary elastic network interface. Doing this takes you to the Amazon EC2 console.

1. On the **Details** tab, find the **Primary private IPv4 IP**. This is the IP address for your primary network interface.

**Note**  
You can't use Domain Name System (DNS) name resolution when mounting an Amazon FSx file system from outside the VPC it is associated with.

# Mounting your Amazon FSx file system automatically
<a name="mount-fs-auto-mount-onreboot"></a>

 You can update the `/etc/fstab` file in your Amazon EC2 instance after you connect to the instance for the first time so that it mounts your Amazon FSx file system each time it reboots.

## Using /etc/fstab to mount FSx for Lustre automatically
<a name="lustre-mount-fs-auto-mount-update-fstab"></a>

To automatically mount your Amazon FSx file system directory when the Amazon EC2 instance reboots, you can use the `fstab` file. The `fstab` file contains information about file systems. The command `mount -a`, which runs during instance startup, mounts the file systems listed in the `fstab` file.

**Note**  
Before you can update the `/etc/fstab` file of your EC2 instance, make sure that you've already created your Amazon FSx file system. For more information, see [Step 1: Create your FSx for Lustre file system](getting-started.md#getting-started-step1) in the Getting Started exercise.
For EFA-enabled file systems, configuring systemd is a pre-requisite. For more information, see [Quick setup](configure-efa-clients.md#quick-setup).

**To update the /etc/fstab file in your EC2 instance**

1. Connect to your EC2 instance, and open the `/etc/fstab` file in an editor.

1. Add the following line to the `/etc/fstab` file.

   Mount the Amazon FSx for Lustre file system to the directory that you created. Use the following command and replace the following:
   + Replace *`/fsx`* with the directory that you want to mount your Amazon FSx file system to.
   + Replace `file_system_dns_name` with the actual file system's DNS name.
   + Replace `mountname` with the file system's mount name. This mount name is returned in the `CreateFileSystem` API operation response. It's also returned in the response of the **describe-file-systems** AWS CLI command, and the `[DescribeFileSystems](https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileSystems.html)` API operation.

   **For non-EFA file systems:**

   ```
   file_system_dns_name@tcp:/mountname /fsx lustre defaults,relatime,flock,_netdev,x-systemd.automount,x-systemd.requires=network.service 0 0
   ```

   **For EFA-enabled file systems:**

   ```
   file_system_dns_name@tcp:/mountname /fsx lustre defaults,relatime,flock,_netdev,x-systemd.automount,x-systemd.requires=configure-efa-fsx-lustre-client.service,x-systemd.after=configure-efa-fsx-lustre-client.service 0 0
   ```
**Warning**  
Use the `_netdev` option, used to identify network file systems, when mounting your file system automatically. If `_netdev` is missing, your EC2 instance might stop responding. This result is because network file systems need to be initialized after the compute instance starts its networking. For more information, see [Automatic mounting fails and the instance is unresponsive](mount-troubleshooting.md#lustre-automount-fails).

1. Save the changes to the file.

Your EC2 instance is now configured to mount the Amazon FSx file system whenever it restarts.

**Note**  
In some cases, your Amazon EC2 instance might need to start regardless of the status of your mounted Amazon FSx file system. In these cases, add the `nofail` option to your file system's entry in your `/etc/fstab` file.

The fields in the line of code that you added to the `/etc/fstab` file do the following.


| Field | Description | 
| --- | --- | 
|  `file_system_dns_name@tcp:/`  |  The DNS name for your Amazon FSx file system, which identifies the file system. You can get this name from the console or programmatically from the AWS CLI or an AWS SDK.  | 
|  `mountname`  | The mount name for the file system. You can get this name from the console or programmatically from the AWS CLI using the **describe-file-systems** command or the AWS API or SDK using the `[DescribeFileSystems](https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileSystems.html)` operation. | 
|  `/fsx`  |  The mount point for the Amazon FSx file system on your EC2 instance.  | 
|  `lustre`  |  The type of file system, Amazon FSx.  | 
|  `mount options`  |  Mount options for the file system, presented as a comma-separated list of the following options: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/fsx/latest/LustreGuide/mount-fs-auto-mount-onreboot.html)  | 
|  `x-systemd.automount,x-systemd.requires=network.service`  |  These options for non-EFA file systems ensure that the auto mounter does not run until the network connectivity is online. For Amazon Linux 2023 and Ubuntu 22.04 and higher, use the `x-systemd.requires=systemd-networkd-wait-online.service` option instead of the `x-systemd.requires=network.service` option.  | 
|  `x-systemd.automount,x-systemd.requires=configure-efa-fsx-lustre-client.service,x-systemd.after=configure-efa-fsx-lustre-client.service`  |  These options for EFA-enabled file systems ensure that the auto mounter does not run until after EFA client configuration completes.  | 
|  `0`  |  A value that indicates whether the file system should be backed up by `dump`. For Amazon FSx, this value should be `0`.  | 
|  `0`  |  A value that indicates the order in which `fsck` checks file systems at boot. For Amazon FSx file systems, this value should be `0` to indicate that `fsck` should not run at startup.  | 

# Mounting specific filesets
<a name="mounting-from-fileset"></a>

By using the Lustre fileset feature, you can mount only a subset of the file system namespace, which is called a *fileset*. To mount a fileset of the file system, on the client you specify the subdirectory path after the file system name. A fileset mount (also called a subdirectory mount) limits the file system namespace visibility on a specific client.

**Example – Mount a Lustre fileset**

1. Assume you have an FSx for Lustre file system with the following directories:

   ```
   team1/dataset1/
   team2/dataset2/
   ```

1. You mount only the `team1/dataset1` fileset, making only this part of the file system visible locally on the client. Use the following command and replace the following items:
   + Replace `file_system_dns_name` with the actual file system's DNS name.
   + Replace `mountname` with the file system's mount name. This mount name is returned in the `CreateFileSystem` API operation response. It's also returned in the response of the **describe-file-systems** AWS CLI command, and the [DescribeFileSystems](https://docs.aws.amazon.com/fsx/latest/APIReference/API_DescribeFileSystems.html) API operation.

   ```
   mount -t lustre file_system_dns_name@tcp:/mountname/team1/dataset1 /fsx
   ```

When using the Lustre fileset feature, keep the following in mind:
+ There are no constraints preventing a client from remounting the file system using a different fileset, or no fileset at all.
+ When using a fileset, some Lustre administrative commands requiring access to the `.lustre/` directory may not work, such as the `lfs fid2path` command.
+ If you plan to mount several subdirectories from the same file system on the same host, be aware that this consumes more resources than a single mount point, and it could be more efficient to mount the file system root directory only once instead.

For more information on the Lustre fileset feature, see the *Lustre Operations Manual* on the [Lustre documentation website](https://doc.lustre.org/lustre_manual.xhtml#SystemConfigurationUtilities.fileset).

# Unmounting file systems
<a name="unmounting-fs"></a>

Before deleting an FSx for Lustre file system, ensure it is unmounted from all Amazon EC2 instances that have mounted it, and before shutting down or terminating any Amazon EC2 instance, ensure any mounted FSx for Lustre file systems are unmounted from that instance.

FSx for Lustre servers grant temporary file and directory locks to clients during I/O operations, and clients must respond promptly when servers ask clients to release their locks to unblock I/O operations from other clients. If clients become non-responsive, they may be forcefully evicted after several minutes to allow other clients to proceed with their requested I/O operations. To avoid these waiting periods, you should always unmount the file system from client instances before shutting down or terminating them, and before deleting FSx for Lustre file systems.

You can unmount a file system on your Amazon EC2 instance by running the `umount` command on the instance itself. You can't unmount an Amazon FSx file system through the AWS CLI, the AWS Management Console, or through any of the AWS SDKs. To unmount an Amazon FSx file system connected to an Amazon EC2 instance running Linux, use the `umount` command as follows:

```
umount /mnt/fsx 
```

We recommend that you do not specify any other `umount` options. Avoid setting any other `umount` options that are different from the defaults.

You can verify that your Amazon FSx file system has been unmounted by running the `df` command. This command displays the disk usage statistics for the file systems currently mounted on your Linux-based Amazon EC2 instance. If the Amazon FSx file system that you want to unmount isn’t listed in the `df` command output, this means that the file system is unmounted.

**Example – Identify the mount status of an Amazon FSx file system and unmount it**  

```
$ df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on 
file-system-id.fsx.aws-region.amazonaws.com@tcp:/mountname /fsx 3547708416 61440 3547622400 1% /fsx
      /dev/sda1 ext4 8123812 1138920 6884644 15% /
```

```
$ umount /fsx
```

```
$ df -T 
```

```
Filesystem Type 1K-blocks Used Available Use% Mounted on 
/dev/sda1 ext4 8123812 1138920 6884644 15% /
```

# Working with Amazon EC2 Spot Instances
<a name="working-with-ec2-spot-instances"></a>

FSx for Lustre can be used with EC2 Spot Instances to significantly lower your Amazon EC2 costs. A Spot Instance is an unused EC2 instance that is available for less than the On-Demand price. Amazon EC2 can interrupt your Spot Instance when the Spot price exceeds your maximum price, when the demand for Spot Instances rises, or when the supply of Spot Instances decreases.

When Amazon EC2 interrupts a Spot Instance, it provides a Spot Instance interruption notice, which gives the instance a two-minute warning before Amazon EC2 interrupts it. For more information, see [Spot Instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html) in the *Amazon EC2 User Guide*. 

To ensure that Amazon FSx file systems are unaffected by EC2 Spot Instances Interruptions, we recommend unmounting Amazon FSx file systems prior to terminating or hibernating EC2 Spot Instances. For more information, see [Unmounting file systems](unmounting-fs.md). 

## Handling Amazon EC2 Spot Instance interruptions
<a name="handling-ec2-spot-interruptions-in-fsx"></a>

 FSx for Lustre is a distributed file system where server and client instances cooperate to provide a performant and reliable file system. They maintain a distributed and coherent state across both client and server instances. FSx for Lustre servers delegate temporary access permissions to clients while they are actively doing I/O and caching file system data. Clients are expected to reply in a short period of time when servers request them to revoke their temporary access permissions. To protect the file system against misbehaving clients, servers can evict Lustre clients that do not respond after a few minutes. To avoid having to wait multiple minutes for a non-responding client to reply to the server request, it is important to cleanly unmount Lustre clients, especially before terminating EC2 Spot Instances. A clean unmount is initiated by using the `umount` command without `-f` or `-l`. 

 If Lustre clients are shut down without cleanly unmounting the file system, other clients using that file system are likely to experience temporarily increased latency, hanging operations, or I/O errors. 

 EC2 Spot sends termination notices 2 minutes in advance before shutting down an instance. We recommend that you automate the process of cleanly unmounting Lustre clients before terminating EC2 Spot Instances. 

**Example – Script to cleanly unmount terminating EC2 Spot Instances**  
This example script cleanly unmounts terminating EC2 Spot Instances by doing the following:  
+ Watches for Spot termination notices.
+ When it receives a termination notice:
  + Stop applications that are accessing the file system.
  + Unmounts the file system before the instance is terminated.
You can adapt the script as needed, especially for gracefully shutting down your application. For more information about best practices for handling Spot Instance interruptions, see [ Best practices for handling EC2 Spot Instance interruptions](https://aws.amazon.com/blogs//compute/best-practices-for-handling-ec2-spot-instance-interruptions/).  
It can take time for a Lustre client to unmount a file system. If you mount many file systems on the same Amazon EC2 Spot Instance, it may take too long to unmount all of them within the two-minute Spot termination notice window. If you need to mount a large number of file systems on one host, we recommend using On-Demand Instances to avoid issues with unclean unmounts due to Amazon EC2 Spot Instance interruptions.

```
#!/bin/bash

# TODO: Specify below the FSx mount point you are using
*FSXPATH=/fsx*

cd /

TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
if [ "$?" -ne 0 ]; then
    echo "Error running 'curl' command" >&2
    exit 1
fi

# Periodically check for termination
while sleep 5
do

    HTTP_CODE=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s -w %{http_code} -o /dev/null http://169.254.169.254/latest/meta-data/spot/instance-action)

    if [[ "$HTTP_CODE" -eq 401 ]] ; then
        # Refreshing Authentication Token
        TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 30")
        continue
    elif [[ "$HTTP_CODE" -ne 200 ]] ; then
        # If the return code is not 200, the instance is not going to be interrupted
        continue
    fi

    echo "Instance is getting terminated. Clean and unmount '$FSXPATH' ..."
    curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/spot/instance-action
    echo

    # Gracefully stop applications accessing the filesystem
    #
    # TODO*: Replace with the proper command to stop your application if possible*

    # Kill every process still accessing Lustre filesystem
    echo "Kill every process still accessing Lustre filesystem..."
    fuser -kMm -TERM "${FSXPATH}"; sleep 2
    fuser -kMm -KILL "${FSXPATH}"; sleep 2

    # Unmount FSx For Lustre filesystem
    if ! umount -c "${FSXPATH}"; then
        echo "Error unmounting '$FSXPATH'. Processes accessing it:" >&2
        lsof "${FSXPATH}"

        echo "Retrying..."
        continue
    fi

    # Start a graceful shutdown of the host
    shutdown now

done
```