How to mount AWS EFS storage in existing AWS EC2 instance using amazon-efs-utils package?
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
Today we are going to discuss, how to mount AWS EFS storage in existing AWS EC2 instance using amazon-efs-utils package.
In the last blog post, we have shown how to create and mount AWS EFS storage to a new AWS EC2 instance automatically using EC2 user data. Today we learn how to mount an EFS storage manually to an existing EC2 instance using amazon-efs-utils package.
What is amazon-efs-utils package?
The amazon-efs-utils package is an open-source collection of Amazon EFS tools that is also referred to as the Amazon EFS client. The Amazon EFS client includes the EFS mount helper, which makes it easier to mount EFS file systems. Using the EFS client enables the ability to use Amazon CloudWatch to monitor an EFS file system’s mount status. You need to install the Amazon EFS client on an Amazon EC2 instance prior to mounting an EFS file system.
How to install amazon-efs-utils?
Install amazon-efs-utils on Amazon Linux, Red Hat Linux, CentOS, and similar OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
###################################### ## Install amazon-efs-utils package ## ###################################### ## --------------------------------------------------- ## Amazon Linux, Red Hat Linux, CentOS, and similar OS ## --------------------------------------------------- ## Update all the packages sudo yum -y update ## Install git sudo yum -y install git ## Install the rpm-build package sudo yum -y install rpm-build ## Clone amazon-efs-utils source code git clone https://github.com/aws/efs-utils cd efs-utils ## Install the bash make command sudo yum -y install make ## Build the amazon-efs-utils package sudo make rpm ## Install amazon-efs-utils sudo yum -y install ./build/amazon-efs-utils*rpm ## amazon-efs-utils require botocore to be installed pip3 install botocore |
Install amazon-efs-utils on Ubuntu, Debian, and similar OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
## ------------------------------ ## Ubuntu, Debian, and similar OS ## ------------------------------ ## Update all your existing packages sudo apt-get update ## Install git and binutils sudo apt-get -y install git binutils ## Clone amazon-efs-utils source code git clone https://github.com/aws/efs-utils cd efs-utils ## Build the amazon-efs-utils package ./build-deb.sh ## Install amazon-efs-utils sudo apt-get -y install ./build/amazon-efs-utils*deb ## amazon-efs-utils require botocore to be installed pip3 install botocore |
Now you are ready to mount the EFS storage to your EC2 instance.
How to mount AWS EFS storage using amazon-efs-utils package?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
####################################### ## Mount AWS EFS to AWS EC2 Instance ## ####################################### ## Create a directory efs that you will use as the file system mount point sudo mkdir efs ## Mount efs file system to your EC2 instance ## Using EFS_FILES_SYSTEM_ID ## sudo mount -t efs file-system-id efs-mount-point/ sudo mount -t efs ## Using EFS_FILE_SYSTEM_DNS_NAME ## sudo mount -t efs -o tls file-system-dns-name efs-mount-point/ sudo mount -t efs -o tls ## Using ## sudo mount -t efs -o tls,mounttargetip=mount-target-ip file-system-id efs-mount-point/ sudo mount -t efs -o tls,mounttargetip= |
You can also get the exact command from the AWS management console. Login to AWS management console and navigate to EFS, click “Attach” and it will display the command to attach the EFS storage.
Hope you have enjoyed this article. To get more details in AWS EFS, please refer the below documentation
https://docs.aws.amazon.com/efs/index.html