Your servers’ disk space may need to be increased from time to time. Before expanding the volume or increasing the size of the disk, it is always recommended to take a snapshot of the volume. Additionally, reducing the size of the disk is not recommended. The file system of a partition must be extended in order to accommodate an increase in volume size. To resize the volume’s file system, a command specific to the file system must be used.
In this article, we will build the circle space of the boot volume (root segment) with the filesystem of type ext4 of Ubuntu 20.04 Server.
Table of Contents
Create an AWS account if you don’t already have one.
An instance of the Ubuntu 20.04 EC2 server (click here to learn how to create an EC2 instance).
What will we do?
Check current disk space.
Change the size of the root Volume’s disk.
Make the Filesystem larger.
Perform a disk space check.
Utilizing the lsblk and blkid commands, let’s first check the available disk space and information about block devices.
You can see that the current disk size of / (root) is 7.7 GBs (approximately 8 GBs) in the screenshot above. We will try to make this disk bigger.
Change the size of the Volume’s disk.
Go to the EC2 instance — > Volume attached to the instance.
Click on “Actions” -> “Modify Volumes” to see the volume.
Select the desired size on the pop-up screen. I have determined 30 GBs, prior it was 8 GBs. Click on the “Modify” button, this will change the circle size to 30GBs.
Click the “Yes” option to confirm the modification.
You will see that the disk has been adjusted.
We have only recently modified the disk’s size, so it is not yet usable. In order to make use of the brand-new storage space, we now need to expand the file system of the volume.
Extend the Filesystem.
To extend the volume size, get information about the block devices attached to your instance using the lsblk command
Check the file system type, use the following command.
In our case, the file system is of type ext4 of the volume
Use the following command to extend the volume of the ext4 type.
sudo resize2fs /dev/xvda1
If you check the disk size this time, you will see that the disk has been extended and now we have 28 GBs(Approx 30 GBs) for / partition.
If you see some other file system than ext4, visit the official documentation of AWS here.
We learned how to expand the ext4 file system and increase the boot volume’s disk size in this article. Before increasing the size of the disk, it is always recommended to take a snapshot of it, and it is also recommended to avoid decreasing its size.