1. Home
  2. Knowledge Base
  3. How to Expand a Volume on a Linux Virtual Machine

How to Expand a Volume on a Linux Virtual Machine

How to Expand a Volume on a Linux Virtual Machine?

Expanding a volume on a Linux VM involves several steps, including resizing partitions, adjusting logical volumes, and ensuring the filesystem utilizes the additional space. Follow these steps to perform the expansion successfully.

Prerequisites

  • Ensure the VM’s disk has been extended cloudPe dashboard.
  • Log in to the VM as a user with root privileges.
  • Install necessary tools like cloud-utils-growpart.

Steps to Expand the Volume

Step 1: Verify Current Disk Layout

Run the following command to check the existing disk and partition layout:

lsblk

Step 2: Install cloud-utils-growpart

This utility helps grow partitions:

yum install cloud-utils-growpart -y

Step 3: Extend the Partition

Extend the target partition using growpart:

growpart /dev/vdb 1

Example output:
[root@cloudpe ~]# growpart /dev/vdb 1
CHANGED: partition=1 start=2048 old: size=10483712 end=10485759 new: size=20969439 end=20971486

Here, /dev/vdb is the disk, and 1 refers to the partition number (vdd1).

Step 4: Resize the disk

resize2fs /dev/vdb1

Example output:
[root@cloudpe ~]# resize2fs /dev/vdb1 
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/vdb1 is mounted on /mnt/newdisk; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/vdb1 is now 2621179 (4k) blocks long.

Summary

In this guide, we expanded the disk, adjusted the partition, resized the physical volume, extended the logical volume, and resized the filesystem. These steps ensure that the additional disk space is fully utilized by the Linux VM.

Was this article helpful?