Resizing a VirtualBox Disk (VDI)

While installing some software on my virtual machine i ran out of disk space so i went out googling and found a nice tutorial. I don’t really like doing this, kind of pasting someone else’s article but, since i keep this blog mainly as a reference to myself and i believe i will most surely need it later, i’ll explain here step by step what i did to accomplish this task.

Basically at the time i tried to achieve this there weren’t any real options to actually grow/resize a virtual box disk image, so instead i had to create a new disk, copy my whole partition (i used GParted) from the full disk image to the new disk image.

Step 0 – Requirements

  1. Hard drive space, you’ll need to create a new disk so you need space for that
  2. GParted, either burned on a CD or an ISO file (grab GParted)
  3. Enough patience

Step 1 – Add a new disk

I won’t explain the options i use for creating a new disk since those are related to my own preferences and because i wanted to use the same settings that i have on the disk that’s full.

$ VBoxManage createhd --filename NewImage.vdi --variant Standard --type normal

This could also be achieve by going to ‘File’ menu, ‘Virtual Media Manager…’, clicking ‘New’ and setting the desired options.

Step 2 – Preparing the virtual machine

When using a physical GParted CD/DVD skip to number 4.

  1. Add a new CD/DVD resource from the GParted ISO on your system
  2. Add the newly created CD/DVD resource to the virtual machine that has the full disk
  3. Set the CD/DVD to mount at startup
  4. Set the boot order to boot from the CD/DVD
  5. Add the new disk image as a secondary disk on the virtual machine

Step 3 – Booting / Copy partition

Since we set the boot order, the system will now boot GParted (from the CD/DVD resource), on the GParted menu choose the default entry ‘GParted Live (Default settings)’, you’ll be prompted for the keymap and language you want to use, after answering these question and waiting a few moments you’ll be looking at the GParted window.

GParted will scan your virtual disk and you should now have 2 different disks, /dev/sda (original virtual disk) and /dev/sdb (your new bigger virtual disk).

  1. Right-click on your first disk (/dev/sda) and select ‘Copy’
  2. select your second disk (/dev/sdb) from the drop down, right-click and select paste
  3. On the pop-up drag the right edge (as not to leave any unallocated space)
  4. click on the ‘Paste’ button
  5. When the pop-up goes away click on the ‘Apply’ button
  6. A dialog will appear while your virtual disk is copied
  7. Do something productive while the process completes
  8. When the process is complete press ‘Close’
  9. Right-click on your second disk (/dev/sdb) and select ‘Manage flags’
  10. Set the ‘Boot’ flag
  11. Close the program
  12. Exit the live cd by clicking the ‘Exit’ icon

Step 4 – Booting you big disk virtual machine

  1. Open you virtual machine settings
  2. Detach your old virtual disk from this image
  3. Set the new virtual disk as primary master
  4. Either set the CD/DVD resource not to mount at startup or change boot order to boot from the disk
  5. Start your virtual machine
  6. If Windows asks to check the filesystem you should let it
  7. If everything boots up correctly you can now delete/backup the old VDI file

This wraps up the process i used here to gain some additinal space to install the software i needed. Hope this is helpfull to anyone else.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.