I have EC2 instance with Linux (Ubunty) and root volume of 10 GB. I have consumed about 96% of the size and now my application responding slow, so I wanted to increase the size to 50 GB.
The most important point is, I have data already there and many applications are running on this EC2 instance and I don't want to disturb or stop them.
To check the current space available ~$ df -hT
Please use ~$ lsblk
command to check the partition size
Here is the solution:
Take a snapshot of your volume which contains valuable data.
Increase the EBS volume using Elastic Volumes
After increasing the size, extend the volume's file system manually.
1) Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2) Choose Snapshots under Elastic Block Store in the navigation pane.
3) Choose Create Snapshot.
4) For Select resource type, choose Volume.
5) For Volume, select the volume.
6) (Optional) Enter a description for the snapshot.
7) (Optional) Choose Add Tag to add tags to your snapshot. For each tag, provide a tag key and a tag value.
8) Choose Create Snapshot.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
Choose Volumes, select the volume to modify, and then choose Actions, Modify Volume.
The Modify Volume window displays the volume ID and the volume's current configuration, including type, size, IOPS, and throughput. Set new configuration values as follows:
To modify the type, choose a value for Volume Type.
To modify the size, enter a new value for Size.
To modify the IOPS, if the volume type is gp3, io1, or io2, enter a new value for IOPS.
To modify the throughput, if the volume type is gp3, enter a new value for Throughput.
After you have finished changing the volume settings, choose Modify. When prompted for confirmation, choose Yes.
Modifying volume size has no practical effect until you also extend the volume's file system to make use of the new storage capacity.
To check whether the volume has a partition that must be extended, use the lsblk
command to display information block devices attached to your instance.
The root volume, /dev/nvme0n1
, has a partition, /dev/nvme0n1p1
. While the size of the root volume reflects the new size, 50 GB, the size of the partition reflects the original size, 10 GB, and must be extended before you can extend the file system.
The volume /dev/nvme1n1
has no partitions. The size of the volume reflects the new size, 40 GB.
For volumes that have a partition, such as the root volume shown in the previous step, use the growpart
command to extend the partition. Notice that there is a space between the device name and the partition number.
~$ sudo growpart /dev/nvme0n1 1
To extend the file system on each volume, use the correct command for your file system. In my case, I have ext4
filesystem, I will use the resize2fs
command.
~$ sudo resize2fs /dev/nvme0n1p1
Use lsblk
to check the partition size.