TECHIES WORLD

For Techs.... Techniques.... Technologies....

AWSBashLinux

How to increase AWS EBS root partition for ext4 filesystems

Step1: Login to the AWS console and navigate to EC2 management console.

Step2: Select the required EBS volume and take a snapshot as the backup.

Step3: Modify the selected volume to the required size. Here in this example we are expanding an EBS having size 8G to 16G.

Step4: Connect to the EC2 instance as root via ssh.

Step5: Check the disk layout.

#lsblk

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  16G  0 disk
└─xvda1 202:1    0   8G  0 part /

Here the root volume /dev/xvda, has a partition, /dev/xvda1. The current size of this partition is 8G and we can extent this to 16G.

Step6: Extend the partition.

#sudo growpart /dev/xvda 1

Step7: Check the disk layoyt again.

#lsblk

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  16G  0 disk
└─xvda1 202:1    0  16G  0 part /

Step8: Verify the size of the file system.

#df -h

Filesystem       Size  Used Avail Use% Mounted on
/dev/xvda1       8.0G  1.9G  6.2G  24% /

Here it can be noticed that, we need to extend the filesystem.

Step9: Run the following command to extend the filesystem.

#sudo resize2fs /dev/xvda1

Step10: Verify the size of the filesystem.

#df -h

Filesystem       Size  Used Avail Use% Mounted on
/dev/xvda1        16G  1.9G  14G  12% /

That's all…