Search code examples
amazon-web-servicesamazon-ec2nfsamazon-efs

Why does the filesystem of AWS EFS mounted on EC2 instance appear as 127.0.0.1:/?


I have mounted an EFS on my EC2 instance:

ubuntu@ip-191-12-12-12:~/myapp/files$ df -h 
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        97G   36G   61G  38% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           785M  1.5M  784M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop0       26M   26M     0 100% /snap/amazon-ssm-agent/5656
/dev/loop1       25M   25M     0 100% /snap/amazon-ssm-agent/6312
/dev/loop3       56M   56M     0 100% /snap/core18/2697
/dev/loop4       50M   50M     0 100% /snap/snapd/18357
/dev/loop5       64M   64M     0 100% /snap/core20/1828
/dev/loop6       92M   92M     0 100% /snap/lxd/23991
/dev/loop7       92M   92M     0 100% /snap/lxd/24061
/dev/loop8       64M   64M     0 100% /snap/core20/1822
/dev/loop9       50M   50M     0 100% /snap/snapd/17950
127.0.0.1:/     8.0E   41M  8.0E   1% /home/ubuntu/myapp/files
tmpfs           785M   20K  785M   1% /run/user/124
tmpfs           785M  4.0K  785M   1% /run/user/1000
/dev/loop10      56M   56M     0 100% /snap/core18/2708

this line is the one:

127.0.0.1:/     8.0E   41M  8.0E   1% /home/ubuntu/myapp/files

I can confirm it works, but why is the Filesystem value 127.0.0.1:/?

It should be something like:

fs-043e64138b1234567.efs.ap-northeast-1.amazonaws.com:/  8.0E     0  8.0E   0% /home/ubuntu/myapp/files

where fs-043e64138b1234567 is the EFS id.

127.0.0.1:/ does not make any sense to me whatsoever.


Solution

  • I'm assuming you mounted using efs-utils. If that's the case, what's happening is that we start a stunnel service that listens on a local port and which forwards encrypted traffic to the mount target. Then, we mount your directory, /home/ubuntu/myapp/files, onto that local port. So, what ends up happening is that the NFS traffic is sent to the stunnel service listening on the local port, stunnel encrypts the NFS traffic it receives, and then forwards that traffic to your mount target (at which point EFS decrypts the traffic to interpret the NFS commands).