My Adventures in Coding

November 21, 2016

VirtualBox – Resize a CentOS Virtual Drive

Filed under: CentOS,Linux,VirtualBox — Brian @ 9:51 pm
Tags: , , , ,

Recently I created a CentOS VM using VirtualBox for some development work I was doing, but foolishly I set the virtual disk to the default size of 8 gigs, figuring it would be easy to resize it later.

Well, after piecing together bits of information from several places I was finally able to get my virtual disk resized as well as my CentOS partition that was on it. Here are the steps that worked for me!

Expand VirtualBox Drive

The first thing you need to do is expand your virtual drive which I did using the VBoxmanage command line tool provided by VirtualBox (reference).

Note: Ensure virtual box root folder is on your path (e.g., C:\Program Files\Oracle\VirtualBox).

Resize the partition with the command VBoxmanage to the desired size in megabytes (e.g., here I am resizing the drive to 20 gigs):

VBoxmanage modifyhd MyCentosDisk.vdi --resize 20000

Resize Partition with GParted

Download the gparted live cd.

Attach the gparted live cd as a drive to your virtual machine and make it the “Primary Master”.

Note: Ensure the checkbox “Live CD” is selected when you add the CD drive.

Now start your VM.

The gparted UI will load. Now resize the parition by expanding it to use the available free space on the virtual disk.

Shutdown your VM, remove the gparted live cd drive and set your virtual disk to once again be the “Primary Master” drive.

However, after you restart your VM you will notice that CentOS is still not aware of the additional space:

df -h

Expand CentOS Partition

Now you will need to expand your Linux partition to use the free space on the drive.

First check the sizes of the current partitions and get the name:

vgdisplay -v

On my system the name of the partition to expand was “/dev/centos/root”.

Extend the volume with the available free space:

lvextend -l +100%FREE /dev/centos/root

Now you are ready to perform the online resize:

xfs_growfs /dev/centos/root

NOTE: resize2fs works on other distributions of Linux but not on CentoOS, so you must use xfs_growfs (reference).

I hope that helps!



  1. Thanks Brian,

    You save my day ^^

    Comment by Nabil — May 11, 2017 @ 8:22 am | Reply

  2. I know this is an old post but you’ve saved me hours of frustration so thank you very much indeed!

    Comment by A Foster — September 20, 2017 @ 5:55 am | Reply

  3. Thanks for this article – easy to follow instructions and it works great. Awesome job!

    Comment by Boris — January 23, 2018 @ 6:53 am | Reply

  4. Thank for this Blog on CentOS expanding the disk.

    Comment by Mike Bradford — January 27, 2018 @ 9:03 am | Reply

  5. complete step provide! great! no error occur!

    Comment by Levis — March 15, 2018 @ 12:11 am | Reply

  6. Well Played kind sir…. -Austin

    Comment by John Myth — March 21, 2018 @ 9:52 am | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: