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

4

10

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

Liddle answered 26/2, 2017 at 7:21 Comment(2)
docs.aws.amazon.com/AWSEC2/latest/UserGuide/…Lights
Hi Amit, how you solved this issue. I'm facing the exact same problem now. Can you help me to solve it?Surprisal
S
4

/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.

Sundial answered 26/2, 2017 at 7:49 Comment(3)
I went through the doc which you mentioned, but procedure is very complex , if there is any easy to follow commands/doc are there , it will be useful. i am sure lots of people have faced this issue and lost into the complex documentation.Liddle
I agree that the process can be complex for root partitions at this stage. Even AWS admits that: "If the partition you need to resize is the root partition for an instance, the process becomes more complicated...". I do hope AWS would make the process much simpler for us in the future though.Sundial
The complexity of the procedure has absolutely nothing to do with AWS. Re-partitioning the boot disk with the root volume on it -- aside from usually being the wrong solution -- is an intrinsically complex task.Zoie
A
21

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

Apopemptic answered 1/4, 2018 at 8:18 Comment(3)
This should be the solution accepted, as the command that you were missing is sudo growpart /dev/xvda 1, @Liddle KhandelwalSaadi
In my case, resize2fs was throwing Bad magic number in super-block while trying to open /dev/xvda1. But when I used xfs_growfs, it worked fine.Hankhanke
The answer above has to do with ext file systems. In your case, the file system was XFS, which is the reason it worked. More here: docs.aws.amazon.com/AWSEC2/latest/UserGuide/…Apopemptic
S
5

My solution:

I don't know about you guys but I was able to add 30GB to my original 8GB Ubuntu EC2 instance and then I went to EC2 Console Manager and right clicked on my Instance, then pressed Reboot.

Once I rebooted and SSH'ed back into the server I typed df -h and saw that my root partition (/dev/xvda1) was of size 38GB.

Supernal answered 8/8, 2017 at 21:24 Comment(5)
Please only add answers in answer, if you have another question, ask it using the ask question interface.Enlil
Same thing happened for me. I was a few days away from giving up and going through all that AWS documentation to increase my root, when my server crashed. I rebooted it and suddenly the extra GBs I had already added to the instance had been added to my root partition. Best server crash I've ever had.Shoulders
Same for me - reboot and get your extra GBs.Wheelman
I also faced the same. Just rebooted and it worked for meGraziano
Same here - I tried following all the steps, but they didn't work. It wasn't until I rebooted that I saw the increase.Links
S
4

/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.

Sundial answered 26/2, 2017 at 7:49 Comment(3)
I went through the doc which you mentioned, but procedure is very complex , if there is any easy to follow commands/doc are there , it will be useful. i am sure lots of people have faced this issue and lost into the complex documentation.Liddle
I agree that the process can be complex for root partitions at this stage. Even AWS admits that: "If the partition you need to resize is the root partition for an instance, the process becomes more complicated...". I do hope AWS would make the process much simpler for us in the future though.Sundial
The complexity of the procedure has absolutely nothing to do with AWS. Re-partitioning the boot disk with the root volume on it -- aside from usually being the wrong solution -- is an intrinsically complex task.Zoie
G
0

Have funin 9 steps...........

Detach root volume and take snapshot of root volume for safer side and resize it.Once resizied, mount this volume to your_instance under /dev/sda1 ensure filesystem is fully expanded to root volume by running “lsblk” and “df -h” commands. If change is not reflected run, “resize2fs -f ”

Further details refer,

Steps to increase the root volume

Grommet answered 13/7, 2017 at 4:9 Comment(2)
Perhaps you could summarize the steps in the link you provided here. That way if the link ever goes dead your answer will still be useful.Franko
Thanks for your comments stephen. I think now its useful.Grommet

© 2022 - 2024 — McMap. All rights reserved.