Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically mount an EBS volume upon starting an Amazon EC2 Linux instance

I have an EBS volume (e.g. /dev/sdf) that has been attached to an EC2 instance (which boots from a different EBS volume), and I have mounted the volume (through mount /dev/sdf /data). When I stop and start again the instance, the volume is still attached but no longer mounted, and I have to manually mount it again.

Is there a way to make the volume /dev/sdf automatically mounted to /data upon starting the instance?

like image 284
user560494 Avatar asked May 15 '11 06:05

user560494


People also ask

Can we attach EBS to running instance?

To attach an Amazon EBS volume to a running instance, and then make the volume available to Windows, follow these steps: Attach the Amazon EBS volume to the Amazon EC2 Windows instance. You can use the Amazon EC2 console, the AWS Command Line Interface (AWS CLI), or AWS Tools for Windows PowerShell.

Can you attach volumes to AWS EC2 instance once it has been created?

You can't attach instance store volumes to an instance after you've launched it. If you change the instance type, an instance store will not be attached to the new instance type.

How do I know if my EBS is attached to EC2?

Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Instances. Select the instance. In the Description tab, for Block devices, select the block device mapping and then choose the EBS ID to view additional details for the volume.


2 Answers

It would seem that the official ec2 documentation now recommends plain old fstab entries with nofail -

/dev/xvdf       /data   ext4    defaults,nofail        0       2 

ref - http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html

like image 88
chrismarx Avatar answered Sep 21 '22 09:09

chrismarx


Make an entry to /etc/fstab

Entry would be like:

/dev/sdf    /data   ext3    defaults    1 1 

This will automatically mount the volume during reboot.

like image 37
Sanket Dangi Avatar answered Sep 23 '22 09:09

Sanket Dangi