6

I need to resize /dev/nvme0n1p1 15G 10G 6G 64% /

Filesystem     1G-blocks  Used Available Use% Mounted on
udev                 16G    0G       16G   0% /dev
tmpfs                 4G    1G        4G   1% /run
/dev/nvme0n1p1       15G   10G        6G  64% /
tmpfs                16G    1G       16G   1% /dev/shm
tmpfs                 1G    0G        1G   0% /run/lock
tmpfs                16G    0G       16G   0% /sys/fs/cgroup
/dev/loop0            1G    1G        0G 100% /snap/amazon-ssm-agent/1480
/dev/loop2            1G    1G        0G 100% /snap/core/7713
/dev/loop3            1G    1G        0G 100% /snap/amazon-ssm-agent/1455
tmpfs                 4G    0G        4G   0% /run/user/1000
/dev/loop4            1G    1G        0G 100% /snap/core/7917



Filesystem     Type     1K-blocks    Used Available Use% Mounted on
udev           devtmpfs  15933020       0  15933020   0% /dev
tmpfs          tmpfs      3189032     864   3188168   1% /run
/dev/nvme0n1p1 ext4      15180980 9711656   5452940  65% /
tmpfs          tmpfs     15945144       8  15945136   1% /dev/shm
tmpfs          tmpfs         5120       0      5120   0% /run/lock
tmpfs          tmpfs     15945144       0  15945144   0% /sys/fs/cgroup
/dev/loop0     squashfs     18432   18432         0 100% /snap/amazon-ssm-agent/1480
/dev/loop2     squashfs     91264   91264         0 100% /snap/core/7713
/dev/loop3     squashfs     18432   18432         0 100% /snap/amazon-ssm-agent/1455
tmpfs          tmpfs      3189028       0   3189028   0% /run/user/1000
/dev/loop4     squashfs     91264   91264         0 100% /snap/core/7917

To make use of the 100GB that has been added

NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0         7:0    0   18M  1 loop /snap/amazon-ssm-agent/1480
loop2         7:2    0   89M  1 loop /snap/core/7713
loop3         7:3    0   18M  1 loop /snap/amazon-ssm-agent/1455
loop4         7:4    0 89.1M  1 loop /snap/core/7917
nvme0n1     259:0    0  100G  0 disk 
└─nvme0n1p1 259:1    0  100G  0 part /

After reading AWS documentation I tried running the following growpart commands but I'm not clear on what is required.

sudo growpart /dev/nvme0n1p1 1
WARN: unknown label 
failed [sfd_dump:1] sfdisk --unit=S --dump /dev/nvme0n1p1
sfdisk: /dev/nvme0n1p1: does not contain a recognized partition table
FAILED: failed to dump sfdisk info for /dev/nvme0n1p1


sudo growpart /dev/nvme0n1 1
NOCHANGE: partition 1 is size 209713119. it cannot be grown

Regards Conteh

4
  • 1
    The lsblk command shows that the partition is already it's max size of 100G. You just need to grow the filesystem using something like resize2fs or xfs_growfs
    – jordanm
    Commented Oct 14, 2019 at 23:30
  • @jordanm yes sudo resize2fs /dev/nvme0n1p1 worked. Thanks
    – conteh
    Commented Oct 15, 2019 at 8:14
  • getting following error resize2fs: Bad magic number in super-block while trying to open /dev/nvme0n1p1 Commented Oct 2, 2021 at 14:29
  • my bad with xfs_growfs, its worked. Commented Oct 2, 2021 at 14:31

3 Answers 3

12

I had the same issue Solved it with the command below (other answers are wrong)

sudo growpart /dev/nvme0n1 1

I could then extend the FS with

sudo resize2fs /dev/nvme0n1p1

1
  • thank you. some tutorial on the internet only say resize2fs, not the growpart things Commented Nov 7, 2023 at 6:02
2

The filetype was ext4. So the following command works.

sudo resize2fs /dev/nvme0n1p1
0

After looking around, considering this is a root filesystem, and probably EBS Nitro instance, you may try the following (you may have to reboot for this to take effect):

To format and mount an NVMe EBS volume, see Making an Amazon EBS Volume Available for Use on Linux.

If you are using Linux kernel 4.2 or later, any change you make to the volume size of an NVMe EBS volume is automatically reflected in the instance. For older Linux kernels, you might need to detach and attach the EBS volume or reboot the instance for the size change to be reflected. With Linux kernel 3.19 or later, you can use the hdparm command as follows to force a rescan of the NVMe device:

[ec2-user ~]$ sudo hdparm -z /dev/nvme1n1

When you detach an NVMe EBS volume, the instance does not have an opportunity to flush the file system caches or metadata before detaching the volume. Therefore, before you detach an NVMe EBS volume, you should first sync and unmount it. If the volume fails to detach, you can attempt a force-detach command as described in Detaching an Amazon EBS Volume from an Instance.

REFERENCES

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .