Expand Disk After Upgrade
After expanding the VPS disk from the panel, extend the partition and filesystem without losing data.
After upgrading your plan from VirtFusion, the additional space is allocated to the virtual disk but is not yet usable until you extend the partition and filesystem.
First of all
Take a snapshot from the VirtFusion panel before proceeding. Operations on partitions and filesystems, if interrupted, can make the system unbootable.
Check available space
# Total physical disk space
fdisk -l /dev/vda | head -5
# Space used per partition
df -h
# Current partitions
lsblkTypical output:
vda 252G # total disk (new)
└─vda1 100G # current partition (old size)Identify the disk and partition
lsblk -fNAME FSTYPE SIZE MOUNTPOINT
vda 252G
└─vda1 ext4 100G /Disk: /dev/vda, Partition: /dev/vda1, Filesystem: ext4
Extension with growpart + resize2fs
Install growpart
apt install cloud-guest-utils -y # Debian/Ubuntu
dnf install cloud-utils-growpart -y # AlmaLinux/CentOSExtend the partition
# Extend vda1 to maximum available space
growpart /dev/vda 1Expected output:
CHANGED: partition=1 start=2048 old: size=209715167 end=209717215 new: size=528480223 end=528482271Extend the ext4 filesystem
resize2fs /dev/vda1Output:
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 32
The filesystem on /dev/vda1 is now 66060027 (4k) blocks long.Verify
df -h /Now shows the updated size.
XFS Filesystem (AlmaLinux/CentOS)
For XFS filesystems, use xfs_growfs instead of resize2fs:
# Extend the partition
growpart /dev/vda 1
# Extend the XFS filesystem (can be done while mounted)
xfs_growfs /LVM (Logical Volume Manager)
If your VPS uses LVM (visible as dm-0 or vg0-lv0 in lsblk):
# Check LVM layout
pvdisplay
vgdisplay
lvdisplay
# Extend the physical volume
pvresize /dev/vda2
# Extend the logical volume to 100% of free space
lvextend -l +100%FREE /dev/vg0/lv0
# Extend the filesystem
resize2fs /dev/vg0/lv0 # ext4
# or
xfs_growfs / # xfsAdd a secondary disk
If you added a second disk from the panel (e.g. /dev/vdb):
# Verify the disk is detected
lsblk | grep vdb
# Create filesystem
mkfs.ext4 /dev/vdb
# Create mount point
mkdir /mnt/data
# Manual mount
mount /dev/vdb /mnt/data
# Permanent mount (survives reboot)
echo '/dev/vdb /mnt/data ext4 defaults 0 2' >> /etc/fstabVerify fstab:
mount -a # mount everything from fstab without rebooting
df -h /mnt/dataTroubleshooting
growpart: "NOCHANGE: partition 1 is size..."
The physical disk has not been expanded yet. Verify in the VirtFusion panel that the resize is complete before proceeding. Sometimes a VPS reboot is required.
resize2fs: "Bad magic number in super-block"
The disk is not ext4. Use lsblk -f to verify the type and use the correct tool (xfs_growfs for XFS, btrfs filesystem resize for Btrfs).
Partition cannot be expanded
If the partition is not the last on the disk, growpart cannot expand it. In this case you need to act from rescue mode with gparted.