How to resize a VirtualBox disk partition

@ http://www.my-guides.net

virtualbox.jpg

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 because your virtual disk is full So, in this tutorial I will explain how to enlarge an existing virtual disk or in other words how to resize your virtualbox vdi. I have a Windows XP installation running on Linux and specifically Archlinux and I am going to create a larger disk for Windows XP…

http://www.my-guides.net/en/content/view/122/26/

**Note: The same procedure works for Windows Vista also. The only difference is that you have to use your original Vista installation CD for Bootmgr repair the first time the system is started after the GPARTED steps have been followed. (Thanks to Andrew)

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.

3.jpg

Select Dynamically expanding image as Image type and click next.

4.jpg

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.

5.jpg

Press Finish to end the wizard.

6.jpg

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 resized virtualbox disk without having lost any of your data. You can now just delete the old .vdi. Enjoy!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s