I'm trying to mount an EFS volume with NFS on macOS, but am having permissions trouble. I am running the following command to mount the volume:
sudo mount -t nfs -o vers=4 -o tcp -w <IP Address>:/ efs/
and am able to successfully mount the volume, but it mounts with root privileges, and I need to be able to grant access to the volume to the local user. I need the local user to be able to both read and write to the volume.
Trying to chown -R $(whoami) ./efs results in an Unknown error: 10039.
I can successfully chmod 666 the files inside of the mount (sometimes with odd behaviors), but I ultimately need to just grant the local user write access to the volume.
Am I missing an option in the mount command or does anyone know how to mount the efs volume and provide the local user permissions to it?
I want to set up AWS Batch running few python scripts to do some batch operations on file fetched from S3 and post processing they need to be saved to a volume.
For this I want to configure compute environments in AWS batch.
I wish to use spot instances but i need my EBS volume to be there even after instance is terminated and if new instance is spin up it has to mount same volume as used before.
Create a instance-template, provide a bootstrap script, for the mentioned case something like:
sudo mkdir -p /<any directory name where volume will be mounted eg: dir>
aws ec2 attach-volume --volume-id <volume_id> --instance-id $(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id) --device /dev/sdf
sudo mount /dev/sdf /<above mentioned dir rg :dir>
in AWS batch definition, use the above template to launch your ec2 machine.
I have created a task definition and mounted EFS but i'm not sure if it works..
So i wanted to verify if my EFS file system is mounted to the running container ?
How can i verify ?
One way is to add a file to the folder inside your container:
ssh into the underlying ECS EC2 instance with ssh -i "somekey.pem" ec2-user#ec2-xxxxxxxxx.eu-west-1.compute.amazonaws.com
Run docker ps to get the id of your container.
docker exec -it CONTAINERID /bin/bash to move inside the container. Inside the container create or copy a file to the EFS-folder.
Now go to the EFS console and verify that the Metered size is greater than 0 meaning your file is in EFS.
You can run a command df -h which will list your mounted volumes on linux machines.
I created an EC2 instance and an EFS, and was able to mount EFS properly on the instance.
I need to auto mount in case the server is rebooted.
According to the documentation, i do that following in /etc/fstab
fs-xxxxxxxx:/ /mnt/efs efs defaults,_netdev 0 0
Using the EFS file system ID in place of xxxxxxxx
But when I reboot the server, EFS does not get mounted, and I save to remount it again
What should I do here?
I'm posting here a more detailed solution since this thread seems to show up near the top for related queries from search engine.
There are two methods to mount an Amazon EFS: "Amazon EFS mount helper" (amazon-efs-utils) and "NFS client" (nfs-utils).
Examples below shows how to mount manually and automatically with each method. Before using, replace the text [value] with your own values.
==============================
===============
Mounting with "Amazon EFS mount helper"
===============
To mount with "Amazon EFS mount helper" manually, you issue the following command format into CLI:
sudo mount -t efs [fs-XXXXXXXX]:/ /path/to/mount/dir
=====
To mount with "Amazon EFS mount helper" automatically, you insert the following line into /etc/fstab
[fs-XXXXXXXX]:/ /path/to/mount/dir efs defaults,_netdev 0 0
===============
Mounting with "NFS client"
===============
To mount with "NFS client" manually, you issue either of the following command format into CLI:
Use the command instruction given from "Amazon EC2 mount instructions (from local VPC)" when you click in to view the Elastic File System ID in question under EFS Web Console.
sudo mount -t nfs4 -o nfsvers=4.1,rsize=XXXXXXX,wsize=XXXXXXX,hard,timeo=XXX,retrans=X,noresvport [fs-XXXXXXXX].efs.[REGION].amazonaws.com:/ /path/to/mount/dir
OR
sudo mount -t nfs4 -o defaults,_netdev [fs-XXXXXXXX].efs.[REGION].amazonaws.com:/ /path/to/mount/dir
=====
To mount with "NFS client" automatically, you insert the following line into /etc/fstab
[fs-XXXXXXXX].efs.[REGION].amazonaws.com:/ /path/to/mount/dir nfs4 defaults,_netdev 0 0
==============================
Given the above example format, do you notice your problem?
You thought you've "Amazon EFS mount helper" installed, but based on the manual mount command format you posted in your first comment reply (not opening post), you actually only have "NFS client" installed on your system. You were using "Amazon EFS mount helper" format inside /etc/fstab to auto mount, but the manual mount command that worked for you is in "NFS client" format. Since your system doesn't have "Amazon EFS mount helper" installed, it doesn't understand the auto mount format inside /etc/fstab so auto mount it doesn't work for you.
The manual mount command you posted above that worked for you is only for "NFS client", not for "Amazon EFS mount helper".
mount -t nfs4 -o nfsvers=4.1 ...
Notice the -t parameter above is nfs4, which is the format for "NFS client". If you were using "Amazon EFS mount helper", the -t parameter should be efs.
To solve the problem, you can use either Amazon EFS mount helper (amazon-efs-utils) or NFS client (nfs-utils), but the command format (in CLI or /etc/fstab) and the mount client being used should be consistent.
In other words:
"Amazon EFS mount helper" <=> efs in both CLI and /etc/fstab
"NFS client" <=> nfs4 in both CLI and /etc/fstab
==============================
Installation instructions for mount client software:
===============
If you want to use "Amazon EFS mount helper", use the following installation instructions for Amazon Linux and Other Distros:
https://docs.aws.amazon.com/efs/latest/ug/using-amazon-efs-utils.html
=====
If you want to use "NFS client", use the following installation instructions on your EC2 instance:
On a Red Hat Enterprise Linux or SUSE Linux instance, including Amazon Linux, use this command:
sudo yum install -y nfs-utils
On an Ubuntu instance, use this command:
sudo apt-get install nfs-common
==============================
Once you have the mount client software installed, use the corresponding mounting instructions posted above.
To solve this using NFS4, please follow the instructions below:
On your AWS account, notice the following:
1) Go to your EFS management screen, you should your EFS_WHATEVER... and there is a small triangle next to it, click down to expand.
2) Notice there is a "DNS Name" right in the middle of the screen, it will say something like: "fs-1234567c.efs.us-west-1.amazonaws.com", note that down, this is your mounting point that we will use later on.
3) By default, if you have just created the new instance, then you must allow it to be seen by your servers, trying to connect will freeze since the firewall is blocking your connection. to allow this scroll down until you see your security group, this is something like sg-abcdef
4) Go into your EC2 servers, select the server that you want it to access your EFS and then click on its "security groups", it should take you into the security groups management screen, note down it's security group ID (this is something sg-12345)
4) Now, clear the filter of your VPC management screen to see all of the SGs...
5) Enter your EFS security group (i.e. sg-abcdef) and click the search button, this should bring up the EFS ACL
6) Click on "Inbound Rules" -> EDIT..
7) Click "ADD" and select "EFS" from the list, enter your server's SG (i.e. sg-12345) and describe it as "Server XXX access" if you like.
8) Now the server should be able to see the EFS Mount,
9) Go into your server and install the necessary components by running as ROOT:
apt-get install nfs-common
10) Now, to test the MOUNT, create a new directory... something like: mkdir /mnt/heider
11) Mount the FS using the following command:
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-1234567c.efs.us-west-1.amazonaws.com:/ /mnt/heider
Please note that your fs-12345c..... is taken from your DNS name as mentioned above.
12) If this work then great, move to the next step, otherwise revise the above to see if you missed anything.
13) Now to auto-mount this, you need to:
14) Edit /etc/fstab
15) Add the following:
fs-1234567c.efs.us-west-1.amazonaws.com:/ /mnt/heider nfs4 defaults,_netdev 0 0
16) Save the file and exit
17) in Linux command shell type:
mount -a
this will test the mounting, if it's mounted then great, rebooting would auto-mount it.
18) This should auto-mount.
19) Reboot to test, all should be there.
I hope this helps.
In order to use the efs file system type, I believe you need to have the amazon-efs-utils package installed. This will install the additional dependencies.
Anyone who has this issue,
instead of
fs-xxxxxxxx:/ /mnt/efs efs defaults,_netdev 0 0
use
{target_ip}:/ /mnt/efs nfs4 defaults,_netdev 0 0
This works fine for me, and it auto mounts on the newly created instances
I have already mounted AWS EFS one folder in EC2 instance. I want to mount another one folder in same AWS EFS. Is this possible?
You can use a Symbolic Link.
mkdir -p /mnt/efs
echo "${FileSystem}.efs.${AWS::Region}.amazonaws.com:/ /mnt/efs nfs4 defaults" >> /etc/fstab
mount -a
ln -s /var/www/html/media /mnt/efs/media
ln -s /var/www/html/var /mnt/efs/var
First your create a root directory for the mount point (/mnt/efs). Them you mount the FileSystem in this directory (/mnt/efs).
Now for example, if you want to map /var/www/html/media create a symbolic link pointing to the mounted point (ln -s /var/www/html/media /mnt/efs/media). This will create a folder in /mnt/efs/media.
It is possible to mount two different directories under file mount system. Initially in order to access your efs just mount a EFS root under your instance using the command
sudo mount -t efs fs-id:/ /home/efs
Then create subdirectories under the /home/efs folder for example let's have two subdirectories under /home/efs namely images and data.
Now you can mount two directories in your which is likely to be under /var/www/html/images and /var/www/html/data by adding the below in fstab file which will be under /etc/
fs-id:/images /var/www/html/images efs defaults,_netdev 0 0
fs-id:/data /var/www/html/data efs defaults,_netdev 0 0
And reboot your instance. Whatever changes in /var/www/html/data will gets reflected in fs-id:/data folder also the same applies for image folder also hope this helps. Initially you need to setup efs-utils in your instance.
I created symbolic link and it reflects in both sym link and main folder but does not reflect in another mounted server