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

Can I mount two different folders in one EC2 instance?


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?


Solution

  • 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.