Skip to content

Instantly share code, notes, and snippets.

@drewyangdev
Last active April 15, 2024 22:21
Show Gist options
  • Save drewyangdev/8e75be22fa75747c80626ddbbb3699bf to your computer and use it in GitHub Desktop.
Save drewyangdev/8e75be22fa75747c80626ddbbb3699bf to your computer and use it in GitHub Desktop.
Mount EFS or EFS AccessPoint on an EC2 instance
#!/bin/bash
## e.g sudo bash mount_efs.sh xxx.xxx.xxx.xxx /mnt/xxx
export EFS_IP=$1 # EFS network section, private IP within subnet
export MOUNT_DIR=$2
if [ ! -d "$MOUNT_DIR" ]; then
mkdir -p $MOUNT_DIR
fi
mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport $EFS_IP:/ $MOUNT_DIR
df -Th
#!/bin/bash
## e.g sudo bash mount_efs.sh fs-xxxxx fsap-xxxxx /mnt/xxxxxx
export EFS_ID=$1
export EFS_AP_ID=$2
export MOUNT_DIR=$3
if [ ! -d "$MOUNT_DIR" ]; then
mkdir -p $MOUNT_DIR
fi
mount -t efs -o tls,accesspoint=$EFS_AP_ID $EFS_ID $MOUNT_DIR
df -Th
#!/bin/bash
## e.g sudo bash mount_efs_prepare.sh
sudo apt-get update
## Release 2.0 build slow, will wait to see if there is any improvement:
## https://github.com/aws/efs-utils/issues/204
# apt-get -y install git binutils rustc cargo pkg-config libssl-dev
# git clone https://github.com/aws/efs-utils /tmp/efs-utils
## Before release 2.0
sudo apt-get -y install git binutils
git clone https://github.com/aws/efs-utils /tmp/efs-utils
cd /tmp/efs-utils
git checkout ddc2bd0684e8baee11907923fccd64d8e19ea83a
./build-deb.sh
sudo apt-get -y install ./build/amazon-efs-utils*deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment