Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
This can be applied whenever you need to extend your EBS volume size avoiding to stop the instance and detach the volume.
Cool if you need to do it on prod, right ? :)
In order to extend the volume size, follow these simple steps:
- Login to your AWSÂ console
- Choose “EC2” from the services list
- Click on “Volumes” under ELASTIC BLOCK STORE menu (on the left)
- Choose the volume that you want to resize, right click on “Modify Volume”
- You’ll see an option window like this one:
6. Set the new size for your EBS volume (in this case i extended an 8GB volume to 20GB)
7. Click on modify.
Now, we need to extend the partition itself.
SSH to the EC2 instance where the EBS we’ve just extended is attached to.
Type the following command to list our block devices:
[ec2-user ~]$ lsblk
You should be able to see a similar output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTxvda 202:0 0 20G 0 disk └─xvda1 202:1 0 8G 0 part /
As you can see size of the root volume reflects the new size, 20GB, the size of the partition reflects the original size, 8 GB, and must be extended before you can extend the file system.
To do so, type the following command:
[ec2-user ~]$ sudo growpart /dev/xvda 0
Be careful, there is a space between device name and partition number!
Now we can check that the partition reflects the increased volume size (we can check it with the lsblk command we already used):
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTxvda 202:0 0 20G 0 disk └─xvda1 202:1 0 20G 0 part /
Last but not least, we need to extend the filesystem itself.If your filesystem is an ext2, ext3, or ext4, type:
[ec2-user ~]$ sudo resize2fs /dev/xvda1
If your filesystem is an XFS, then type:
[ec2-user ~]$ sudo xfs_growfs /dev/xvda1
Finally we can check our extended filesystem by typing:
[ec2-user ~]$ df -h
If everything went right, we should be able to see our effective filesystem extended size:
Filesystem Size Used Avail Use% Mounted ondevtmpfs 980M 0 980M 0% /devtmpfs 997M 0 997M 0% /dev/shmtmpfs 997M 440K 997M 1% /runtmpfs 997M 0 997M 0% /sys/fs/cgroup/dev/xvda1 20G 1,4G 19G 7% /
You have just extended your EBS volume size with 0 downtime, enjoy!
NOTE: All product names, logos, and brands are property of their respective owners.
Tutorial: how to extend AWS EBS volumes with no downtime was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.