amazon-web-servicesubuntunvme

How to increase AWS EBS NVME size


I have upgraded an EC2 instance from m4 to m5, and now want to increase the size of the attached EBS storage volume. I am using an solid-state (SSD) EBS volume mounted as an NVMe drive.

After some research, I performed this command:

growpart /dev/nvme0n1 p1

After doing so, I received this error message in response:

FAILED: partition-number must be a number

I have tried to find instructions in the AWS docs and forums, but have not found a solution to this error message.

How can I increase the size of the EBS volume?


Solution

  • 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% /