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
- Hard drive space, you’ll need to create a new disk so you need space for that
- GParted, either burned on a CD or an ISO file (grab GParted)
- 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.
- Add a new CD/DVD resource from the GParted ISO on your system
- Add the newly created CD/DVD resource to the virtual machine that has the full disk
- Set the CD/DVD to mount at startup
- Set the boot order to boot from the CD/DVD
- 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).
- Right-click on your first disk (/dev/sda) and select ‘Copy’
- select your second disk (/dev/sdb) from the drop down, right-click and select paste
- On the pop-up drag the right edge (as not to leave any unallocated space)
- click on the ‘Paste’ button
- When the pop-up goes away click on the ‘Apply’ button
- A dialog will appear while your virtual disk is copied
- Do something productive while the process completes
- When the process is complete press ‘Close’
- Right-click on your second disk (/dev/sdb) and select ‘Manage flags’
- Set the ‘Boot’ flag
- Close the program
- Exit the live cd by clicking the ‘Exit’ icon
Step 4 – Booting you big disk virtual machine
- Open you virtual machine settings
- Detach your old virtual disk from this image
- Set the new virtual disk as primary master
- Either set the CD/DVD resource not to mount at startup or change boot order to boot from the disk
- Start your virtual machine
- If Windows asks to check the filesystem you should let it
- 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.