Back to Top

Disk resizing procedure

This procedure presents a high level procedure and the considerable precautions when resizing volumes/disks in CloudStack (release 4.5.1-SSC-2). Volume resizing is supported for DATA disks only.

The high level procedure looks as following:

  1. Make sure that the volume you are resizing is NOT actively used. This means the volume is either not attached to VM (volume is detached) or if the volume is attached, please make sure that the VM is stopped, so again the volume is not actively used at this point. Optionally you can experiment with unmounting the volume in the OS, so again it is not actively used. However, it might be the best to stop the VM or detach the volume in order to avoid any volume corruption
  2. From the ACS GUI, select the desired volume and click on the resize button: 
  3. Please select the desired Disk offering (size and speed) - usually you will want to make sure the new Volume size is bigger than the original volume. Although volume shrinking is supported, it may lead to file-system corruption in many cases and is generally risky to use, unless you are very proficient with volume/partition/filesystem changes. 
  4. After the volume is resized, you can attach it again to a VM, or if already attached, restart the VM.

All steps performed so far result in having the "physical" volume/disk resized.

But this does not resize partitions and file-systems inside the volume/disk. Resizing partitions and file-systems is up to the user to do on his/her own, taking into consideration many different type of setups that can exist with different partition types, different file-systems etc.

 

Example procedure for Linux

Here is a high-level procedure for increasing partition and file-system size, for Linux/CentOS - using just basic tools (optionally you can use dedicated Live Linux or Windows distribution with special partition-managing tools.

  • Boot the VM and make sure the data disk is unmounted. 
  • Increase the partition size of the volume (we assume here single partition i.e. /dev/vdb1)
    • Use fdisk utility to print/list a partition table - write down the kind of partition, number of partition and starting sector of the partition
    • Use fdisk utility to delete /dev/vdb1 partition
    • Use fdisk utility to create a new partition, of the same kind, of the same number and the same starting sector and maximum ending sector
    • This way we effectively changed the end sector of the partition which actually makes the partition bigger
    • Confirm partition changes
  • Use the resize2fs command to resize the file-system on /dev/vdb1 partition - this tools works online-resize also (i.e. while /dev/vdb1 is mounted, if needed)
  • Finally check free disk space with "df -h"

 

Important note on shrinking volumes

As already mentioned, although you can shrink volumes (reduce volume size), it is absolutely not recommended to do so, unless you are very proficient with the whole file-system and partition resize procedure and understand the math and calculations behind disk sectors. Incorrect volume shrinking will result in corrupted and unusable file-systems, so please be warned.
For volume shrinking, the procedure is reverse to that of volume size increasing.
If i.e. resizing a volume from 50GB to 10GB, the safest (but not most accurate)  option would be to resize the file-system to 9.5GB, then resize the partition to 9.7GB and finally resize the volume to 10GB. This way, although some amount of space is "wasted", the volume is still big enough to hold the whole partition, and the partition is big enough to hold the whole file-system, so no corruption would happen in this case.