I am having an issue where I am unable to mount my EFS on red hat ec2 instance using the DNS names. It throws the error
mount.nfs4: Failed to resolve server us-east-1a.fs-c2aXXXX.efs.us-east-1.amazon
aws.com: Name or service not known
I am following the instructions provided by AWS. I tried below two ways to do it and both throw the same above error. I can confirm that the DNS names are correct.
1st:
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-c2aXXXX.efs.us-east-1.amazonaws.com:/ efs
2nd:
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).fs-c2a7XXXX.efs.us-east-1.amazonaws.com:/ /efs
However, if I use IP instead of DNS names, I am able to mount it just fine. So below command works.
mount -t nfs4 -o
nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.38.X.XX:/ /efs
I am fine with using IP instead of DNS as long as I am able to mount it.
Now my issue is as soon as I stop and start the instance again, my mount is gone. Even after I add the below entry to the /etc/fstab, it doesn't do auto mount.
10.38.X.XXX:/ /efs efs defaults,_netdev 0 0
Can someone please help me in either resolving the issue with DNS or tell me how to auto mount using IPs?
To attach to EFS from the command line use this as your template, replacing fs-12345678
with your id:
$ sudo mount -t efs fs-12345678:/ /efs
Use this in your /etc/fstab
(do not add .efs.us-east-1.amazonaws.com
after it)
fs-12345678:/ /efs efs vers=4.1,rw,tls,_netdev,relatime,acl,nofail 0 0
The fstab
version also turns on encryption for data transport. Check out the resource for more information
Resources
https://docs.aws.amazon.com/efs/latest/ug/mounting-fs.html https://docs.aws.amazon.com/efs/latest/ug/troubleshooting-efs-mounting.html#automount-fails