Skip to content

How to resize a volume in Jetstream

Ian edited this page Oct 18, 2023 · 1 revision

Ordinarily, we prefer to perform all operations in Terraform, if possible, but resizing volumes attached to containers is not currently supported in our Terraform / OpenStack setup on Jetstream v2. At best, Terraform can be used to delete a volume and create a new volume with an increased size mounted at the same point. However, if it's important to maintain the data on the volume follow the below steps.

Warnings

  • Volumes can only safely be resized to be larger than they were. If it is necessary to shrink a volume, you must backup the data, recreate a smaller volume and restore the data.
  • Volumes cannot be safely resized while they are in use. This means that the server they are attached to should be stopped and the volume should be detached.

Steps

Resize the Volume

All of these first set of steps can be performed using either Exosphere, Horizon or using the OpenStack CLI.

  1. Stop the server the volume is attached to and power it off.
  2. Detach the volume from the server. Make note of which device it is mounted as (probably /dev/sdb).
  3. Create a snapshot of the current state of the volume.
  4. Use the OpenStack volume expand operation to increase the volume size to the desired amount.
  5. Attach the volume to the server to the device it is mounted as noted in step 2.
  6. Restart the server. Verify things work as expected.

Update the partition table

At this point, the volume itself has been resized, but the partition table on the server needs to be updated to be able to use the additional space. To do this:

  1. SSH into the server in question.
  2. Run sudo parted. Inside the parted tool run the following steps:
    1. select /dev/sdb (substitute the device noted above if different)
    2. resizepart 1 100%
    3. quit
  3. Run sudo resize2fs /dev/sdb1 (substitute the device noted above if different)

Update the Terraform state

At this point, the volume has been resized and the server can make full use of it, but it is necessary to update the Terraform state so that future Terraform operations don't do anything unexpected. To do this, go to the Terraform project and pull down the latest version from Git, then:

  1. Run ./build.rb terraform <server> "state pull" > .tmp/terraform_old.state, which pulls Terraform's current state for the server.
  2. Open the .tmp/terraform_old.state file in a text editor and edit the volume_size variable and increase the serial number.
  3. Run ./build.rb terraform <server> "state push $PWD/.tmp/terraform_old.state", which will update the Terraform state for the server to reflect the changes.
Clone this wiki locally