Attach and mount an EBS volume to an EC2 instance
Below are the steps needed for attaching a new EBS volume to an Amazon Linux EC2 instance:
- 1. Create an EBS volume – Standard or IOPS.
2. Attach the newly created EBS volume to an EC2 instance specifying the dev name; for example /dev/sdg.
3. To be able to mount the new volume one must first format the new volume; this is done as follows:
sudo mkfs.ext4 /dev/xvdg
sudo mkfs.ext4 /dev/sdg
- 4. Create the mount directory
mkdir /newvolume chmod 777 /newvolume
5. Mount the new volume
mount /dev/xvdg /newvolume
6. In case one needs this volume to be auto mounted on reboot please modify the /etc/fstab; add the following line to /etc/fstab
/dev/sdg /newvolume ext4 defaults,noatime 1 1