-
Notifications
You must be signed in to change notification settings - Fork 9
How to resize a volume in Jetstream
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.
All of these first set of steps can be performed using either Exosphere, Horizon or using the OpenStack CLI.
- Stop the server the volume is attached to and power it off.
- Detach the volume from the server. Make note of which device it is mounted as (probably /dev/sdb).
- Create a snapshot of the current state of the volume.
- Use the OpenStack volume expand operation to increase the volume size to the desired amount.
- Attach the volume to the server to the device it is mounted as noted in step 2.
- Restart the server. Verify things work as expected.
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:
- SSH into the server in question.
- Run
sudo parted
. Inside theparted
tool run the following steps:-
select /dev/sdb
(substitute the device noted above if different) resizepart 1 100%
quit
-
- Run
sudo resize2fs /dev/sdb1
(substitute the device noted above if different)
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:
- Run
./build.rb terraform <server> "state pull" > .tmp/terraform_old.state
, which pulls Terraform's current state for the server. - Open the
.tmp/terraform_old.state
file in a text editor and edit thevolume_size
variable and increase the serial number. - 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.
Read this before updating this wiki.