Tag: amazon efs

  • Create Dummy Data in Amazon EFS

    Disk read/write speed in Amazon EFS depends on how much data you have on the file system.

    Amazon EFS have something called BurstCreditBalance, that shows much much data balance you have available. Initially all file system have some 2 TB Burst credit, this is is for you to copy data. If you don’t copy dummy data or real data, your file system performance will degrade after your Burst credit used up.

    Amazon EFS burst credit

    To create dummy data, run

    cd /path/to/efs
    mkdir dummy
    cd dummy
    dd if=/dev/zero of=dymmy-data-1 bs=1M count=1024 oflag=sync
    cp dymmy-data-1 dymmy-data-2
    cp dymmy-data-1 dymmy-data-3
    cp dymmy-data-1 dymmy-data-4
    cp dymmy-data-1 dymmy-data-5
    cp dymmy-data-1 dymmy-data-6
    cp dymmy-data-1 dymmy-data-7
    cp dymmy-data-1 dymmy-data-8
    cp dymmy-data-1 dymmy-data-9
    cp dymmy-data-1 dymmy-data-10
    cp dymmy-data-1 dymmy-data-11
    cp dymmy-data-1 dymmy-data-12
    cp dymmy-data-1 dymmy-data-13
    cp dymmy-data-1 dymmy-data-14
    cp dymmy-data-1 dymmy-data-15
    cp dymmy-data-1 dymmy-data-16
    cp dymmy-data-1 dymmy-data-17
    cp dymmy-data-1 dymmy-data-18
    

    See Amazon EFS

  • Amazon EFS

    Amazon EFS can be used to mount same drive on multiple EC2 instances allowing you to make the website scale on multiple web servers.

    To mount EFS drive on Ubuntu, you need to install

    apt-get -y install nfs-common

    To mount a EFS drive, run

    mkdir /efs
    mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-YOUR-ID.efs.us-east-1.amazonaws.com:/ /efs

    Here is fstab entry for auto-mounting the EFS file system on boot. In this example, the EFS filesystem is mounted as /efs directory.

    root@ip-10-0-0-224:~# cat /etc/fstab 
    LABEL=cloudimg-rootfs   /    ext4   defaults,discard    0 0
    fs-4fg8d351.efs.us-east-1.amazonaws.com:/ /efs nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0
    root@ip-10-0-0-224:~# 

    Or

    fs-a27131eb.efs.us-east-1.amazonaws.com:/ /efs nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev 0 0

    Connection Error and Security Group

    If you get an error like the following when trying to mount the EFS file system, you need to allow traffic between security groups used by EFS and EC2 on TCP port 2049.

    root@ip-172-31-39-189:~# mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2            fs-021c514bd4d641fb3.efs.eu-central-1.amazonaws.com:/ /efs
    mount.nfs4: Connection timed out for fs-021c514bd4d641fb3.efs.eu-central-1.amazonaws.com:/ on /efs
    root@ip-172-31-39-189:~# 

    To connect to EFS, you need to edit the security group associated with your EFS mount target. This, you can find by going to

    EFS > Network

    Here you will see all networks and associated security groups. Edit the security group and allow connection from the ec2 server security group

    Add an Inbound Rule:

    Type: NFS

    Protocol: TCP

    Port Range: 2049

    Source: Select the security group associated with your EC2 instance, or use 0.0.0.0/0 for testing (though for security reasons, using the security group of your EC2 instance is recommended).

    Security group associated with EC2 usually allows all outgoing traffic. If not, you may need to add a rule to allow traffic to EFS security group on TCP port 2049.

    Create Dummy Data in Amazon EFS