This is an old revision of the document!
Table of Contents
Enlarge Disk
Before you begin
- Create a snapshot of the volume, in case you need to roll back your changes. For more information, see https://docs.aws.amazon.com/ebs/latest/userguide/ebs-creating-snapshot.html.
- Confirm that the volume modification succeeded and that it is in theoptimizing or completed state. For more information, see https://docs.aws.amazon.com/ebs/latest/userguide/monitoring-volume-modifications.html.
- Ensure that the volume is attached to the instance and that it is formatted and mounted. For more information, see https://docs.aws.amazon.com/ebs/latest/userguide/ebs-using-volumes.html#ebs-format-mount-volume.
- (Linux instances only) If you are using logical volumes on the Amazon EBS volume, you must use Logical Volume Manager (LVM) to extend the logical volume. For instructions about how to do this, see the Extend the LV section in the article https://repost.aws/knowledge-center/create-lv-on-ebs-partition.
Linux instances
Note The following instructions walk you through the process of extending XFS and Ext4 file systems for Linux. For information about extending a different file system, see its documentation.
Before you can extend a file system on Linux, you must extend the partition, if your volume has one.
Extend the file system of EBS volumes
Use the following procedure to extend the file system for a resized volume.
Note that device and partition naming differs for Xen instances and instances built on the Nitro System(https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html). To determine whether your instance is Xen-based or Nitro-based, use the describe-instance-types(https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-instance-types.html) AWS CLI command, and for '–instance-type', specify your instance type.
aws ec2 describe-instance-types --instance-type instance_type --query "InstanceTypes[].Hypervisor"
A value of nitro indicates that your instance is Nitro-based. A value of xen indicates that your instance is Xen-based.
To extend the file system of EBS volumes
1 Connect to your instance(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-to-linux-instance.html).
2 Resize the partition, if needed. To do so:
- Check whether the volume has a partition. Use the lsblk command.
–Nitro instance example
In the following example output, the root volume (nvme0n1) has two partitions (nvme0n1p1 and nvme0n1p128), while the additional volume (nvme1n1) has no partitions.
sudo lsblk
–Xen instance example
In the following example output, the root volume (xvda) has a partition (xvda1), while the additional volume (xvdf) has no partition.
sudo lsblk
If the volume has a partition, continue the procedure from the following step (2b). If the volume has no partitions, skip steps 2b, 2c, and 2d, and continue the procedure from step 3.
Troubleshooting tip
If you do not see the volume in the command output, ensure that the volume is attached to the instance(https://docs.aws.amazon.com/ebs/latest/userguide/ebs-attaching-volume.html), and that it is formatted and mounted(https://docs.aws.amazon.com/ebs/latest/userguide/ebs-using-volumes.html#ebs-format-mount-volume).
-Check whether the partition needs to be extended. In the lsblk command output from the previous step, compare the partition size and the volume size.
If the partition size is smaller than the volume size, continue to the next step. If the partition size is equal to the volume size, the partition can't be extended.
