After creating a EC2 instance, you may find out that the Amazon Machine Image (AMI), ie install image, you used had a different OS/root partition size than the size you allocated in the AWS Console, which is where this tutorial comes into play.
Resize volume
Check the used partition size via lsblk, which lists information about all available or the specified block devices> sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:1 0 8G 0 disk
├─nvme0n1p1 259:2 0 1M 0 part
└─nvme0n1p2 259:3 0 8G 0 part /
First we will extend the partition, and then we will extend the file system
├─nvme0n1p1 259:2 0 1M 0 part
└─nvme0n1p2 259:3 0 8G 0 part /
First we will extend the partition, and then we will extend the file system
Install growpart to extend a partition in a partition table to fill the available space
> sudo yum install cloud-utils-growpart
Extend the partition, the first option is the volume ie nvme0n1, the second options is the partition number ie the 1 in p1
> sudo growpart /dev/nvme0n1 1
Verify
> sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:1 0 16G 0 disk
├─nvme0n1p1 259:2 0 1M 0 part
└─nvme0n1p2 259:3 0 16G 0 part /
├─nvme0n1p1 259:2 0 1M 0 part
└─nvme0n1p2 259:3 0 16G 0 part /
The 8GB partition now lists as 16GB
But the file system is still 8GB
But the file system is still 8GB
> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 8G 1.9G 8G 24% /
> sudo xfs_growfs /
Verify
> df -h
> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 16G 1.9G 16G 12% /
-End of Document-
Thanks for reading
No comments:
Post a Comment