8

How to extend Vdi and VMDK Hard disks on VirtualBox

 2 years ago
source link: https://computingforgeeks.com/how-to-extend-vdi-and-vmdk-hard-disks-on-virtualbox/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
How to extend Vdi and VMDK Hard disks on VirtualBox

This will show you how to extend Any operating system’s Virtual Hard Disk running on VirtualBox ; both vdi and VMDK virtual hard drive formats. When i was working on a vagrant box i downloaded from the internet, it had only 10GB allocated. After filling up the space, i had to extend it so that i could install more packages.

Below are steps that I followed to accomplish the task. This guide assumes you’re using Linux Guest OS, but i will let you know how to go about it on Windows Guest and Windows Host. My host operating system is Fedora.

If you’re new to Vagrant and want to add a new box from your existing Virtualbox environment, then look at Step by step guide on using existing virtual machines with Vagrant. So let’s get started. Follow steps below.

This will show you how to extend Any operating system’s Virtual Hard Disk running on VirtualBox ; both vdi and VMDK virtual hard drive formats. When i was working on a vagrant box i downloaded from the internet, it had only 10GB allocated. After filling up the space, i had to extend it so that i could install more packages.

Below are steps I followed to extend VDI and VMDK Hard disks on VirtualBox VM. This guide assumes you’re using Linux Guest OS, but i will let you know how to go about it on Windows Guest and Windows Host. My host operating system is Fedora Linux.

Step 1: Setup pre-requisites

  • Installed Guest operating system on Virtualbox that you want to extend its hard disk
  • VirtualBox installed
  • Virtual Machine to be modified must be powered off
  • Gparted live bootable ISO

Step 2: DownloadGparted live iso

Download Gparted live iso image

# 64-bit
wget https://sourceforge.net/projects/gparted/files/gparted-live-stable/1.3.1-1/gparted-live-1.3.1-1-amd64.iso

# 32-bit
wget https://sourceforge.net/projects/gparted/files/gparted-live-stable/1.3.1-1/gparted-live-1.3.1-1-i686.iso

Step 3: Expand VDI disk

Change to directory containing Virtual Machine to modify. If you’re using vagrant first run

vagrant halt

Then change to VirtualBox VMs folder. For my case it’s /home/josepy/ VirtualBox VMs/, cd to Virtual machine’s directory

cd /home/$USER/VirtualBox VMs/
cd  vm-name/

If using VMDK, you’ll have to clone it first to vdi. If your virtual hard disk is in vdi format, you can directly resize it. The name of my vmdk file was box-disk1.vmdk

VBoxManage clonehd box-disk1.vmdk box-disk1-clone.vdi --format vdi
VBoxManage modifyhd box-disk1-clone.vdi --resize 50000

The commands above cloned box-disk1.vmdk tobox-disk1-clone.vdi so that we can resize it. VirtualBox doesn’t support resizing of .vmdk disk type.

In case you would like to convert new resized vdi to vmdk, you’ll have to clone it again, e.g.

VBoxManage clonehd box-disk1-clone.vdi box-new-disk1.vmdk --format vmdk

Step 4: Modify Disks on VirtualBox

Open VirtualBox GUI and click on your VM.Then Settings > Storage >IDE Controller > Add optical drive ( round like icon on the right) > Point to Gparted iso you downloaded and add it.

Again click on IDE Controller > Adds hard disk and point to your newly resized vdi or vmdk. Mine is centos-asterisk.vdi. See below screenshots for clarification.

After that, on same Virtual Machine GUI, go to settings > System > Motherboard > Boot order. Then, uncheck Hard disk, and select Optical and click on OK button at the bottom to save changes.

Step 5: Boot VM and use Gparted

Boot the VM by clicking on start button, and select Gparted Live on gparted boot menu that will appear. Use default settings by hitting Enter key until you reach the gparted partion Menu.

Step 6: Resize disk

This is the point we’re doing partioning to make extended drive functional.

Click on Already partitioned drive > ( Resize/Move). Now press and hold CTRL key and drag the dark arrow to the end. Or add Free space following + New size and put the sum on New Size area.Click on resize the apply changes, then exit.

After shutting down the Virtual Machine.Go back to settings and untick on Optical under boot order and select hard disk. Also remove the iso you added under IDE Controller menu option.

FOR WINDOWS GUEST OPERATING SYSTEM

If you resized Hard disk for Windows Guest Operating system, open DISK PARTITION MANAGER and extend your Windows partition.

That’s all. Your hard disk should be extended by now. To check run lsblk command on your Linux Guest OS.

lsblk

We hope this guide was of great help to you.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK