I Tried Changing an Amazon EBS Root Volume from gp3 to gp3a

I Tried Changing an Amazon EBS Root Volume from gp3 to gp3a

After re-attaching, fstrim cut the stored data on a 2,048 GiB root volume from 102 GiB to 52 GiB. The gp3a change was done online in about an hour. Enabling TRIM requires re-attaching, and for root volumes, stopping the instance.
2026.12.02

This page has been translated by machine translation. View original

Introduction

On November 30, 2026, Adaptive Volumes for Amazon EBS was announced.

https://aws.amazon.com/about-aws/whats-new/2026/11/ebs-adaptive-volumes/

gp3a, the general purpose SSD volume type of Adaptive Volumes, is billed based on the amount of data stored rather than the size of the volume.

The following article covers how the amount of stored data changes when writing to and deleting from a gp3a volume, changing a running gp3 volume to gp3a, and monthly cost estimates by size and utilization.

https://dev.classmethod.jp/articles/amazon-ebs-adaptive-volumes-gp3a/

This article describes the steps I took to change a root volume from gp3 to gp3a.

Test Environment

  • Region: Tokyo (ap-northeast-1)
  • Instance type: t9g.small (arm64)
  • OS: Amazon Linux 2023
    • Kernel: 6.18
    • File system: XFS
  • AWS CLI: 2.43.0
  • Root volume (before the change)
    • Type: gp3
    • Size: 2,048 GiB
    • IOPS: 3,000
    • Throughput: 125 MiB/s

Preparing the Root Volume

I launched an instance with the root volume size set to 2,048 GiB.

aws ec2 run-instances \
  --image-id <AMI ID> \
  --instance-type t9g.small \
  --block-device-mappings '[{"DeviceName":"/dev/xvda","Ebs":{"VolumeSize":2048,"VolumeType":"gp3","DeleteOnTermination":true}}]'

I wrote 100 files of 1 GiB each, using the output of openssl enc (an encrypted stream of zeros). The total is about 100 GiB, which is about 5% of 2,048 GiB.

Write script (remote-write.sh)

Run it by passing the number of files to write (100) as an argument.

#!/bin/bash
N=${1:-100}; D=/var/tmp/wl; mkdir -p $D
echo "write start $(date -Is) n=$N"
for i in $(seq -w 1 $N); do
  openssl enc -aes-128-ctr -pass pass:seed$i -pbkdf2 -md sha256 < /dev/zero 2>/dev/null | dd of=$D/f$i.bin bs=1M count=1024 iflag=fullblock conv=fsync 2>/dev/null
  echo "f$i $(date +%T)"
done
echo "write end $(date -Is)"
sync
df -B1 /

Changing to gp3a

I changed the running root volume to gp3a with 1,000 IOPS using modify-volume.

aws ec2 modify-volume --volume-id vol-0123456789abcdef0 --volume-type gp3a --iops 1000

Here is an excerpt of the response.

{
    "VolumeModification": {
        "ModificationState": "modifying",
        "TargetIops": 1000,
        "TargetVolumeType": "gp3a",
        "OriginalIops": 3000,
        "OriginalVolumeType": "gp3",
        "TargetTrimOnAttach": "enabled"
    }
}

Even without specifying TrimOnAttach, TargetTrimOnAttach was set to enabled.

I confirmed the completion of the change with describe-volumes-modifications.

aws ec2 describe-volumes-modifications --volume-ids vol-0123456789abcdef0
{
    "VolumesModifications": [
        {
            "ModificationState": "completed",
            "StartTime": "2026-12-01T11:14:49+00:00",
            "EndTime": "2026-12-01T12:15:41+00:00"
        }
    ]
}

For the 2,048 GiB volume with about 100 GiB written, the change took 60 minutes 52 seconds to complete.

When I ran describe-volumes after completion, TrimOnAttach was enabled, but TrimState remained disabled.

aws ec2 describe-volumes --volume-ids vol-0123456789abcdef0 --query 'Volumes[].{VolumeType:VolumeType,Size:Size,Iops:Iops,Throughput:Throughput,TrimOnAttach:TrimOnAttach,Attachments:Attachments[].{Device:Device,TrimState:TrimState,State:State,DeleteOnTermination:DeleteOnTermination}}' --output json

The output is an excerpt.

[
    {
        "VolumeType": "gp3a",
        "Iops": 1000,
        "TrimOnAttach": "enabled",
        "Attachments": [
            {
                "TrimState": "disabled",
                "DeleteOnTermination": true
            }
        ]
    }
]

Enabling TRIM

To enable TRIM, you need to detach and reattach the volume. See the user guide for details.

https://docs.aws.amazon.com/ebs/latest/userguide/ebs-trim.html

Reattaching

Detaching a root volume requires stopping the instance. I performed stop, detach, reattach, and start with the following steps.

aws ec2 stop-instances --instance-ids i-0123456789abcdef0
aws ec2 detach-volume --volume-id vol-0123456789abcdef0
aws ec2 attach-volume --volume-id vol-0123456789abcdef0 --instance-id i-0123456789abcdef0 --device /dev/xvda
aws ec2 start-instances --instance-ids i-0123456789abcdef0

In describe-volumes after reattaching, TrimState became enabled. On the other hand, DeleteOnTermination changed from true, which was specified in run-instances, to false (output is an excerpt).

[
    {
        "VolumeType": "gp3a",
        "Iops": 1000,
        "TrimOnAttach": "enabled",
        "Attachments": [
            {
                "TrimState": "enabled",
                "DeleteOnTermination": false
            }
        ]
    }
]

When TrimState Is disabled

On a root volume changed to gp3a, running fstrim -v / while TrimState was still disabled failed with the following error.

fstrim: /: the discard operation is not supported

The snapshot taken after fstrim failed had a size of 6,178,734,080 bytes and 11,785 blocks, the same as before fstrim. No space had been released.

Stored Data Before and After fstrim

After changing to gp3a, I confirmed that deleting files and running fstrim releases blocks. Because the CloudWatch metric VolumeConsumedBytes is recorded at 1-hour intervals, I checked the sizes before and after fstrim using snapshots.

Steps for deletion, taking a snapshot, fstrim, and taking a snapshot

Of the 100 files I wrote, I deleted 50 (50 GiB) after the change to gp3a completed and before reattaching.

for i in $(seq 1 50); do rm -f /var/tmp/wl/f$(printf %03d $i).bin; done
sync

After reattaching, I created snapshot s1 before fstrim and snapshot s2 after it.

aws ec2 create-snapshot --volume-id vol-0123456789abcdef0
fstrim -v /
/: 2 TiB (2199011700736 bytes) trimmed

I obtained the size with describe-snapshots and the block count with list-snapshot-blocks. Because list-snapshot-blocks returns only some of the blocks per response, I repeated it until no NextToken was returned and summed the results.

aws ec2 describe-snapshots --snapshot-ids snap-0123456789abcdef0 --query 'Snapshots[].{SnapshotId:SnapshotId,State:State,VolumeSize:VolumeSize,FullSnapshotSizeInBytes:FullSnapshotSizeInBytes}' --output json

aws ebs list-snapshot-blocks --snapshot-id snap-0123456789abcdef0 --query '{BlockSize:BlockSize,BlockCount:length(Blocks)}' --output json
s1 (after deletion, before fstrim) s2 (after fstrim) Difference
Size 109,732,954,112 bytes (102.20 GiB) 55,905,878,016 bytes (52.07 GiB) 53,827,076,096 bytes (50.13 GiB)
Block count 209,299 106,632 102,667

I confirmed that the block count decreased after fstrim.

Calculating Monthly Costs

I calculated the monthly costs under the conditions of 3,000 IOPS and 125 MiB/s for gp3, and 1,000 IOPS and 125 MiB/s for gp3a. The unit prices and formulas are the same as in "Monthly cost estimates" in the previous article. The stored amount is derived from the size and utilization.

Size Utilization Stored amount gp3 gp3a Difference
250 GiB 10% 25.00 GiB $24.00 $14.40 −$9.60 (−40%)
1,024 GiB 5% 51.20 GiB $98.30 $16.92 −$81.39 (−83%)
4,096 GiB 5% 204.80 GiB $393.22 $31.66 −$361.56 (−92%)
16,384 GiB 5% 819.20 GiB $1,572.86 $82.98 −$1,489.88 (−95%)

Summary

I changed a running gp3 root volume to gp3a and confirmed the reduction in stored data with fstrim.

Changing the volume type (gp3 to gp3a) can be done online, but to reduce costs with gp3a, you need to detach and reattach the volume and run TRIM. Note that for a root volume, stopping the instance is required.

Also, with gp3, performance up to 3,000 IOPS and 125 MiB/s is not charged, but if you switch to gp3a while keeping the gp3 settings, costs tend to increase for small volumes (250 GiB or less). Before changing to gp3a, estimate the costs including IOPS and throughput. We also recommend duplicating a test environment from an AMI or similar to check how long the change takes and how much capacity fstrim can release.


コスト最適化、打ちっぱなしで元通りになっていませんか

タグ付けも不要リソースの棚卸しも、施策は打てる。でも続ける仕組みがなければ、コストは数か月でじわじわ戻る。一度きりで終わらせず、FinOpsを組織に定着させる=CCoEの役割。最適化を回し続ける進め方を、無料資料にまとめました。

CCoE総合支援

FinOpsを定着させる資料をもらう

Share this article

AWSのお困り事はクラスメソッドへ