May 24, 2016 1 Comment
Nowadays majority of us are using some cloud services. Amazon Web Services is one of the popular provider among all the other cloud service providers. Just like we upgrade our harddisk or mounting new drives to physical machines, we can attach new block storages to Amazon EC2 also. Amazon provides a service called EBS (Elastic Block Storage). There are various types of EBS with various speed and cost. Example are magnetic, SSD etc.
Attaching a new EBS to a running EC2 instance is very simple. We can do this programatically as well as using the console. Here I am explaining the basic steps to perform this operation using the console.
- Launch an EBS in the same region and same availability zone as that of the EC2 instance
- Note down the instance id of the EC2 instance
- Attach the EBS to the EC2. This can be done by using the attach option available in the EBS. The EBS will be listed under the Volumes section in EC2 service page of AWS console.
- Login to the EC2 instance and switch to the root user
- Type lsblk to list all the block devices
- Identify the new block device.
- Create a new directory to mount the EBS.
- Format the newly mounted storage. The command is mkfs -t ext4 /dev/<device-name>
- Mount the EBS on the directory. The command is mount /dev/<device-name> <mount-dir>
- Check for the new storage. The command is df -h