
Running Out of Space? A Step-by-Step Guide to Resizing Your OpenStack Linux Disk
It’s a dreaded notification that every system administrator wants to avoid: “disk space is critically low.” When your root partition on a Linux instance in OpenStack is nearing capacity, performance can suffer, applications can fail, and essential services might stop running. Fortunately, extending the root partition is a straightforward process that can be done without downtime.
This guide provides a clear, step-by-step method to increase the size of your root volume, ensuring your instance has the space it needs to operate smoothly. The process involves two main phases: first, increasing the volume’s size in the OpenStack dashboard, and second, instructing the Linux operating system to recognize and use that new space.
Before You Begin: A Crucial Precaution
Modifying disk partitions is a sensitive operation. While the process outlined here is generally safe, there is always a small risk of data loss if something goes wrong.
Before proceeding, it is highly recommended that you create a snapshot or backup of your volume. This provides a safe recovery point in the unlikely event of an issue.
Step 1: Extend the Volume in OpenStack
The first step is to allocate more space to the virtual disk at the infrastructure level. This is done through your OpenStack cloud dashboard (Horizon).
- Navigate to the Project -> Volumes -> Volumes section in your OpenStack dashboard.
- Locate the volume attached to your Linux instance that you wish to extend.
- From the “Actions” dropdown menu next to the volume, select Extend Volume.
- Enter the new, larger size for the volume in GiB. Remember, you can only increase the size, not decrease it.
- Click Extend Volume to confirm.
OpenStack will now resize the block device. This change is often immediate, but the operating system inside your instance is not yet aware of the new space.
Step 2: Identify the Target Disk and Partition in Linux
Next, you’ll need to log into your instance to tell the operating system about the change. Connect to your instance using SSH.
First, let’s inspect the current disk layout. The lsblk command provides a clean overview of your block devices.
lsblk
You will see output similar to this, where vda is the disk and vda1 is the root partition on that disk.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 254:0 0 50G 0 disk
└─vda1 254:1 0 20G 0 part /
Notice that the disk vda shows the new total size (e.g., 50G), but the partition vda1 still shows the old size (20G). Our goal is to make the partition expand to fill the entire disk.
You can also use df -h to confirm the filesystem’s current size from the OS perspective.
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 19G 500M 98% /
Step 3: Extend the Linux Partition
To extend the partition to fill the newly available space on the disk, we will use the growpart utility. This is a safe and simple tool designed specifically for this task, avoiding the complexities of manual partitioning with fdisk or parted.
The growpart command requires the device name and the partition number. Based on our lsblk output, the device is /dev/vda and the partition number is 1.
Execute the following command to extend the partition:
sudo growpart /dev/vda 1
If successful, the command will output a message indicating that the partition was resized.
Note: If growpart is not found, you may need to install it. On Debian/Ubuntu, it is part of the cloud-guest-utils package (sudo apt install cloud-guest-utils). On CentOS/RHEL, it is in the cloud-utils-growpart package (sudo yum install cloud-utils-growpart).
Step 4: Resize the Filesystem
You have successfully extended the partition, but one final step remains. You must resize the filesystem that lives on the partition to make the new space usable. The command to do this depends on the type of filesystem you are using.
First, identify your filesystem type using lsblk -f.
lsblk -f
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
vda
└─vda1 ext4 root 1234abcd-5678-90ef-ghij-klmnopqrstuv 500M 98% /
For ext2, ext3, or ext4 filesystems:
Use the resize2fs command. Provide the path to your partition.
sudo resize2fs /dev/vda1
For XFS filesystems:
Use the xfs_growfs command. For the root filesystem, you can simply provide the mount point (/).
sudo xfs_growfs /
This command tells the filesystem to expand and occupy all the space now available in its underlying partition.
Step 5: Verify the Results
The process is complete. To confirm that your root partition has been successfully extended, run the df -h command again.
df -h
The output should now reflect the new, larger size of your root filesystem, and the usage percentage should be significantly lower.
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 50G 19G 29G 40% /
You have now successfully extended your Linux root partition on an OpenStack instance, giving your applications and services the breathing room they need. This simple, live-resizing process is a powerful tool for managing your cloud infrastructure effectively.
Source: https://kifarunix.com/easily-extend-linux-root-partition-on-openstack-instance/


