New volume in ec2 instance not reflecting
Asked Answered
S

4

6

I have a volume of 250 gb initially in one of my ec2 instance. I have increased the volume to 300gb. I could able to see that 300gb using the below command enter image description here

But when i do df-h command i could not see the 300gb volume. Please help i am new to AWS enter image description here

Seagoing answered 2/6, 2020 at 6:47 Comment(2)
did you resize2fs ?Baggett
Yes i did i am getting this error sudo: unable to resolve host ip-172-31-3-165: Resource temporarily unavailable resize2fs 1.44.1 (24-Mar-2018) resize2fs: Device or resource busy while trying to open /dev/xvda Couldn't find valid filesystem superblock.Seagoing
S
9

New volumes should be formatted to be accessible. Resized existing volumes should also be modified (resized) from the inside of the operating system.

The general information on how to do this safely (e.g. with snapshots) is given in the following AWS documentation:

Based on the discussion in comments, two commands were used to successfully solve the problem:

  • sudo growpart /dev/xvda 1
  • sudo resize2fs /dev/xvda1
Subteen answered 2/6, 2020 at 7:3 Comment(7)
I tried to extend the partition by using sudo growpart /dev/xvda 1 Its showing the below error Resource temporarily unavailable CHANGED: partition=1 start=2048 old: size=524285919 end=524287967 new: size=629143519,end=629145567Seagoing
@HarnishKumar Can you clarify it this is totally new volume, or it was existing volume that was working fine. But then when you extended it stopped working?Subteen
It was an existing volume not working when i extendSeagoing
@HarnishKumar I see. This is root volume.Subteen
@HarnishKumar I did a quick check on my ubuntu instance, and ` CHANGED` means that the resize was successful. Did you check lsblk again?Subteen
lsblk i could see the 300gb xvda 202:0 0 300G 0 disk └─xvda1 202:1 0 250G 0 part / But when i do df-h i could not udev 468M 0 468M 0% /dev tmpfs 98M 5.6M 93M 6% /run /dev/xvda1 243G 243G 0 100% / tmpfs 490M 0 490M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/loop0 94M 94M 0 100% /snap/core/9066 /dev/loop2 18M 18M 0 100% /snap/amazon-ssm-agent/1480Seagoing
Let us continue this discussion in chat.Seagoing
M
20

Let's solve step by step

  1. After increasing the EBS volume size, connect to your instance over SSH to check the EBS volume size.
ssh ubuntu@<Public IP> -i <Key Pair>
  1. Now use the df command to list all the filesystems mounted on your disk.

sudo df -hT

  1. I hope you are seeing that The root filesystem size (/dev/xvda1) is still (X GB here X={Your EC2 storage size}), and its type is ext4. Now use the lsblk command in the terminal to check whether the disk has an extended partition.

sudo lsblk

  1. The root volume (/dev/xvda) has a partition (/dev/xvda1). The size of the volume is 20 GB, but the size of the partition is still X GB. Now use the growpart command in the terminal to extend the partition size.

sudo growpart /dev/xvda 1

  1. Again use the lsblk command in the terminal to verify if the partitions size extended.

sudo lsblk

  1. So far, the volume size and the partition size have been extended. Use the df command to check if the root filesystem has been extended or not.

sudo df -hT

The size of the root filesystem is still X GB, and it needs to be extended. To extend different types of filesystems, different commands are used.

  1. In order to extend an ext4 filesystem, the resize2fs command is used.

sudo resize2fs /dev/xvda1

  1. Now again, list all the filesystems on your EC2 instance using the df command.

sudo df -hT

I hope you are seeing the changes after running the resize2fs command, the size of the filesystem is increased.

Marcelmarcela answered 31/10, 2022 at 4:35 Comment(0)
S
9

New volumes should be formatted to be accessible. Resized existing volumes should also be modified (resized) from the inside of the operating system.

The general information on how to do this safely (e.g. with snapshots) is given in the following AWS documentation:

Based on the discussion in comments, two commands were used to successfully solve the problem:

  • sudo growpart /dev/xvda 1
  • sudo resize2fs /dev/xvda1
Subteen answered 2/6, 2020 at 7:3 Comment(7)
I tried to extend the partition by using sudo growpart /dev/xvda 1 Its showing the below error Resource temporarily unavailable CHANGED: partition=1 start=2048 old: size=524285919 end=524287967 new: size=629143519,end=629145567Seagoing
@HarnishKumar Can you clarify it this is totally new volume, or it was existing volume that was working fine. But then when you extended it stopped working?Subteen
It was an existing volume not working when i extendSeagoing
@HarnishKumar I see. This is root volume.Subteen
@HarnishKumar I did a quick check on my ubuntu instance, and ` CHANGED` means that the resize was successful. Did you check lsblk again?Subteen
lsblk i could see the 300gb xvda 202:0 0 300G 0 disk └─xvda1 202:1 0 250G 0 part / But when i do df-h i could not udev 468M 0 468M 0% /dev tmpfs 98M 5.6M 93M 6% /run /dev/xvda1 243G 243G 0 100% / tmpfs 490M 0 490M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/loop0 94M 94M 0 100% /snap/core/9066 /dev/loop2 18M 18M 0 100% /snap/amazon-ssm-agent/1480Seagoing
Let us continue this discussion in chat.Seagoing
C
2
  1. Connect to the EC2 instance & verify mounted point:df -h
  2. Then identify the filesystem: df -T
  3. Resize the File System:For xfs: sudo xfs_growfs /dev/nvme0n1p1 For ext4:sudo resize2fs /dev/nvme0n1p1.

Replace /dev/nvme0n1p1 with appropriate device identifier for your system.

  1. Now verify the mounted point. In some cases, a restart the instance: sudo reboot
Comport answered 9/1 at 8:25 Comment(0)
E
0

This command fixed my issue

sudo xfs_growfs -d /

Following this official document:

https://docs.aws.amazon.com/ebs/latest/userguide/recognize-expanded-volume-linux.html

Euthenics answered 22/9 at 15:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.