Using the EFS mount helper to automatically re-mount EFS file systems

To Nha Notes | Dec. 11, 2022, 1:35 p.m.

Use the EFS mount helper to configure the /etc/fstab on EC2 Linux instances to automatically remount your EFS file systems when the instance re-starts.

echo "${EFS_ID}.efs.ap-northeast-1.amazonaws.com:/ /path/to/data nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,_netdev 0 0" >> /etc/fstab

We can also use systemd to automatically remount NVME disk

Create systemd file /etc/systemd/system/data.mount with below content

[Unit]

Description=Data mount

[Mount]

What=/dev/nvme1n1
Where=/data
Type=xfs
Options=defaults


[Install]
WantedBy=multi-user.target

Enable data.mount on reboot

systemctl enable data.mount

Reboot the node and check for the status of the mount service unit.
shutdown -r now
References

https://docs.aws.amazon.com/efs/latest/ug/automount-with-efs-mount-helper.html

https://www.thegeekdiary.com/how-to-auto-mount-a-filesystem-using-systemd/

https://superuser.com/questions/1399763/how-to-disable-systemd-auto-unmount-of-manually-mounted-partitions