Skip to content

Extend Volumes

Extending volumes in OpenStack can be performed for both the root volume and additional data volumes. Here, we will discuss the processes for both cases.

Important

Always ensure you have proper backups before performing any volume operations.

Extend the Root Volume

  • Shut off the Instance: navigate to Project > Compute > Instances and in the Actions dropdown select Shut Off Instance.
  • Extend the Volume: navigate to Project > Compute > Volumes and in the Actions column click Extend Volume. In the popup window that appears specify the new size of the volume and click Extend Volume.
  • Start the Instance: Once the volume is extended, navigate to Project > Compute > Instances and in the Actions dropdown select Start Instance.

Stop the server (if successful, no output):

openstack server stop <server_id>

Verify the results:

openstack server list
Example output
+--------------------------------------+------------------+---------+------------------------------------------------+--------------------------+----------+
| ID                                   | Name             | Status  | Networks                                       | Image                    | Flavor   |
+--------------------------------------+------------------+---------+------------------------------------------------+--------------------------+----------+
| 525f7b2c-6d71-4123-988f-e637e383fbd6 | my-CLI-instance2 | ACTIVE  | myNetwork=192.168.11.150, 2001:620:6:e021::1b  | N/A (booted from volume) | c001r001 |
| f946a80d-1e24-462e-a297-25293bc12f86 | my-CLI-instance  | SHUTOFF | myNetwork=192.168.11.163, 2001:620:6:e021::31a | N/A (booted from volume) | c001r001 |
+--------------------------------------+------------------+---------+------------------------------------------------+--------------------------+----------+

Get Volume ID of the root volume:

openstack server volume list <server_id>
Example output
+----------+--------------------------------------+--------------------------------------+------+------------------------+--------------------------------------+--------------------------------------+
| Device   | Server ID                            | Volume ID                            | Tag  | Delete On Termination? | Attachment ID                        | BlockDeviceMapping UUID              |
+----------+--------------------------------------+--------------------------------------+------+------------------------+--------------------------------------+--------------------------------------+
| /dev/sda | f946a80d-1e24-462e-a297-25293bc12f86 | 83d11c7a-d11f-4fb1-b74a-ce85f3fcd5d6 | None | False                  | 31b883ec-f8b4-4ca1-b46d-cb44c73ca449 | 707562f6-b73a-4faa-82cc-810dccf0c740 |
+----------+--------------------------------------+--------------------------------------+------+------------------------+--------------------------------------+--------------------------------------+

Extend the volume (if successful, no output):

openstack --os-volume-api-version 3.54 volume set --size <size_in_GB> <volume_id>

Verify the volume size:

openstack volume list
Example output
+--------------------------------------+------+-----------+------+-------------------------------------------+
| ID                                   | Name | Status    | Size | Attached to                               |
+--------------------------------------+------+-----------+------+-------------------------------------------+
| 66f13145-1f7f-43e5-9f86-e640465defdd |      | available |   20 |                                           |
| 563fcad7-9579-48cd-aaec-ed916d5adf7b |      | in-use    |   20 | Attached to my-CLI-instance2 on /dev/sda  |
| 83d11c7a-d11f-4fb1-b74a-ce85f3fcd5d6 |      | in-use    |   60 | Attached to my-CLI-instance on /dev/sda   |
+--------------------------------------+------+-----------+------+-------------------------------------------+

Restart the server; the server will automatically resize its filesystem (if succesful, no output):

openstack server start <server_id>

Verify the server is active:

openstack server list
Example output
+--------------------------------------+------------------+--------+------------------------------------------------+--------------------------+----------+
| ID                                   | Name             | Status | Networks                                       | Image                    | Flavor   |
+--------------------------------------+------------------+--------+------------------------------------------------+--------------------------+----------+
| 525f7b2c-6d71-4123-988f-e637e383fbd6 | my-CLI-instance2 | ACTIVE | myNetwork=192.168.11.150, 2001:620:6:e021::1b  | N/A (booted from volume) | c001r001 |
| f946a80d-1e24-462e-a297-25293bc12f86 | my-CLI-instance  | ACTIVE | myNetwork=192.168.11.163, 2001:620:6:e021::31a | N/A (booted from volume) | c001r001 |
+--------------------------------------+------------------+--------+------------------------------------------------+--------------------------+----------+

To further verify you can connect to the instance:

ssh -i /path/to/private_key user@server_ip

Verify the disk size by listing block devices:

lsblk
Example output
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda       8:0    0   60G  0 disk
├─sda1    8:1    0   59G  0 part /
├─sda14   8:14   0    4M  0 part
├─sda15   8:15   0  106M  0 part /boot/efi
└─sda16 259:0    0  913M  0 part /boot

Check the Filesystem Size:

df -h
Example output
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            96M  1.1M   95M   2% /run
efivarfs        256K   17K  235K   7% /sys/firmware/efi/efivars
/dev/sda1        58G  1.5G   56G   3% /
tmpfs           479M     0  479M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda16      881M   61M  758M   8% /boot
/dev/sda15      105M  6.1M   99M   6% /boot/efi
tmpfs            96M   12K   96M   1% /run/user/1000

Extend Additional Data Volumes

For additional data volumes, the process does not require shutting down and starting the instance. Otherwise, follow the same steps as outlined for extending the root volume.

However, you will need to resize the filesystem: use the resize2fs command within the instance to resize the filesystem to utilize the new volume size. Check the OpenStack CLI tab in this chapter.

For additional data volumes, the process does not require shutting down and starting the instance. Otherwise, follow the same steps as outlined for extending the root volume.

However, you will need to resize the filesystem.

Connect to the instance:

ssh -i /path/to/private_key user@server_ip

Verify the disk size by listing block devices:

lsblk
Example output
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda       8:0    0   60G  0 disk
├─sda1    8:1    0   59G  0 part /
├─sda14   8:14   0    4M  0 part
├─sda15   8:15   0  106M  0 part /boot/efi
└─sda16 259:0    0  913M  0 part /boot
sdb       8:16   0  100G  0 disk
└─sdb1    8:17   0  100G  0 part /mnt/data

Resize the filesystem:

sudo resize2fs /dev/sdb1

Verify the filesystem is resized:

df -h /mnt/data
Example output
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       100G  1.5G   98G   2% /mnt/data