How to resize a VirtualBox disk partition |
|
|
| Written by axel | |||||||||||||||||||||||||
VirtualBox is a cross platform full virtualizer for x86 hardware. It runs on Windows, Linux, Macintosh and OpenSolaris hosts and supports a large number of guest operating systems such as Windows, Linux and OpenBSD. In a previous guide I have shown you How to install Ubuntu Linux on Windows using VirtualBox . The procedure is the same if you want to install Windows on Linux. The guest operating system is installed on a virtual disk created by VirtualBox which is nothing more than a single .vdi file. When you first create the virtual machine you must set a certain size for this disk. However after playing with VirtualBox you might realize you need more space. So, in this tutorial I will explain how to enlarge an existing virtual disk. I have a Windows XP installation running on Linux and specifically Archlinux and I am going to create a larger disk for Windows XP.
Run VirtualBox and go to File -> Disk Manager. ![]() Here as you can see I have a .vdi disk with a size of 10GB (1) which is almost full. So press the New button (2) to create a new virtual disk. ![]() Click next to go to the next page of the New Virtual Disk Wizard. ![]() Select Dynamically expanding image as Image type and click next. ![]() Select a name for the new image (1), this should be different than the existing one, and also set the size of the new disk (2). Here I've set it to 20GB. ![]() Press Finish to end the wizard. ![]() Now you should have 2 .vdi images in the Virtual Disk Manager. Click Ok to close the wizard.
Here we are gonna need GParted to copy the data of our old disk to the new one. GParted is the Gnome Partition Editor application for creating, destroying, resizing, moving, checking and copying partitions, and the file systems on them. It has a LiveCD which you must download from here . You don't have to burn it on a cd, just store the .iso somewhere in you hard disk.
Now select the existin Windows XP installation (1) and click on the Settings button (2). ![]() In the General -> Advanced tab set CD/DVD Rom as the first boot device. ![]() In the Hard Disks settings double click below your IDE Primary Master and set IDE Primary Slave and the new Virtual Hard Disk image. ![]() In the CD/DVD-ROM settings click on Mount CD/DVD Drive (1), choose ISO Image File (2) and use the folder button to browse to the location you have saved the gparted live cd (3). ![]() Now click the Ok button and start the Windows XP Virtual Machine. Press Enter to boot GParted Live with Default Settings. ![]() Don't touch keymap should be fine. Again press Enter. ![]() Select the Language you prefer. Press Enter for English. And again press Enter for the default video card settings. ![]() GParted will automatically scan your virtual disks. /dev/hda should be the old one and /dev/hdb the new one. Right click on your first disk and select Copy. ![]() Next select /dev/hdb from the drop down menu (1), right click on the unallocated space and select Paste (2). ![]() Drag the right edge (1) like you see in the screenshot so as not to leave any unallocated space in the new disk. Next click the Paste button. ![]() Now press Apply to apply the changes. ![]() When all listed operations are applied click the Close button. Again right click on the new partition /dev/hdb and click Manage flags. Here you should tick the boot flag. ![]()
Gparted will scan all devices once more. When it's done close the program and shutdown the live cd from the exit button. It will prompt you to press Enter. Now return to the VirtualBox application, select the Windows XP virtual machine and click the settings button. In the General -> Advanced tab select Hard Disk as the first boot device.
![]() In the Hard Disk settings use the delete button (1) to remove the IDE Primary Slave, leave just IDE Primary Master (2), and select the new .vdi (3). ![]() In the CD/DVD-ROM settings tick the Host CD/DVD Drive. ![]() Press the Ok button and start your Windows XP virtual machine. Windows might ask to check their filesystem. Just let them do it. ![]() After they automatically reboot you will log into your new enlarged disk installation without having lost any of your data. You can now just delete the old .vdi. Enjoy! ![]()
Please do not use the comment function to ask for help! If you need help, please use our forum instead.
Did you enjoy this article? Please share it!
Set as favorite
Bookmark
Email This
Hits: 3480 Comments (7)
![]()
Nassim Bennouna
said:
|
|||||||||||||||||||||||||
|
Thanks ! Everything is fully detailled. No place for any error. |
|
|
report abuse
vote down
vote up
|
Joseph
said:
| Thank you for the time and effort you put into this - surely saved me hours of trouble... | |
|
report abuse
vote down
vote up
|
Jin
said:
|
I fell in 2 problems: 1. BSOD: due to improper IDE Controller Type ( in Advanced Setup). I don´t know why it changed. 2. not correct NTFS Journal in source system disk. I recommend to use ntfsfix /dev/sdxx as the first step in the procedure. Hope it helps |
|
|
report abuse
vote down
vote up
|
JRP
said:
Thank you, thank you and thank you! I started to use virtualbox last week and as everything was finally working, I got a nice message as I was running out of space . I was looking for an answer. Not only you gave the answer I was looking for, but it was so clear and well explained that I could not go wrong. Thank's again for your wisdom. You are a genius. Have a great day! I don't have a place to rate my vote, but you got 11 out of 10! |
|
|
report abuse
vote down
vote up
|
Enzo
said:
|
I'm using VirtualBox on Windows with Fedora 10 as the guest OS. I have a .vdi file for my virtual machine that is 8gb in size and I want to make it 40gb so I create another vdi file and attach it. I then boot up in gparted live cd and I can see both hda and hdb. In the Fedora guest OS, if I do fdisk -l /dev/hda I see that I have /dev/hda1 LINUX and /dev/hda2 LINUX LVM partitions. I didn't specifically create it this way, this is the way it came out from the standard Fedora 10 install. After I copy hda to hdab I end up with /dev/hdb1 and /dev/hdb2. hdb1 is ext3 format boot partition and hdb2 is unknown to gparted. The resize button is greyed out for hdb2 so you cannot resize it no matter what you do. I can resize the /dev/hdb1 partition if I want, but that is the boot partition and I need to resize /dev/hdb2 and it will not. Is this because it is a linux lvm? Any ideas? |
|
|
report abuse
vote down
vote up
|
kieran.tv
said:
| Just used the above procedure to resize a win 2003 server machine. Your solution worked ok for me, however i did have to use the ntfsfix to get it to grow the disk (resize) correctly. | |
|
report abuse
vote down
vote up
|
Write comment
| Next > |
|---|






VirtualBox is a cross platform full virtualizer for x86 hardware. It runs on Windows, Linux, Macintosh and OpenSolaris hosts and supports a large number of guest operating systems such as Windows, Linux and OpenBSD. In a previous guide I have shown you 
























as I was running out of space
. I was looking for an answer. Not only you gave the answer I was looking for, but it was so clear and well explained that I could not go wrong. Thank's again for your wisdom. You are a genius.