Mount EFS on Amazon Linux
- Published on
- 3 mins read
So, you have created an EFS volume and now you want to mount it on your Amazon Linux instance. This tutorial will show you how to do that.
Prerequisites
Check if the EFS volume is created and available.
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:0 0 20G 0 disk
├─nvme0n1p1 259:1 0 20G 0 part /
├─nvme0n1p127 259:2 0 1M 0 part
└─nvme0n1p128 259:3 0 10M 0 part
nvme1n1 259:4 0 20G 0 disk
├─nvme1n1p1 259:5 0 19.9G 0 part
├─nvme1n1p14 259:6 0 4M 0 part
└─nvme1n1p15 259:7 0 106M 0 part
We can notice that nvme1n1 is the EFS volume which has not been mounted yet.
We also need to know the device name of the EFS volume. We can get that from the AWS console.
In the above case it's /dev/sdf
Mounting the EFS volume
First, we need to create a directory where we want to mount the EFS volume.
$ sudo mkdir /mnt/data
Before we mount, we need to check if the EFS volume is correctly formatted. If not, we need to format it.
$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1
├─nvme0n1p1 xfs / 0e39c519-1802-45f1-9bf8-61f5bbd358bd 1.7G 92% /
├─nvme0n1p127
└─nvme0n1p128 vfat FAT16 ECFE-5555
nvme1n1
├─nvme1n1p1 ext4 1.0 cloudimg-rootfs cda0c0a7-e64a-4413-85a5-a0235f6f567f
├─nvme1n1p14
└─nvme1n1p15 vfat FAT32 UEFI 54D6-C8B8
We can see that its fstype is ext4
, we will convert it to xfs
in our case.
sudo mkfs -t xfs /dev/sdf
If the above command fails and ask for force, we can use the -f
flag to force the format.
sudo mkfs -t xfs -f /dev/sdf
Now, mount the EFS volume to the directory we created earlier.
sudo mount /dev/sdf /mnt/data
Done!! Now, we can check if the EFS volume is mounted.
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 3.1G 8.5M 3.1G 1% /run
/dev/nvme0n1p1 20G 19G 1.7G 92% /
tmpfs 7.7G 0 7.7G 0% /tmp
tmpfs 1.6G 28K 1.6G 1% /run/user/1000
/dev/nvme1n1 20G 175M 20G 1% /mnt/data
We can see that the EFS volume is mounted to /mnt/data
.
Note: if the
mkfs
fails sayingmkfs.xfs
not foundrun
sudo yum install xfsprogs
and try again.
Thanks for reading. If you have any questions, please let me know.