How to install AWS EFS on RHEL (Updated 2021)

This guide will show you how to install AWS EFS using EFS-Helper on RHEL. Additionally, you will see how to use the AWS EC2 user data field to auto-configure your RHEL instance.

Let's get started!

You will need to modify the script below and replace fs-MY_EFS_ID with your EFS storage id. The script also assumes your security groups are correctly configured, allowing inbound traffic.

Lastly, Stunnel may be updated when you run this script. Therefore, the script may not work if you download a version that is no longer available. Visit Stunnel downloads to confirm the latest version and then update the script accordingly.

It would be best if you also modify the hostname to be more suitable for your environment.

The AWS EFS install script for RHEL

The script below will install AWS EFS on your RHEL instance:

sudo hostnamectl set-hostname --static testwebserver.localdomain
cd /home/ec2-user/ || exit
sudo yum -y update
sudo yum -y install git
sudo git clone
sudo yum -y install rpm-build
cd /home/ec2-user/efs-utils/ || exit
sudo make rpm
sudo yum -y install build/amazon-efs-utils*rpm
sudo yum -y install gcc openssl-devel tcp_wrappers-devel
sudo curl -o stunnel-5.44.tar.gz
sudo tar xvfz stunnel-5.44.tar.gz
cd stunnel-5.44 || exit
sudo make install
if [[ -f /bin/stunnel ]]; then
sudo mv /bin/stunnel /root
sudo ln -s /usr/local/bin/stunnel /bin/stunnel
cd / || exit
sudo mkdir efs
sudo mount -t efs -o tls fs-MY_EFS_ID:/ efs
sudo echo $'Gofs-MY_EFS_ID /efs efs defaults,_netdev 0 0\E:x\n' | sudo vi /etc/fstab

Run the script via AWS EC2 user data

You can also run the script via AWS EC2 user data if you wish the instance to be auto-configured with your EFS mount. To do this, add this script in the user data field on the 'configure instance details' page when launching a new instance.

Example of the user data field under advanced details when configuring an AWS EC2 instance:

Configure Instance Details User Data
Configure Instance Details page with User Data field

Frequently asked questions

What is Stunnel?

Stunnel (“Secure Tunnel”) is a cross-platform proxy application designed for clients and servers. Additionally, Stunnel uses the OpenSSL library for cryptography.

What is AWS EFS?

AWS Amazon Elastic File System (EFS) automatically grows and shrinks as you add and remove files. With AWS EFS, there is no need for management or provisioning.

What is AWS EFS Helper?

The AWS EFS (mount) helper helps you mount your EFS file systems. It includes the AWS EFS recommended options by default. Additionally, the mount helper has built-in logging for troubleshooting purposes.

What is AWS User Data?

You have the option of passing user data to an AWS EC2 instance when launching it. In addition, the user data field can perform common automated configuration tasks and even run scripts after the instance starts.

You may also be interested in

About the Authors

Anto's editorial team loves the cloud as much as you! Each member of Anto's editorial team is a Cloud expert in their own right. Anto Online takes great pride in helping fellow Cloud enthusiasts. Let us know if you have an excellent idea for the next topic! Contact Anto Online if you want to contribute.

Support the Cause

Support Anto Online and buy us a coffee. Anything is possible with coffee and code.

Buy me a coffee

Leave a Reply

Your email address will not be published. Required fields are marked *