HowTo: Extend VMDK on VirtualBox
When I first started using Oracle VirtualBox,
I would mostly stick with the default
options when creating a virtual machine.
I soon realized,
that wouldn't work for RDBMS installations,
and although I would just add new virtual disk drives,
I started to have unused or 100% full disks on some VMs.
Rather than delete the VM,
I decided to learn how to extend the existing disks,
the steps are listed below:
I would mostly stick with the default
options when creating a virtual machine.
I soon realized,
that wouldn't work for RDBMS installations,
and although I would just add new virtual disk drives,
I started to have unused or 100% full disks on some VMs.
Rather than delete the VM,
I decided to learn how to extend the existing disks,
the steps are listed below:
Note: The Oracle Virtualbox Hypervisor is installed on a Windows OS
Open a command prompt:
Change directories to the VirtualBox Installation
cd C:\Program Files\oracle\VirtualBox
List the info on the disk you want to resize
VBoxManage showhdinfo
“C:\Users\panong\VirtualBox VMs\CENTOS-6.7\D0.vmdk”
Run the command to resize:
VBoxManage modifyhd “C:\Users\panong\VirtualBox VMs
\CENTOS-6.7\D0.vmdk” --resize 50000

If you receive the error below, then you will have to
create a new disk, clone the data on the existing disk
to the new disk and then delete the original disk:
create a new disk, clone the data on the existing disk
to the new disk and then delete the original disk:

Create a new VMDK “dynamic” disk
VBoxManage createhd –filename “C:\Users\panong\VirtualBox VMs
\CENTOS-6.7\D11.vmdk” --size 50000
Clone old disk to the newly created disk
VBoxManage clonehd
“C:\Users\panong\VirtualBox VMs\CENTOS-6.7\D0.vmdk”
--existing “C:\Users\panong\VirtualBox VMs\CENTOS-6.7\D11.vmdk”

Release the old disk
Go to Virtualbox Media Manager ---> Select
Click the "Release" option.
D0.vmdk
---> Click the "Release" option.
Note: DO NOT DELETE IT YET
Add the new disk to the Virtual Machine
Open the Machine folder and check the permission of
the created hard disk. If it doesn't have the
proper permission then it gives error while attaching
to the machine
the created hard disk. If it doesn't have the
proper permission then it gives error while attaching
to the machine
Open the Settings of the Virtual Machine ---->
Storage ---> Add Hardisk -----> Select the hard disk that
was just created.
Storage ---> Add Hardisk -----> Select the hard disk that
was just created.
Make sure to remove all disks, then add the new one first
to be /dev/sda.
to be /dev/sda.
You're not done yet! If you start the VM now,
the disk space will not be present since it has not yet been
presented and allocated to your Linux Server.
the disk space will not be present since it has not yet been
presented and allocated to your Linux Server.
To allocate the new disk, you will need to use
GParted - a GUI for editing disk partitions.
GParted - a GUI for editing disk partitions.
To download GParted,
go to http://gparted.sourceforge.net/livecd.php
to download the ISO file named GParted Live CD (
Be sure to get the current version based on the architecture
of your OS e.g. 32-bit vs 64-bit).
go to http://gparted.sourceforge.net/livecd.php
to download the ISO file named GParted Live CD (
Be sure to get the current version based on the architecture
of your OS e.g. 32-bit vs 64-bit).
Create a new virtual machine for the
GParted ISO on a Linux OS.
Select Do not add a Hard Drive and ignore the warning.
GParted ISO on a Linux OS.
Select Do not add a Hard Drive and ignore the warning.
Select the GParted VM, go to Settings ----->
Storage -----> Controller: IDE Controller ----->
Add a new CD/DVD.
Add the GParted ISO file as the first item under
Controller: IDE section and delete any additional
empty disk slots. Add the disk that you wish to
resize(
under the Controller: SATA Controller section -----> OK.
Storage -----> Controller: IDE Controller ----->
Add a new CD/DVD.
Add the GParted ISO file as the first item under
Controller: IDE section and delete any additional
empty disk slots. Add the disk that you wish to
resize(
C:\Users\panong\VirtualBox VMs\CENTOS-6.7\D11.vmdk
) under the Controller: SATA Controller section -----> OK.
Start the GParted VM ----> GParted Live.
Do not change any of the default settings.
Press the power button on the GParted VM to start it.
Do not change any of the default settings.
Press the power button on the GParted VM to start it.
Now, you should have made a backup of your vdi at this point.
If you haven’t go back and do that
– so many things can go wrong here and you are on your own!
If you haven’t go back and do that
– so many things can go wrong here and you are on your own!
If it is any partition other
than
you wish to resize and choose Resize/Move.
than
/dev/sda1
you can right-click the partition you wish to resize and choose Resize/Move.
IF YOU PREFER TO CREATE A NEW
PARTITION WITH THE ADDITIONAL
DISK SPACE YOU NEED TO CREATE A PARTITION:
Device —-> Create Partition Table
It should be back to main screen, click on
New —-> Add (it should have selected all the free space - 20000MiB) —-> Add
You should see it now listed as
not
New partition #1
not
unallocated
anymore.
Click on
then confirm again by clicking
You should now see the disk listed as
Apply
at the top of the GUI, then confirm again by clicking
Apply
. Click Close
. You should now see the disk listed as
/dev/sda#
with 20Gb.
Exit the GParted VM.
Log on to the VM for the disk you just resized and
everything should be functional and the
drive should show the new size of 50Gb.
everything should be functional and the
/dev/sda
drive should show the new size of 50Gb.
Delete the Original Disk Drive
Click the Remove option - this allows you to
keep the HDD without deleting it from the system if you choose.
keep the HDD without deleting it from the system if you choose.
*Cover Images from Oracle Corporation
-------------------------------------------------------------------
Credit :
https://www.patricia-anong.com/blog/2017/11/1/extend-vmdk-on-virtualbox
----------------------------------------------------------------------------------