

# Modify an Amazon EBS volume using Elastic Volumes operations
<a name="ebs-modify-volume"></a>

With Amazon EBS Elastic Volumes, you can increase the volume size, change the volume type, or adjust the performance of your EBS volumes. If your instance supports Elastic Volumes, you can do so without detaching the volume or restarting the instance. This enables you to continue using your application while the changes take effect.

There is no charge to modify the configuration of a volume. You are charged for the new volume configuration after volume modification starts. For more information, see the [Amazon EBS Pricing](https://aws.amazon.com/ebs/pricing/) page.

**Topics**
+ [Considerations](#elastic-volumes-considerations)
+ [Limitations](#elastic-volumes-limitations)
+ [Requirements for Amazon EBS volume modifications](modify-volume-requirements.md)
+ [Request Amazon EBS volume modifications](requesting-ebs-volume-modifications.md)
+ [Monitor the progress of Amazon EBS volume modifications](monitoring-volume-modifications.md)
+ [Extend the file system after resizing an Amazon EBS volume](recognize-expanded-volume-linux.md)

## Considerations
<a name="elastic-volumes-considerations"></a>
+ After you initiate a volume modification, you must wait for that modification to reach the `completed` state before you can initiate another modification for the same volume. You can modify a volume up to four times within a rolling 24-hour period, as long as the volume is in the `in-use` or `available` state, and all previous modifications for that volume are `completed`. If you exceed this limit, you get an error message that indicates when you can perform your next modification.
+ Volume modifications are performed on a best-effort basis, and they can take from a few minutes to a few hours to complete, depending on the requested volume configuration. Typically, A 1-TiB volume can take up to six hours to be modified. However, the time does not always scale linearly with the volume size - a larger volume might take less time, and a smaller volume might take more time.
+ Size increases take effect once the volume modification reaches the `optimizing` state, which usually takes a few seconds.
+ Modification time is increased for volumes that are not fully initialized. For more information see [Manually initialize the volumes after creation](initalize-volume.md#ebs-initialize).
+ If you change the volume type from `gp2` to `gp3`, and you do not specify IOPS or throughput performance, Amazon EBS automatically provisions either equivalent performance to that of the source `gp2` volume, or the baseline `gp3` performance, whichever is higher.

  For example, if you modify a 500 GiB `gp2` volume with 250 MiB/s throughput and 1500 IOPS to `gp3` without specifying IOPS or throughput performance, Amazon EBS automatically provisions the `gp3` volume with 3000 IOPS (baseline `gp3` IOPS) and 250 MiB/s (to match the source `gp2` volume throughput).
+ If you encounter an error message while attempting to modify an EBS volume, or if you are modifying an EBS volume attached to a previous-generation instance type, take one of the following steps:
  + For a non-root volume, detach the volume from the instance, apply the modifications, and then re-attach the volume.
  + For a root volume, stop the instance, apply the modifications, and then restart the instance.

## Limitations
<a name="elastic-volumes-limitations"></a>
+ You can't cancel a volume modification request after it has been submitted.
+ You must increase the volume size. You can't decrease the volume size. However, you can create a smaller volume and then migrate your data to it using an application-level tool such as **rsync** (Linux instances) or **robocopy** (Windows instances).
+ There are limits to the maximum aggregated storage that can be requested across volume modifications. For more information, see [Amazon EBS service quotas](https://docs.aws.amazon.com/general/latest/gr/ebs-service.html#limits_ebs) in the *Amazon Web Services General Reference*.
+ The new volume size can't exceed the supported capacity of its file system and partitioning scheme. For more information, see [Amazon EBS volume constraints](volume_constraints.md).
+ If you are not changing the volume type, then volume size and performance modifications must be within the limits of the current volume type. If you are changing the volume type, then volume size and performance modifications must be within the limits of the target volume type. For more information, see [Amazon EBS volume types](ebs-volume-types.md)
+ [ Nitro-based instances](https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html) support volumes provisioned with up to 256,000 IOPS. Other instance types can be attached to volumes provisioned with up to 64,000 IOPS, but can achieve up to 32,000 IOPS.
+ You can't modify the volume type for Multi-Attach enabled `io2` volumes.
+ You can't modify the volume type, size, or Provisioned IOPS of Multi-Attach enabled `io1` volumes.
+ A root volume of type `io1`, `io2`, `gp2`, `gp3`, or `standard` can't be modified to an `st1` or `sc1` volume, even if it is detached from the instance.
+ If the volume was attached before November 3, 2016 23:40 UTC, you must initialize Elastic Volumes support. For more information, see [Initializing Elastic Volumes Support](requesting-ebs-volume-modifications.md#initialize-modification-support).
+ While `m3.medium` instances fully support volume modification, `m3.large`, `m3.xlarge`, and `m3.2xlarge` instances might not support all volume modification features.

# Requirements for Amazon EBS volume modifications
<a name="modify-volume-requirements"></a>

The following requirements and limitations apply when you modify an Amazon EBS volume. To learn more about the general requirements for EBS volumes, see [Amazon EBS volume constraints](volume_constraints.md).

**Topics**
+ [Supported instance types](#instance-support)
+ [Operating system](#operating-system)

## Supported instance types
<a name="instance-support"></a>

Elastic Volumes are supported on the following instances:
+ All [current generation instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#current-gen-instances)
+ The following previous-generation instances: C1, C3, C4, G2, I2, M1, M3, M4, R3, and R4

If your instance type does not support Elastic Volumes, see [Modify an EBS volume if Elastic Volumes is not supported](requesting-ebs-volume-modifications.md#modify-volume-stop-start).

## Operating system
<a name="operating-system"></a>

The following operating system requirements apply:

### Linux
<a name="operating-system-linux"></a>

Linux AMIs require a GUID partition table (GPT) and GRUB 2 for boot volumes that are 2 TiB (2,048 GiB) or larger. Many Linux AMIs today still use the MBR partitioning scheme, which only supports boot volume sizes up to 2 TiB. If your instance does not boot with a boot volume larger than 2 TiB, the AMI you are using may be limited to a boot volume size of less than 2 TiB. Non-boot volumes do not have this limitation on Linux instances.

Before attempting to resize a boot volume beyond 2 TiB, you can determine whether the volume is using MBR or GPT partitioning by running the following command on your instance:

```
[ec2-user ~]$ sudo gdisk -l /dev/xvda
```

An Amazon Linux instance with GPT partitioning returns the following information:

```
GPT fdisk (gdisk) version 0.8.10
  
  Partition table scan:
    MBR: protective
    BSD: not present
    APM: not present
    GPT: present
  
  Found valid GPT with protective MBR; using GPT.
```

A SUSE instance with MBR partitioning returns the following information:

```
GPT fdisk (gdisk) version 0.8.8
  
  Partition table scan:
    MBR: MBR only
    BSD: not present
    APM: not present
    GPT: not present
```

### Windows
<a name="operating-system-windows"></a>

By default, Windows initializes volumes with a Master Boot Record (MBR) partition table. Because MBR supports only volumes smaller than 2 TiB (2,048 GiB), Windows prevents you from resizing MBR volumes beyond this limit. In such a case, the **Extend Volume** option is disabled in the Windows **Disk Management** utility. If you use the AWS Management Console or AWS CLI to create an MBR-partitioned volume that exceeds the size limit, Windows cannot detect or use the additional space.

To overcome this limitation, you can create a new, larger volume with a GUID partition table (GPT) and copy over the data from the original MBR volume. 

**To create a GPT volume**

1. Create a new, empty volume of the desired size in the Availability Zone of the EC2 instance and attach it to your instance. 
**Note**  
The new volume must not be a volume restored from a snapshot.

1. Log in to your Windows system and open **Disk Management** (**diskmgmt.exe**). 

1. Open the context (right-click) menu for the new disk and choose **Online**.

1. In the **Initialize Disk** window, select the new disk and choose **GPT (GUID Partition Table)**, **OK**.

1. When initialization is complete, copy the data from the original volume to the new volume, using a tool such as robocopy or teracopy.

1. In **Disk Management**, change the drive letters to appropriate values and take the old volume offline.

1. In the Amazon EC2 console, detach the old volume from the instance, reboot the instance to verify that it functions properly, and delete the old volume.

# Request Amazon EBS volume modifications
<a name="requesting-ebs-volume-modifications"></a>

With Elastic Volumes, you can dynamically increase the size, increase or decrease the performance, and change the volume type of your Amazon EBS volumes without detaching them.

**Process overview**

1. (Optional) Before modifying a volume that contains valuable data, it is a best practice to create a snapshot of the volume in case you need to roll back your changes. For more information, see [Create Amazon EBS snapshots](ebs-creating-snapshot.md).

1. Request the volume modification.

1. Monitor the progress of the volume modification. For more information, see [Monitor the progress of Amazon EBS volume modifications](monitoring-volume-modifications.md).

1. If the size of the volume was modified, extend the volume's file system to take advantage of the increased storage capacity. For more information, see [Extend the file system after resizing an Amazon EBS volume](recognize-expanded-volume-linux.md).

**Topics**
+ [Modify an EBS volume using Elastic Volumes](#modify-ebs-volume)
+ [Modify an EBS volume if Elastic Volumes is not supported](#modify-volume-stop-start)
+ [Initialize Elastic Volumes support (if needed)](#initialize-modification-support)

## Modify an EBS volume using Elastic Volumes
<a name="modify-ebs-volume"></a>

Before you begin, see the following:
+ [Considerations](ebs-modify-volume.md#elastic-volumes-considerations)
+ [Limitations](ebs-modify-volume.md#elastic-volumes-limitations)
+ [Requirements](modify-volume-requirements.md)

------
#### [ Console ]<a name="console-modify-size"></a>

**To modify an EBS volume**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Volumes**.

1. Select the volume to modify and choose **Actions**, **Modify volume**.

1. The **Modify volume** screen displays the volume ID and the volume's current configuration, including type, size, IOPS, and throughput. Set new configuration values as follows:
   + To modify the type, choose a value for **Volume type**.
   + To modify the size, enter a new value for **Size**.
   + (`gp3`, `io1`, and `io2` only) To modify the IOPS, enter a new value for **IOPS**.
   + (`gp3` only) To modify the throughput, enter a new value for **Throughput**.

1. After you have finished changing the volume settings, choose **Modify**. When prompted for confirmation, choose **Modify**.

1. If you've increased the size of your volume, then you must also extend the volume's partition to make use of the additional storage capacity. For more information, see [Extend the file system after resizing an Amazon EBS volume](recognize-expanded-volume-linux.md).

1. (*Windows instances only*) If you increase the size of an NVMe volume on an instance that does not have the AWS NVMe drivers, you must reboot the instance to enable Windows to see the new volume size. For more information about installing the AWS NVMe drivers, see [AWS NVMe drivers](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/aws-nvme-drivers.html).

------
#### [ AWS CLI ]

**To modify an EBS volume**  
Use the [modify-volume](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-volume.html) command. For example, if you have a volume of type `gp2` with a size of 100 GiB, the following example changes its configuration to a volume of type `io1` with 10,000 IOPS and a size of 200 GiB.

```
aws ec2 modify-volume \
    --volume-id vol-01234567890abcdef \
    --volume-type io1 \
    --iops 10000 \
    --size 200
```

The following is example output.

```
{
    "VolumeModification": {
        "TargetSize": 200,
        "TargetVolumeType": "io1",
        "ModificationState": "modifying",
        "VolumeId": "vol-01234567890abcdef",
        "TargetIops": 10000,
        "StartTime": "2022-01-19T22:21:02.959Z",
        "Progress": 0,
        "OriginalVolumeType": "gp2",
        "OriginalIops": 300,
        "OriginalSize": 100
    }
}
```

If you've increased the size of your volume, then you must also extend the volume's partition to make use of the additional storage capacity. For more information, see [Extend the file system after resizing an Amazon EBS volume](recognize-expanded-volume-linux.md).

------
#### [ PowerShell ]

**To modify an EBS volume**  
Use the [Edit-EC2Volume](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2Volume.html) cmdlet. For example, if you have a volume of type `gp2` with a size of 100 GiB, the following example changes its configuration to a volume of type `io1` with 10,000 IOPS and a size of 200 GiB.

```
Edit-EC2Volume `
    -VolumeId vol-01234567890abcdef `
    -VolumeType io1 `
    -Iops 10000 `
    -Size 200
```

If you've increased the size of your volume, then you must also extend the volume's partition to make use of the additional storage capacity. For more information, see [Extend the file system after resizing an Amazon EBS volume](recognize-expanded-volume-linux.md).

------

## Modify an EBS volume if Elastic Volumes is not supported
<a name="modify-volume-stop-start"></a>

If you are using a supported instance type, you can use Elastic Volumes to dynamically modify the size, performance, and volume type of your Amazon EBS volumes without detaching them.

If you cannot use Elastic Volumes but you need to modify the root (boot) volume, you must stop the instance, modify the volume, and then restart the instance.

After the instance has started, you can check the file system size to see if your instance recognizes the larger volume space. On Linux, use the **df -h** command to check the file system size.

```
[ec2-user ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda1            7.9G  943M  6.9G  12% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
```

If the size does not reflect your newly expanded volume, you must extend the file system of your device so that your instance can use the new space. For more information, see [Extend the file system after resizing an Amazon EBS volume](recognize-expanded-volume-linux.md).

With Windows instances, you might have to bring the volume online in order to use it. For more information, see [Make an Amazon EBS volume available for use](ebs-using-volumes.md). You do not need to reformat the volume.

## Initialize Elastic Volumes support (if needed)
<a name="initialize-modification-support"></a>

Before you can modify a volume that was attached to an instance before November 3, 2016 23:40 UTC, you must initialize volume modification support using one of the following actions:
+ Detach and attach the volume
+ Stop and start the instance

------
#### [ Console ]

**To determine whether your instances are ready**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. On the navigation pane, choose **Instances**.

1. Choose the **Show/Hide Columns** icon (the gear). Select the **Launch time** attribute column and then choose **Confirm**.

1. Sort the list of instances by the **Launch Time** column. For each instance that was started before the cutoff date, choose the **Storage** tab and check the **Attachment time** column to see when its volumes were attached.

------
#### [ AWS CLI ]

**To determine whether your instances are ready**  
Use the following [describe-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html) command to determine whether the volume was attached before November 3, 2016 23:40 UTC.

```
aws ec2 describe-instances \
    --query "Reservations[*].Instances[*].[InstanceId,LaunchTime<='2016-11-01',BlockDeviceMappings[*][Ebs.AttachTime<='2016-11-01']]" \
    --output text
```

The first line of the output for each instance shows its ID and whether it was started before the cutoff date (True or False). The first line is followed by one or more lines that show whether each EBS volume was attached before the cutoff date (True or False). In the following example output, you must initialize volume modification for the first instance because it was started before the cutoff date and its root volume was attached before the cutoff date. The other instances are ready because they were started after the cutoff date.

```
i-e905622e              True
True
i-719f99a8              False
True
i-006b02c1b78381e57     False
False
False
i-e3d172ed              False
True
```

------
#### [ PowerShell ]

**To determine whether an instance is ready**  
Use the [Get-EC2Instance](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2Instance.html) cmdlet to determine whether a volume was attached before November 3, 2016 23:40 UTC.

```
(Get-EC2Instance `
    -InstanceId i-1234567890abcdef0).Instances.BlockDeviceMappings | `
     Format-Table @{Name="VolumeId";Expression={$_.Ebs.VolumeId}}, `
                  @{Name="AttachTime";Expression={$_.Ebs.AttachTime}}
```

The following is example output.

```
VolumeId              AttachTime
--------              ----------
vol-0b243c8d927752d2b 3/23/2020 12:21:14 AM
vol-043eadbeb4a8387c3 9/5/2020 7:39:22 PM
vol-0c3f0c4e55c082753 4/23/2019 4:07:40 PM
```

------

# Monitor the progress of Amazon EBS volume modifications
<a name="monitoring-volume-modifications"></a>

When you modify an EBS volume, it goes through a sequence of states. The volume enters the `modifying` state, the `optimizing` state, and finally the `completed` state. At this point, the volume is ready to be further modified. 

While the volume is in the `optimizing` state, your volume performance is in between the source and target configuration specifications. Transitional volume performance will be no less than the source volume performance. If you are downgrading IOPS, transitional volume performance is no less than the target volume performance.

Volume modification changes take effect as follows:
+ Size increases take effect once the volume modification reaches the `optimizing` state, which usually takes a few seconds.
+ Performance (IOPS and throughput) changes can take from a few minutes to a few hours to complete, depending on the requested volume configuration. Typically, a fully used 1-TiB volume can take about 6 hours to migrate to a new performance configuration. In some cases, it can take more than 24 hours for a new performance configuration to take effect, such as when the volume has not been fully initialized.

The possible volume states are `creating`, `available`, `in-use`, `deleting`, `deleted`, and `error`.

The possible modification states are `modifying`, `optimizing`, and `completed`.

------
#### [ Console ]

**To monitor progress of a modification**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Volumes**.

1. Select the volume.

1. The **Volume state** column and the **Volume state** field in the **Details** tab contain information in the following format: *Volume state* - *Modification state* (*Modification progress*%). The following image shows the volume and volume modification states.  
![\[Volume and volume modification states\]](http://docs.aws.amazon.com/ebs/latest/userguide/images/volume_state.png)

   After the modification completes, only the volume state is displayed. The modification state and progress are no longer displayed.

   Alternatively, you can use Amazon EventBridge to create a notification rule for volume modification events. For more information, see [Getting started with Amazon EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-get-started.html).

------
#### [ AWS CLI ]

**To monitor progress of a modification**  
Use the [describe-volumes-modifications](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-volumes-modifications.html) command to view the progress of one or more volume modifications. The following example describes the volume modifications for two volumes.

```
aws ec2 describe-volumes-modifications \
    --volume-ids vol-11111111111111111 vol-22222222222222222
```

In the following example output, the volume modifications are still in the `modifying` state. Progress is reported as a percentage.

```
{
    "VolumesModifications": [
        {
            "TargetSize": 200,
            "TargetVolumeType": "io1",
            "ModificationState": "modifying",
            "VolumeId": "vol-11111111111111111",
            "TargetIops": 10000,
            "StartTime": "2017-01-19T22:21:02.959Z",
            "Progress": 0,
            "OriginalVolumeType": "gp2",
            "OriginalIops": 300,
            "OriginalSize": 100
        },
        {
            "TargetSize": 2000,
            "TargetVolumeType": "sc1",
            "ModificationState": "modifying",
            "VolumeId": "vol-22222222222222222",
            "StartTime": "2017-01-19T22:23:22.158Z",
            "Progress": 0,
            "OriginalVolumeType": "gp2",
            "OriginalIops": 300,
            "OriginalSize": 1000
        }
    ]
}
```

The next example describes all volumes with a modification state of either `optimizing` or `completed`, and then filters and formats the results to show only modifications that were initiated on or after February 1, 2017:

```
aws ec2 describe-volumes-modifications \
    --filters Name=modification-state,Values="optimizing","completed" \
    --query "VolumesModifications[?StartTime>='2017-02-01'].{ID:VolumeId,STATE:ModificationState}"
```

The following is example output with information about two volumes:

```
[
    {
        "STATE": "optimizing",
        "ID": "vol-06397e7a0eEXAMPLE"
    },
    {
        "STATE": "completed",
        "ID": "vol-ba74e18c2aEXAMPLE"
    }
]
```

------
#### [ PowerShell ]

**To monitor progress of a modification**  
Use the [Get-EC2VolumeModification](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2VolumeModification.html) cmdlet. The following example describes the volume modifications for two volumes.

```
Get-EC2VolumeModification `
    -VolumeId vol-11111111111111111 vol-22222222222222222
```

------

**Note**  
Rarely, a transient AWS fault can result in a `failed` state. This is not an indication of volume health; it merely indicates that the modification to the volume failed. If this occurs, retry the volume modification.

# Extend the file system after resizing an Amazon EBS volume
<a name="recognize-expanded-volume-linux"></a>

After you [increase the size of an EBS volume](requesting-ebs-volume-modifications.md), you must extend the partition and file system to the new, larger size. You can do this as soon as the volume enters the `optimizing` state.

## Before you begin
<a name="extend-file-system"></a>
+ Create a snapshot of the volume, in case you need to roll back your changes. For more information, see [Create Amazon EBS snapshots](ebs-creating-snapshot.md).
+ Confirm that the volume modification succeeded and that it is in the`optimizing` or `completed` state. For more information, see [Monitor the progress of Amazon EBS volume modifications](monitoring-volume-modifications.md).
+ Ensure that the volume is attached to the instance and that it is formatted and mounted. For more information, see [Format and mount an attached volume](ebs-using-volumes.md#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 [ How do I use LVM to create a logical volume on an EBS volume's partition?](https://repost.aws/knowledge-center/create-lv-on-ebs-partition).

## Linux instances
<a name="extend-linux"></a>

**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
<a name="extend-file-system"></a>

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. To determine whether your instance is Xen-based or Nitro-based, see [ Amazon EC2 hypervisor type](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#instance-hypervisor-type).

**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).

1. Resize the partition, if needed. To do so:

   1. 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.

      ```
      [ec2-user ~]$ sudo 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
      ```

------
#### [ Xen instance example ]

      In the following example output, the root volume (`xvda`) has a partition (`xvda1`), while the additional volume (`xvdf`) has no partition.

      ```
      [ec2-user ~]$ sudo lsblk                
      NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
      xvda    202:0    0  16G  0 disk
      └─xvda1 202:1    0   8G  0 part /
      xvdf    202:80   0  24G  0 disk
      ```

------
      + If the volume has a partition, continue to the next step (2b).
      + If the volume has no partitions, skip steps 2b, 2c, and 2d, and continue to step 3.
**Troubleshooting tip**  
If you do not see the volume in the command output, ensure that the volume is [attached to the instance](ebs-attaching-volume.md), and that it is [formatted and mounted](ebs-using-volumes.md#ebs-format-mount-volume).

   1. 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 (2c).
      + If the partition size is equal to the volume size, the partition does not need to be extended - skip steps 2c and 2d, and continue to step 3.
**Troubleshooting tip**  
If the volume still reflects the original size, [ confirm that the volume modification succeeded](monitoring-volume-modifications.md).

   1. Extend the partition. Use the **growpart** command and specify the device name and the partition number.

------
#### [ Nitro instance example ]

      The partition number is the number after the `p`. For example, for `nvme0n1p1`, the partition number is `1`. For `nvme0n1p128`, the partition number is `128`.

      To extend a partition named `nvme0n1p1`, use the following command.

**Important**  
Note the space between the device name (`nvme0n1`) and the partition number (`1`).

      ```
      [ec2-user ~]$ sudo growpart /dev/nvme0n1 1
      ```

------
#### [ Xen instance example ]

      The partition number is the number after the device name. For example, for `xvda1`, the partition number is `1`. For `xvda128`, the partition number is `128`.

      To extend a partition named `xvda1`, use the following command.

**Important**  
Note the space between the device name (`xvda`) and the partition number (`1`).

      ```
      [ec2-user ~]$ sudo growpart /dev/xvda 1
      ```

------
**Troubleshooting tips**  
`mkdir: cannot create directory ‘/tmp/growpart.31171’: No space left on device FAILED: failed to make temp dir`: Indicates that there is not enough free disk space on the volume for growpart to create the temporary directory it needs to perform the resize. Free up some disk space and then try again.
`must supply partition-number`: Indicates that you specified an incorrect partition. Use the **lsblk** command to confirm the partition name, and ensure that you enter a space between the device name and the partition number.
`NOCHANGE: partition 1 is size 16773087. it cannot be grown`: Indicates that the partition already extends the entire volume and can't be extended. [Confirm that the volume modification succeeded](monitoring-volume-modifications.md).

   1. Verify that the partition has been extended. Use the **lsblk** command. The partition size should now be equal to the volume size.

------
#### [ Nitro instance example ]

      The following example output shows that both the volume (`nvme0n1`) and the partition (`nvme0n1p1`) are the same size (`16 GB`).

      ```
      [ec2-user ~]$ sudo 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
      ```

------
#### [ Xen instance example ]

      The following example output shows that both the volume (`xvda`) and the partition (`xvda1`) are the same size (`16 GB`).

      ```
      [ec2-user ~]$ sudo lsblk               
      NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
      xvda    202:0    0  16G  0 disk
      └─xvda1 202:1    0  16G  0 part /
      xvdf    202:80   0  24G  0 disk
      ```

------

1. Extend the file system.

   1. Get the name, size, type, and mount point for the file system that you need to extend. Use the **df -hT** or **lsblk -f** command.

------
#### [ Nitro instance example ]

      The following example output for the **df -hT** command shows that the `/dev/nvme0n1p1` file system is 8 GB in size, its type is `xfs`, and its mount point is `/`.

      ```
      [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
      ...
      ```

------
#### [ Xen instance example ]

      The following example output for the **df -hT** command shows that the `/dev/xvda1` file system is 8 GB in size, its type is `ext4`, and its mount point is `/`.

      ```
      [ec2-user ~]$ df -hT
      Filesystem      Type   Size    Used   Avail   Use%   Mounted on
      /dev/xvda1      ext4   8.0G    1.9G   6.2G    24%    /
      /dev/xvdf1      xfs    24.0G   45M    8.0G    1%     /data
      ...
      ```

------
      + If the file system size is smaller than the volume size, continue to the next step (3b).
      + If the file system size is equal to the volume size, then it does not need to be extended. In this case, skip the remaining steps - the partition and file system have been extended to the new volume size.

       

   1. The commands to extend the file system differ depending on the file system type. Choose the following correct command based on the file system type that you noted in the previous step.
      + **[XFS file system]** Use the **xfs\$1growfs** command and specify the mount point of the file system that you noted in the previous step.

------
#### [ Nitro and Xen instance example ]

        For example, to extend a file system mounted on `/`, use the following command.

        ```
        [ec2-user ~]$ sudo xfs_growfs -d /
        ```

------
**Troubleshooting tips**  
`xfs_growfs: /data is not a mounted XFS filesystem`: Indicates that you specified the incorrect mount point, or the file system is not XFS. To verify the mount point and file system type, use the **df -hT** command.
`data size unchanged, skipping`: Indicates that the file system already extends the entire volume. If the volume has no partitions, [ confirm that the volume modification succeeded](monitoring-volume-modifications.md). If the volume has partitions, ensure that the partition was extended as described in step 2.
      + **[Ext4 file system]** Use the **resize2fs** command and specify the name of the file system that you noted in the previous step.

------
#### [ Nitro instance example ]

        For example, to extend a file system mounted named `/dev/nvme0n1p1`, use the following command.

        ```
        [ec2-user ~]$ sudo resize2fs /dev/nvme0n1p1
        ```

------
#### [ Xen instance example ]

        For example, to extend a file system mounted named `/dev/xvda1`, use the following command.

        ```
        [ec2-user ~]$ sudo resize2fs /dev/xvda1
        ```

------
**Troubleshooting tips**  
`resize2fs: Bad magic number in super-block while trying to open /dev/xvda1`: Indicates that the file system is not Ext4. To verify file the system type, use the **df -hT** command.
`open: No such file or directory while opening /dev/xvdb1`: Indicates that you specified an incorrect partition. To verify the partition, use the **df -hT** command.
`The filesystem is already 3932160 blocks long. Nothing to do!`: Indicates that the file system already extends the entire volume. If the volume has no partitions, [confirm that the volume modification succeeded](monitoring-volume-modifications.md). If the volume has partitions, ensure that the partition was extended, as described in step 2.
      + **[Other file system]** See the documentation for your file system for instructions.

   1. Verify that the file system has been extended. Use the **df -hT** command and confirm that the file system size is equal to the volume size.

## Windows instances
<a name="extend-windows"></a>

Use one of the following methods to extend the file system on a Windows instance.

------
#### [ Disk Management utility ]

**To extend a file system using Disk Management**

1. Before extending a file system that contains valuable data, it is a best practice to create a snapshot of the volume that contains it in case you need to roll back your changes. For more information, see [Create Amazon EBS snapshots](ebs-creating-snapshot.md).

1. Log in to your Windows instance using Remote Desktop.

1. In the **Run** dialog, enter **diskmgmt.msc** and press Enter. The Disk Management utility opens.  
![\[Windows Server Disk Management Utility\]](http://docs.aws.amazon.com/ebs/latest/userguide/images/Expand-Volume-Win2008-before.png)

1. On the **Disk Management** menu, choose **Action**, **Rescan Disks**.

1. Open the context (right-click) menu for the expanded drive and choose **Extend Volume**.
**Note**  
**Extend Volume** might be disabled (grayed out) if:  
The unallocated space is not adjacent to the drive. The unallocated space must be adjacent to the right side of the drive you want to extend.
The volume uses the Master Boot Record (MBR) partition style and it is already 2TB in size. Volumes that use MBR cannot exceed 2TB in size.  
![\[Windows Server Disk Management Utility\]](http://docs.aws.amazon.com/ebs/latest/userguide/images/Expand-Volume-Win2008-before-menu.png)

1. In the **Extend Volume** wizard, choose **Next**. For **Select the amount of space in MB**, enter the number of megabytes by which to extend the volume. Generally, you specify the maximum available space. The highlighted text under **Selected** is the amount of space that is added, not the final size the volume will have. Complete the wizard.  
![\[Windows Server Extend Volume Wizard\]](http://docs.aws.amazon.com/ebs/latest/userguide/images/Extend-Volume-Wizard-Win2008.png)

1. If you increase the size of an NVMe volume on an instance that does not have the AWS NVMe driver, you must reboot the instance to enable Windows to see the new volume size. For more information about installing the AWS NVMe driver, see [AWS NVMe drivers](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/aws-nvme-drivers.html).

------
#### [ PowerShell ]

Use the following procedure to extend a Windows file system using PowerShell.

**To extend a file system using PowerShell**

1. Before extending a file system that contains valuable data, it is a best practice to create a snapshot of the volume that contains it in case you need to roll back your changes. For more information, see [Create Amazon EBS snapshots](ebs-creating-snapshot.md).

1. Log in to your Windows instance using Remote Desktop.

1. Run PowerShell as an administrator.

1. Run the `Get-Partition` command. PowerShell returns the corresponding partition number for each partition, the drive letter, offset, size, and type. Note the drive letter of the partition to extend.

1. Run the following command to rescan the disk.

   ```
   "rescan" | diskpart
   ```

1. Run the following command, using the drive letter you noted in step 4 in place of **<drive-letter>**. PowerShell returns the minimum and maximum size of the partition allowed, in bytes.

   ```
   Get-PartitionSupportedSize -DriveLetter <drive-letter>
   ```

1. To extend the partition to a specified amount, run the following command, entering the new size of the volume in place of **<size>**. You can enter the size in `KB`, `MB`, and `GB`; for example, `50GB`.

   ```
   Resize-Partition -DriveLetter <drive-letter> -Size <size>
   ```

   To extend the partition to the maximum available size, run the following command.

   ```
   Resize-Partition -DriveLetter <drive-letter> -Size $(Get-PartitionSupportedSize -DriveLetter <drive-letter>).SizeMax
   ```

   The following PowerShell commands show the complete command and response flow for extending a file system to a specific size.  
![\[Extend a partition using PowerShell - specific\]](http://docs.aws.amazon.com/ebs/latest/userguide/images/ebs-extend-powershell-v3-specific.png)

   The following PowerShell commands show the complete command and response flow for extending a file system to the maximum available size.  
![\[Extend a partition using PowerShell - max\]](http://docs.aws.amazon.com/ebs/latest/userguide/images/ebs-extend-powershell-v3-max.png)

------