Kategorien: Compute Cloud
How can I resize a VM’s volume?
Once in a while you may have the need for more storage space in an existing VM. How to accomplish this depends on the type of volume you need to enlarge.
Additional Volumes
If you are dealing with a volume that you attached additionally to you VM, then enlarging is rather straightforward.
- Connect to your virtual machine via SSH, and unmount the volume.
- Now login to the web interface, navigate to the volume page and detach the volume via ‚Manage Attachments‘ in the drop down menu on the right. (Or use the CLI Client)
- Then click on ‚Extend Volume‘ in the same drop down, and choose a new bigger size for it.
- After that you can attach the volume again via ‚Manage Attachments‘
- Adjust the partition layout of the volume if necessary from the virtual machine and mount the volume again.
- Finally enlarge the filesystem of the volume. For example in case of an xfs or ext4 filesystem use the xfs_growfs /mount/point or resize2fs /mount/point commands.
Root Volumes
Root volumes need special treatment, because you cannot detach them from an instance. There are two options:
Deleting the virtual machine
If you didn’t choose ‚Delete volume on instance‘ delete when creating the virtual machine, you can do the following:
- Delete the virtual machine.
- Go to the volume page, and extend the volume via the drop down ‚Manage Attachments‚.
- Then create a new virtual machine from this volume.
- Finally adjust the partition layout if necessary.
Using the Cinder CLI Client
First of all you have to install the OpenStack and Cinder command line tools on your local (Linux) computer. To install the Cinder CLI on Ubuntu do ‚apt install python3-cinderclient
‚.
- Shut down the instance using the OpenStack CLI command ‚
openstack server stop <INSTANCE-UUID
>‘ or by using the OpenStack Web UI selecting ‚Shut Off Instance‚ in the pull down menu. - When the instance state has changed to shutoff, call ‚
openstack server volume list
‚ and get theVOLUME_ID
of the/dev/vda
volume, i.e. the root volume. - Call ‚
cinder --os-volume-api-version 3.42 extend <VOLUME_ID> <NEW_SIZE>
‚ . - Restart the instance using Web UI or by calling ‚
openstack server start <INSTANCE-UUID
>‘ . - Finally adjust the partition layout if necessary and enlarge the filesystem, see above.