# Grow or rename a volume

Make a volume bigger, attached or not, then grow the filesystem on it; or give it another name.

Replace _vol-1a2b3c4d_ with your volume's id and _12345678_ with the number in its device path
(**Device on the instance** in the volume's side panel).

**Important:**
A volume only grows; it cannot shrink. It is billed for the new size from then on.

## Prerequisites

- Permission for `ec2:ModifyVolume` (for growing and for renaming).
- In the console, also `ec2:DescribeVolumes` to open **Volumes** (without it the page says "Access
  denied").
- Room in the **Volume storage** quota (`ec2.volume-storage`) for the difference; else `409`
  "Quota exceeded: Volume storage (ec2.volume-storage) — …".
- To grow: the volume is no longer `creating` (else `409` "… can be grown once it is available (it
  is creating)"), and no snapshot or restore of it is in progress (`409` "Snapshot … of this volume
  is in progress; …" or "This volume is being restored from …; …"). The console offers **Resize**
  only for an **Available** or **In use** volume.

## Grow the volume

**Console**
1. Open **Compute**, then **Volumes**.
2. Open the volume's actions menu and choose **Resize**.
3. For **New size (GiB)**, enter a size above the current one, at most 10 000.
4. Choose **Grow volume**. The new size shows in the list.

To rename instead, choose **Rename** in the same menu, for **Name** enter the new name, and choose
**Rename**.

**CLI**
```sh
dcloud ec2 volumes modify vol-1a2b3c4d --size-gib 100
```

`--name` renames it in the same call.

**API**
```http
PATCH /ec2/api/volumes/vol-1a2b3c4d
{ "sizeGib": 100 }
```

`{ "name": "…" }` renames it. A smaller size is refused with `400` "A volume only grows: … is …
GiB".

In Terraform, a new `size_gib` replaces the `dcloud_volume`; grow it with the CLI or API instead.

## Grow the filesystem

The device is bigger now; the filesystem on it is not. On the instance:

```sh
# ext4 straight on the disk
sudo resize2fs /dev/disk/by-id/scsi-0HC_Volume_12345678
# XFS, by mount point
sudo xfs_growfs /data
```

An encrypted volume opens at its new size at its next unlock: reboot the instance (or unmount, run
`sudo cryptsetup close ews-vol-12345678`, detach and attach again). On an instance with the
volume helper you can instead grow the open mapping in place with
`sudo /usr/local/sbin/ews-volume-unlock resize 12345678`. Then run
`sudo resize2fs /dev/mapper/ews-vol-12345678`.

## Related

- [Create and attach a volume](create-and-attach-a-volume.md)
- `ec2.volumes.modify` · `dcloud ec2 volumes modify`
