How to increase AWS EBS NVME size

戏子无情 提交于 2019-12-05 11:25:58

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

resize2fs didn't work for me, so I had to use

xfs_growfs /dev/nvme0n1p1

instead since I got the error

[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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!