Resizing Block Storage Volumes

This guide explains how to resize block storage volumes in Thalassa Cloud and expand the filesystem on your virtual machine. Resizing allows you to increase storage capacity without creating new volumes or migrating data.

Prerequisites

  • A block storage volume attached to a virtual machine in Thalassa Cloud
  • SSH access to the VM with root or sudo privileges
  • The volume must be attached and mounted on the VM
  • For ext4 filesystems: cloud-guest-utils or growpart package installed
  • For xfs filesystems: xfsprogs package installed

Note

You can only increase volume size, not decrease it. If you need to reduce storage, you’ll need to create a new smaller volume and migrate data.

Overview

The resize process involves three main steps:

  1. Resize the volume in Thalassa Cloud (via console, CLI, or API)
  2. Expand the partition on the VM using growpart
  3. Resize the filesystem using resize2fs (ext4) or xfs_growfs (xfs)

Step 1: Resize the Volume in Thalassa Cloud

First, increase the size of the block storage volume through the Thalassa Cloud console, CLI, or API.

Option A: Using the Console

  1. Navigate to IaaSStorageVolumes
  2. Select the volume you want to resize
  3. Click Resize or Edit
  4. Enter the new size (must be larger than the current size)
  5. Confirm the resize operation

Option B: Using the CLI

If you have the tcloud CLI installed, you can resize volumes using the API. Check the API Reference for the exact endpoint and parameters.

Verify Volume Resize

After resizing, verify the new volume size in the console or using the CLI:

tcloud storage volumes list

The volume should show the updated size. Note that the VM’s filesystem won’t reflect this change until you complete the steps below.

Step 2: Verify Current Block Device Status

SSH into your virtual machine and check the current state of block devices.

List Block Devices

Use lsblk to see all block devices and their current sizes:

lsblk

Example output:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0 63.8M  1 loop /snap/core20/2682
loop1    7:1    0 91.4M  1 loop /snap/lxd/36918
loop2    7:2    0 50.9M  1 loop /snap/snapd/25577
loop3    7:3    0 63.8M  1 loop /snap/core20/2686
loop4    7:4    0 48.1M  1 loop /snap/snapd/25935
sda      8:0    0  120G  0 disk
├─sda1   8:1    0 34.9G  0 part /
├─sda14  8:14   0    4M  0 part
└─sda15  8:15   0  106M  0 part /boot/efi

In this example, sda is the disk (120GB), and sda1 is the partition mounted at / (34.9GB). After resizing the volume in Thalassa Cloud, you’ll notice that the disk size (sda) has increased, but the partition size (sda1) hasn’t changed yet.

Check Filesystem Type

Determine the filesystem type to use the correct resize command:

df -T /

Or for a specific device:

sudo file -sL /dev/sda1

Common filesystem types:

  • ext4: Use resize2fs
  • xfs: Use xfs_growfs

Step 3: Expand the Partition

After the volume is resized in Thalassa Cloud, the partition table needs to be updated to use the new space. Use growpart to expand the partition.

Install growpart (if needed)

On Ubuntu/Debian:

sudo apt-get update
sudo apt-get install cloud-guest-utils

On RHEL/CentOS/Fedora:

sudo yum install cloud-utils-growpart
# or for newer versions:
sudo dnf install cloud-utils-growpart

Expand the Partition

Use growpart to expand the partition to fill the available space on the disk:

sudo growpart /dev/sda 1

Replace:

  • /dev/sda with your disk device (e.g., /dev/vdb, /dev/nvme0n1)
  • 1 with your partition number

Example output:

CHANGED: partition=1 start=227328 old: size=73172959 end=73400287 new: size=251430879 end=251658207

This shows that the partition has been expanded from the old size to the new size.

Warning

Always specify the partition number correctly. Expanding the wrong partition can cause data loss. Double-check with lsblk before running growpart.

Verify Partition Expansion

Check that the partition has been expanded:

lsblk

The partition size should now match the disk size (minus any other partitions).

Step 4: Resize the Filesystem

After expanding the partition, resize the filesystem to use the newly available space.

For ext4 Filesystems

Use resize2fs to expand the ext4 filesystem:

sudo resize2fs /dev/sda1

Replace /dev/sda1 with your partition device.

Example output:

resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 15
The filesystem on /dev/sda1 is now 31428859 (4k) blocks long.

Note

resize2fs can resize mounted filesystems online without unmounting. No downtime is required.

For xfs Filesystems

For xfs filesystems, use xfs_growfs:

sudo xfs_growfs /

Or specify the mount point directly:

sudo xfs_growfs /mnt/data

Note

xfs_growfs requires the mount point, not the device path. It can also resize mounted filesystems online.

Step 5: Verify the Resize

After completing all steps, verify that the filesystem has been successfully resized.

Check Filesystem Size

Use df to check the filesystem size and available space:

df -h /

Or for a specific mount point:

df -h /mnt/data

The output should show the new, larger size:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        120G   15G  100G  13% /

Compare with Block Device

Compare the filesystem size with the block device size:

lsblk

The partition size should match the disk size, and the filesystem should match the partition size.

Complete Example Workflow

Here’s a complete example workflow for resizing a volume:

# 1. Resize volume in Thalassa Cloud console
# Navigate to: IaaS → Storage → Volumes → Select volume → Resize to 120GB

# 2. SSH into the VM
ssh user@vm-ip

# 3. Check current status
lsblk
df -h /

# 4. Install growpart if needed (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install cloud-guest-utils

# 5. Expand the partition (example: /dev/sda, partition 1)
sudo growpart /dev/sda 1

# 6. Resize the filesystem (for ext4)
sudo resize2fs /dev/sda1

# 7. Verify the resize
df -h /
lsblk

Troubleshooting

growpart: command not found

Install the required package:

  • Ubuntu/Debian: sudo apt-get install cloud-guest-utils
  • RHEL/CentOS: sudo yum install cloud-utils-growpart
  • Fedora: sudo dnf install cloud-utils-growpart

resize2fs: Bad magic number

This error indicates the device doesn’t have an ext4 filesystem. Check the filesystem type:

sudo file -sL /dev/sda1

Use the appropriate command for your filesystem type (e.g., xfs_growfs for xfs).

Partition not expanding

If growpart doesn’t work, you may need to:

  1. Ensure the volume was actually resized in Thalassa Cloud
  2. Check that the partition has free space after it (use fdisk -l)
  3. For GPT partition tables, ensure there’s no backup partition table at the end

Filesystem resize fails

If filesystem resize fails:

  1. Ensure the partition was successfully expanded first
  2. Check filesystem for errors: sudo fsck /dev/sda1 (unmount first if possible)
  3. For ext4, try: sudo resize2fs -f /dev/sda1 (force flag)

Considerations and Limitations

  • Volume size can only be increased, not decreased. To reduce storage, create a new smaller volume and migrate data.
  • Online resizing is supported for both ext4 and xfs filesystems. No downtime is required.
  • Backup before resizing is recommended, especially for production systems.
  • Partition alignment is handled automatically by growpart.
  • Multiple partitions on the same disk require careful handling. Only the last partition can typically be expanded easily.

References