Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using same AWS EFS to share multiple directories

I have create a file system EFS and mount on a EC2 instance on /var/www/html/media. I would like to use the same EFS Filesystem to mount another directory /var/www/html/var.

Is that possible?

I would do:

fs-296e0282.efs.us-west-2.amazonaws.com:/media   /var/www/html/media   nfs4    defaults

fs-296e0282.efs.us-west-2.amazonaws.com:/var   /var/www/html/var   nfs4    defaults

But it seems not possible.

like image 520
p.magalhaes Avatar asked Dec 29 '25 21:12

p.magalhaes


1 Answers

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 media and var

Now you can mount two directories in /var/www/html/media and /var/www/html/var by adding the below in fstab file which will be under /etc/

fs-id:/media /var/www/html/media efs defaults,_netdev 0 0

fs-id:/var /var/www/html/var efs defaults,_netdev 0 0

And reboot your instance. Whatever changes in /var/www/html/media will gets reflected in fs-id:/media folder also the same applies for var folder also hope this helps.

like image 98
Prashanna Avatar answered Dec 31 '25 15:12

Prashanna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!