After resizing a block storage volume in the Cloud Control Panel, the additional space isn't automatically usable. You need to expand the partition and resize the filesystem to utilize the new capacity. This guide covers the process for both standard partitions and LVM configurations.
What You'll Learn
Important: Always create a backup or snapshot before modifying partitions. While these operations are generally safe, having a backup protects against unexpected issues.
Prerequisites
- Block storage volume already resized in the Cloud Control Panel
- Root or sudo access to the server
- The
cloud-guest-utilspackage (for growpart) - A recent backup or snapshot of your data
Install the required tools if not already present:
sudo apt update
sudo apt install cloud-guest-utils gdisk -ysudo dnf install cloud-utils-growpart gdisk -yCheck Current Layout
First, identify your block device and current partition layout. Block storage volumes are typically named /dev/vdb, /dev/sdb, or similar.
List Block Devices
lsblkExample output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 50G 0 disk
├─vda1 252:1 0 49G 0 part /
└─vda2 252:2 0 1G 0 part [SWAP]
vdb 252:16 0 200G 0 disk
└─vdb1 252:17 0 100G 0 part /mnt/storageNotice that vdb shows 200G total, but vdb1 is only 100G. This means there's 100G of unallocated space after the resize.
Check Filesystem Type
df -Th /mnt/storageExample output showing ext4:
Filesystem Type Size Used Avail Use% Mounted on
/dev/vdb1 ext4 98G 24G 70G 26% /mnt/storageCheck Partition Table Type
sudo fdisk -l /dev/vdb | grep "Disklabel type"This shows whether you have GPT or MBR (DOS) partition table. The growpart tool handles both.
Rescan the Device
After resizing the volume in the control panel, the kernel may need to rescan the device to detect the new size.
# For virtio devices (vdX)
echo 1 | sudo tee /sys/class/block/vdb/device/rescan
# For SCSI devices (sdX)
echo 1 | sudo tee /sys/class/block/sdb/device/rescan
# Alternative: rescan all SCSI hosts
for host in /sys/class/scsi_host/host*/scan; do
echo "- - -" | sudo tee $host
doneVerify the new size is detected:
lsblk /dev/vdbExpand the Partition
Use growpart to expand the partition to use all available space. This can be done online (while the filesystem is mounted).
Using growpart
The syntax is growpart DEVICE PARTITION_NUMBER:
# Expand partition 1 on /dev/vdb
sudo growpart /dev/vdb 1Expected output:
CHANGED: partition=1 start=2048 old: size=209713152 end=209715200 new: size=419428319 end=419430367Verify Partition Expansion
lsblk /dev/vdbThe partition should now show the full size:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdb 252:16 0 200G 0 disk
└─vdb1 252:17 0 200G 0 part /mnt/storageNote: If you see "NOCHANGE: partition 1 is size X", the partition is already using all available space. Ensure the block device resize was successful in the control panel.
Resize the Filesystem
After expanding the partition, resize the filesystem to use the new space. The command depends on your filesystem type.
For ext4 Filesystems
Use resize2fs to grow ext4 filesystems online:
sudo resize2fs /dev/vdb1Expected output:
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/vdb1 is mounted on /mnt/storage; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 25
The filesystem on /dev/vdb1 is now 52428539 (4k) blocks long.For XFS Filesystems
Use xfs_growfs with the mount point:
sudo xfs_growfs /mnt/storageNote: XFS can only be grown while mounted. Use the mount point, not the device path.
Verify Filesystem Size
df -h /mnt/storageThe filesystem should now show the full capacity:
Filesystem Size Used Avail Use% Mounted on
/dev/vdb1 197G 24G 164G 13% /mnt/storageLVM Volume Expansion
If your block storage uses LVM (Logical Volume Manager), the process involves expanding the physical volume, then the logical volume, and finally the filesystem.
Step 1: Expand the Partition
First, expand the partition as shown above:
sudo growpart /dev/vdb 1Step 2: Resize the Physical Volume
sudo pvresize /dev/vdb1Verify the PV size:
sudo pvsStep 3: Extend the Logical Volume
Extend the LV to use all available space (replace with your VG and LV names):
# Use 100% of free space
sudo lvextend -l +100%FREE /dev/mapper/vg_data-lv_storage
# Or extend by a specific amount
sudo lvextend -L +50G /dev/mapper/vg_data-lv_storageStep 4: Resize the Filesystem
sudo resize2fs /dev/mapper/vg_data-lv_storagesudo xfs_growfs /mnt/storageOne-Command LVM Resize
With recent versions of LVM, you can extend and resize in one command:
# For ext4
sudo lvextend -l +100%FREE --resizefs /dev/mapper/vg_data-lv_storage
# For XFS
sudo lvextend -l +100%FREE /dev/mapper/vg_data-lv_storage
sudo xfs_growfs /mnt/storageVerification
After completing the expansion, verify everything is working correctly:
# Check filesystem size
df -h /mnt/storage
# Check partition layout
lsblk /dev/vdb
# Check filesystem integrity (optional, for ext4)
sudo e2fsck -n /dev/vdb1
# For LVM, check all components
sudo pvs
sudo vgs
sudo lvsSuccessful Expansion Checklist
lsblk shows the partition using the full disk sizedf -h shows increased filesystem capacityTroubleshooting
growpart shows NOCHANGE
The partition is already using all available space, or the kernel hasn't detected the new size.
- Verify the resize was successful in the Cloud Control Panel
- Try rescanning the device:
echo 1 | sudo tee /sys/class/block/vdb/device/rescan - Check
lsblkshows the new disk size
resize2fs: Bad magic number
You're trying to resize a non-ext filesystem with resize2fs.
- Check filesystem type:
df -Th /mnt/storage - For XFS, use
xfs_growfs /mnt/storage
Device is busy
The device or partition is in use by another process.
- Check what's using the device:
sudo lsof +D /mnt/storage - For online resize of ext4/XFS, this is usually not a problem
- If issues persist, try stopping services using the mount
GPT backup header issue
GPT partition tables have a backup header at the end of the disk that needs updating.
# Fix GPT header
sudo sgdisk -e /dev/vdb
# Then run growpart again
sudo growpart /dev/vdb 1