# How to increase the storage size of mongodb when using aws ebs volume

**URL:** <https://forums.percona.com/t/how-to-increase-the-storage-size-of-mongodb-when-using-aws-ebs-volume/21638>\
**Category:** Percona Operator for MongoDB\
**Created:** [April 25, 2023, 8:55am UTC](https://forums.percona.com/t/how-to-increase-the-storage-size-of-mongodb-when-using-aws-ebs-volume/21638 "2023-04-25T08:55:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kay\_Khan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/kay_khan/32/17023_2.png) [@Kay\_Khan](https://forums.percona.com/u/Kay_Khan)\
**Post date:** [April 25, 2023, 8:55am UTC](https://forums.percona.com/t/how-to-increase-the-storage-size-of-mongodb-when-using-aws-ebs-volume/21638/1 "2023-04-25T08:55:13Z")

</div>

Hi friends,

I would like to know how to increase the storage size of mongodb. Hoping someone can guide me through what steps do i need to take to perform an inplace upgrade.

Currently i have a volumespec with `storage: "100Gi"`. I would like to increase the storage size to “200Gi”.

```auto
...
    volumeSpec:
      pvc:
        storageClassName: mongodb
        resources:
          requests:
            storage: 200Gi
...

```

I have tried to simply alter the value and helm upgrade. However that has no effect.

```auto
 helm upgrade psmdb-db percona/psmdb-db --namespace mongodb -f psmdb-db.values.yaml

```

**mongodb.stroageclass.yaml**

```auto
kubectl describe sc mongodb 
Name: mongodb
IsDefaultClass: No
Annotations: <none>
Provisioner: ebs.csi.aws.com
Parameters: fsType=xfs,type=gp3
AllowVolumeExpansion: True
MountOptions: <none>
ReclaimPolicy: Retain
VolumeBindingMode: WaitForFirstConsumer
Events: <none>

```

---

<div class="post-metadata">

**Author:** ![Kay\_Khan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/kay_khan/32/17023_2.png) [@Kay\_Khan](https://forums.percona.com/u/Kay_Khan)\
**Post date:** [April 25, 2023, 9:32am UTC](https://forums.percona.com/t/how-to-increase-the-storage-size-of-mongodb-when-using-aws-ebs-volume/21638/2 "2023-04-25T09:32:57Z")

</div>

I managed to find a solution and upgrade mongodb uisng the following blog post. [Percona Operator Volume Expansion Without Downtime](https://www.percona.com/blog/percona-operator-volume-expansion-without-downtime/)

Throughout this process i was connected to mongodb, there was no downtime and the dummy database and collection i had created was still there after the expansion.

1. Expand the size of PVC

```auto
kubectl patch pvc <pvc-kubectl -n mongodb patch pvc mongod-data-psmdb-db-rs0-0 -p '{ "spec": { "resources": { "requests": { "storage": "250Gi" }}}}'> -n <pvc-namespace> -p '{ "spec": { "resources": { "requests": { "storage": "NEW STORAGE VALUE" }}}}'

```

1. Check if it has expanded

```auto
kubectl describe pvc mongod-data-psmdb-db-rs0-0 -n mongodb
--
Normal FileSystemResizeSuccessful 2m25s kubelet MountVolume.NodeExpandVolume succeeded for volume "pvc-0c374fd9-d443-452d-97be-9fe2a70686ae" ip-10-0-1-96.eu-west-2.compute.internal

```

1. Check the mongodb pod has recognized the expansion

```auto
kubectl -n mongodb exec psmdb-db-rs0-0 -- lsblk
---
nvme2n1 259:4 0 250G 0 disk /data/db

```

1. Delete the current stateful set

```auto
kubectl -n mongodb delete sts psmdb-db-rs0 --cascade=orphan

```

1. Update the value and upgrade Helm

```auto
volumeSpec:
  pvc:
   storageClassName: mongodb
    resources:
      requests:
        storage: 250Gi

```

```auto
helm upgrade psmdb-db percona/psmdb-db --namespace mongodb -f psmdb-db.values.yaml

```

1. Check value of new stateful set

```auto
kubectl describe sts psmdb-db-rs0 -n mongodb
---
Capacity: 250Gi

```

* * *

**What are the side effects of NOT recreating the stateful set?**

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [April 28, 2023, 11:59am UTC](https://forums.percona.com/t/how-to-increase-the-storage-size-of-mongodb-when-using-aws-ebs-volume/21638/3 "2023-04-28T11:59:14Z")

</div>

The side effect would be that once you scale up the cluster, the new node will be created with the size specified in the stateful set.

Please let me know if it makes sense.
