Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS ec2 root volume increase: Expanding elastic root volume on aws ubuntu instance not working

I've followed aws doc for expanding elastic root volume and got my root volume size increased from 8 GB to 20 GB, which i confirmed using lsblk.

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

But updated size not reflecting in the df -h command, even after i explicitly resize the device using the sudo resize2fs /dev/xvda1 command as my file system type is ext4 which i checked using sudo file -s /dev/xvd* command. sudo resize2fs /dev/xvda1 command giving below output :-

sudo resize2fs /dev/xvda1 resize2fs 1.42.12 (29-Aug-2014) The filesystem is already 2096635 (4k) blocks long. Nothing to do!

Let me know, what i need to do for OS to pickup the size in my volume.

Thanks

like image 555
Amit Avatar asked Feb 26 '17 07:02

Amit


People also ask

Can we increase root EBS volume size?

Expand the EBS root volume of EC2 Linux running on a current generation instance without detaching and reattaching the volume by using the Amazon EBS Elastic Volumes feature. To expand the EBS root volume of EC2 Linux running on a previous generation instance, you must detach and then reattach the volume.


2 Answers

The reason for your output is because you are missing a step.

The resize2fs program does not manipulate the size of partitions. If you wish to enlarge a filesystem, you must make sure you can expand the size of the underlying partition first... https://linux.die.net/man/8/resize2fs

Once you've increased the size of your volume either from using the AWS Console ( UI ) or using the command line aws ec2 modify-volume --volume-id ID_OF_DEVICE --size NEW_SIZE (modify volume command line documentation)

You still need to tell the operating system that you want to allocate more space to the partition ( in this case the root partition /) So the correct sequence to get it work is as shown:

Extend the partition in a partition table to fill available space

(1) sudo growpart /dev/xvda 1 https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/expand-linux-partition.html

Expand an ext2, ext3, ext4 file system

(2)sudo resize2fs /dev/xvda1

More on AWS recognizing expanded volume

like image 75
Antonio Gomez Alvarado Avatar answered Oct 12 '22 11:10

Antonio Gomez Alvarado


/dev/xvda1 is an 8 GiB partition on a 20 GiB device and there are no other partitions on the volume. In this case, the partition must be resized in order to use the remaining space on the volume.

After you resize the partition, you can extend the file system (via sudo resize2fs /dev/xvda1) to occupy all of the space on the partition.

like image 30
Khalid T. Avatar answered Oct 12 '22 09:10

Khalid T.