Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase AWS EBS NVME size

Tags:

nvme

I have upgraded an EC2 instance from m4 to m5, and now I want to increase the volume.

I did perform this command and got the error:

growpart /dev/nvme0n1 p1
FAILED: partition-number must be a number

Can't find instruction from AWS docs and forums.

Any idea how to increase NVME disk ?

like image 839
Nguyễn Hải Thanh Avatar asked Sep 25 '18 23:09

Nguyễn Hải Thanh


People also ask

Can EBS size be increased?

With Amazon EBS Elastic Volumes, you can increase the volume size, change the volume type, or adjust the performance of your EBS volumes. If your instance supports Elastic Volumes, you can do so without detaching the volume or restarting the instance.

What is the maximum size AWS EBS volume?

EBS currently supports a maximum volume size of 64 TiB. This means that you can create an EBS volume as large as 64 TiB, but whether the OS recognizes all of that capacity depends on its own design characteristics and on how the volume is partitioned.

How do I find my EBS volume ID for NVMe volume?

NVMe EBS volumes have the EBS volume ID set as the serial number in the device identification. Use the lsblk -o +SERIAL command to list the serial number. The NVMe device name format can vary depending on whether the EBS volume was attached during or after the instance launch.


3 Answers

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html

growpart [OPTIONS] DISK PARTITION-NUMBER

$ lsblk
NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1       259:0    0  16G  0 disk 
├─nvme0n1p1   259:1    0   8G  0 part /
└─nvme0n1p128 259:2    0   1M  0 part 

So to grow the partition, we use the diskname nvme0n1 (see disk under TYPE) and desired partition is 1

sudo growpart /dev/nvme0n1 1

And then to extend the fs - resize2fs device [ size ]

(device refers to the location of the target filesystem)

$ df -h
Filesystem                                 Size  Used Avail Use% Mounted on
devtmpfs                                   470M   52K  470M   1% /dev
tmpfs                                      480M     0  480M   0% /dev/shm
/dev/nvme0n1p1                             7.8G  7.7G  3.1M 100% /

So to extend the fs, we use the device name /dev/nvme01np1:

sudo resize2fs /dev/nvme0n1p1

Voila!

$ df -h
Filesystem                                 Size  Used Avail Use% Mounted on
devtmpfs                                   470M   52K  470M   1% /dev
tmpfs                                      480M     0  480M   0% /dev/shm
/dev/nvme0n1p1                              16G  7.7G  7.9G  50% /
like image 50
MetricMike Avatar answered Oct 11 '22 18:10

MetricMike


resize2fs didn't work for me, so I used this instead:

xfs_growfs /dev/nvme0n1p1

resize2fs gave me this error when I used it:

[root@ip-1-2-3-4 ~]# resize2fs /dev/nvme0n1p1
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/nvme0n1p1
Couldn't find valid filesystem superblock.

I noticed the disk was using xfs under /etc/fstab:

UUID=4cbf4a19-1fba-4027-bf92-xxxxxxxxxxxx     /           xfs    defaults,noatime  1   1
like image 44
hobbes3 Avatar answered Oct 11 '22 17:10

hobbes3


Prerequesities:

  1. You found the partition you want to extend and there is just one partition on this particular NVME: /dev/nvme0n1p1 but not /dev/nvme0n1p2. Note the mount location: /
df
Filesystem     1K-blocks     Used Available Use% Mounted on
...
/dev/nvme0n1p1 _________ ________  ________  99% /
  1. You run lsblk and it confirms a single partition under the volume nvme0n1
lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
nvme0n1     259:2    0   400G  0 disk
└─nvme0n1p1 259:3    0   400G  0 part /

Than you first extend your volume through AWS console and then run next code block.

Single place script:

# /dev/nvme0n1 - volume name, 1 - partition index
sudo growpart /dev/nvme0n1 1 
# block for xfs
# / - mount from above. Command will safely fail for non xfs
sudo xfs_growfs -d / 
# block for ext4
# /dev/nvme0n1p1 - partition you would like to extend
sudo resize2fs /dev/nvme0n1p1

Assembled from this resource: Extend a Linux file system after resizing a volume

like image 2
y.selivonchyk Avatar answered Oct 11 '22 17:10

y.selivonchyk