Uncategorized

Example: Extend the file system of NVMe EBS volumes

For this example, suppose that you have an instance built on the Nitro System, such as an M5 instance. You resized the boot volume from 8 GB to 16 GB and an additional volume from 8 GB to 30 GB. Use the following procedure to extend the file system of the resized volumes.

To extend the file system of NVMe EBS volumes

  1. Connect to your instance.
  2. To verify the file system for each volume, use the df -hT command.[ec2-user ~]$ df -hTThe following is example output for an instance that has a boot volume with an XFS file system and an additional volume with an XFS file system. The naming convention /dev/nvme[0-26]n1 indicates that the volumes are exposed as NVMe block devices.[ec2-user ~]$ df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/nvme0n1p1 xfs 8.0G 1.6G 6.5G 20% / /dev/nvme1n1 xfs 8.0G 33M 8.0G 1% /data ...
  3. To check whether the volume has a partition that must be extended, use the lsblk command to display information about the NVMe block devices attached to your instance.[ec2-user ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme1n1 259:0 0 30G 0 disk /data nvme0n1 259:1 0 16G 0 disk └─nvme0n1p1 259:2 0 8G 0 part / └─nvme0n1p128 259:3 0 1M 0 part This example output shows the following:
    • The root volume, /dev/nvme0n1, has a partition, /dev/nvme0n1p1. While the size of the root volume reflects the new size, 16 GB, the size of the partition reflects the original size, 8 GB, and must be extended before you can extend the file system.
    • The volume /dev/nvme1n1 has no partitions. The size of the volume reflects the new size, 30 GB.
  4. For volumes that have a partition, such as the root volume shown in the previous step, use the growpart command to extend the partition. Notice that there is a space between the device name and the partition number.[ec2-user ~]$ sudo growpart /dev/nvme0n1 1
  5. (Optional) To verify that the partition reflects the increased volume size, use the lsblk command again.[ec2-user ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme1n1 259:0 0 30G 0 disk /data nvme0n1 259:1 0 16G 0 disk └─nvme0n1p1 259:2 0 16G 0 part / └─nvme0n1p128 259:3 0 1M 0 part
  6. To verify the size of the file system for each volume, use the df -h command. In this example output, both file systems reflect the original volume size, 8 GB.[ec2-user ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p1 8.0G 1.6G 6.5G 20% / /dev/nvme1n1 8.0G 33M 8.0G 1% /data ...
  7. To extend the file system on each volume, use the correct command for your file system, as follows:
    • [XFS file system] To extend the file system on each volume, use the xfs_growfs command. In this example, / and /data are the volume mount points shown in the output for df -h.

sudo resize2fs /dev/nvme0n1p1 

Extend a Linux file system after resizing a volume – Amazon Elastic Compute Cloud

Similar Posts