Page 1 of 2

Change Size of Virtual Disk

Posted: 1. Dec 2010, 12:52
by tenkros
Is it possible to increase the size of the virtual disk ?

Re: Change Size of Virtual Disk

Posted: 1. Dec 2010, 13:27
by mpack
Is it possible you didn't search the forums before asking?

Re: Change Size of Virtual Disk

Posted: 2. Dec 2010, 09:30
by tenkros
Is it possible that you are more polite ?

Re: Change Size of Virtual Disk

Posted: 2. Dec 2010, 09:53
by FrodoHobbits
mpack is the author of the most excellent tool you are looking for.
The reply he came back with was the usual sort of reply you would expect :wink:
Search for CloneVDI or just look around and you will soon enough stumble upon it.

Re: Change Size of Virtual Disk

Posted: 2. Dec 2010, 11:52
by mpack
Also, please update your profile so we know which guest and host OS you are using, as that influences the choice of best answer.

Re: Change Size of Virtual Disk

Posted: 2. Dec 2010, 15:58
by tenkros
I am not used to get such kind of replies from companies who care for their customers.

Re: Change Size of Virtual Disk

Posted: 2. Dec 2010, 16:17
by mpack
tenkros wrote:I am not used to get such kind of replies from companies who care for their customers.
You haven't had a reply from the company at all, nor are you a customer unless you paid for your copy of VirtualBox.

This site is run by volunteers and yes, we resent the time we volunteer being hogged by people who are too lazy to read the manual and/or search the site before asking a FAQ.

Re: Change Size of Virtual Disk

Posted: 2. Dec 2010, 20:35
by shawnlau
What OS are you using for the host and what OS for the guest?

Re: Change Size of Virtual Disk

Posted: 3. Dec 2010, 02:48
by shawnlau
tenkros wrote:Is it possible to increase the size of the virtual disk ?
Yes. How you do it depends on the host OS and the guest OS. If the host OS is windows, you will probably use the GUI CloneVDI tool found here : http://forums.virtualbox.org/viewtopic.php?f=6&t=22422

If you are using linux as a host OS, you will probably just run Vboxmanage with the clonevdi argument. E.g., Vboxmanage clonevdi "mydrive.vdi" "copyofmydrive.vdi"

Now I'm still looking into it but I'm sure there are other arguments you can add in the command line to enlarge the virtual size of the drive. I've little doubt the clonevdi tool is just creating a command line from the options you check in the GUI.

While you can do the same thing in Windows using the command prompt (the dos window), the CloneVDI tool saves you from having to go to the dos prompt, and has editable boxes to change attributes you would have to enter at the command prompt, e.g., virtual size.

After you have cloned the disk to a new size, you then have to use a tool to make that (unallocated) space available to the VM. What tool you use to do that depends on the guest OS. If its Windows 7 you can easily claim the space with the disk management tool. You simply grow your drive by the amount of unallocated space. In linux, you'll probably load the gparted.iso into the virtual CD and boot up the VM. The gparted program has a graphic interface that allows you to stretch and delete different partitions. In my case, I simply deleted the extended and swap file partitions and stretched the remaining partition to the new length. I really doubt this is the right way, but nothing has exploded yet and my data remained uncorrupted. I don't see a swap file pr extended partition after rebooting, but I'm willing to bet there's a way to add these with gparted. But as I've said, the VM runs fne.

So yes you can enlarge the virtual disk, but how you do it will depend on the host OS and guest OS and how comfortable you are with running programs from the command line.

Re: Change Size of Virtual Disk

Posted: 3. Dec 2010, 02:56
by Perryg
Just a note. Gparted can assign a swap partition. When growing the primary partition stop short of the entire drive. Usually a few GB are all you need but if you want things like hibernate and ample disk space to swap you need to actually make it 1 1/2 times the size of RAM to 2 times the size of RAM. Be sure to mark it as swap.

Re: Change Size of Virtual Disk

Posted: 3. Dec 2010, 03:27
by shawnlau
Perryg wrote:Just a note. Gparted can assign a swap partition. When growing the primary partition stop short of the entire drive. Usually a few GB are all you need but if you want things like hibernate and ample disk space to swap you need to actually make it 1 1/2 times the size of RAM to 2 times the size of RAM. Be sure to mark it as swap.

Thanks for that. I was confident it was wrong, and if I'm sure after time the side effects of no swap file would become apparent :) I wasn't so sure about the extended partition. I do remember from early windows days ( when it was still possible to set the size of your swap file) about the swap file being set to a percentage of ram. I of course have the source vdi and will try cloning it again, stretching the extended partition, moving the swap file to the end, and then stretching the primary partition.

If I get what is right, I'll post the exact steps. Thanks for the help.

Re: Change Size of Virtual Disk

Posted: 3. Dec 2010, 09:16
by tenkros
Many thanks to shawnlau and Perryg for their exhaustive, very clear and helpfull assistance.

Re: Change Size of Virtual Disk

Posted: 3. Dec 2010, 10:45
by mpack
A couple of minor corrections :-
shawnlau wrote:If you are using linux as a host OS, you will probably just run Vboxmanage with the clonevdi argument. E.g., Vboxmanage clonevdi "mydrive.vdi" "copyofmydrive.vdi"
In fact the "clonevdi" argument for VBoxManage has been obsolete for quite some time. It is kept for backwards compatibility reasons, but new users should be encouraged to use the correct syntax: "VBoxManage clonehd", which is also how the command description can be found in the user manual.
shawnlau wrote:I've little doubt the clonevdi tool is just creating a command line from the options you check in the GUI.
In fact it isn't. As it says in the link which you posted, the CloneVDI tool is "not just a front end for VBoxManage". It is entirely stand alone and does not require any part of VirtualBox to be present in order to work. Indeed, that's why it can do things which VBoxManage can't, such as enlarge a drive, or compact a filesystem that hasn't had sdelete / zerofree run on it first, etc.

Re: Change Size of Virtual Disk

Posted: 4. Dec 2010, 00:00
by shawnlau
mpack wrote: In fact it isn't. As it says in the link which you posted, the CloneVDI tool is "not just a front end for VBoxManage". It is entirely stand alone and does not require any part of VirtualBox to be present in order to work. Indeed, that's why it can do things which VBoxManage can't, such as enlarge a drive, or compact a filesystem that hasn't had sdelete / zerofree run on it first, etc.
That good to know. I had no idea Vboxmanage couldn't change the size of a virtual drive. I was assuming the size was kept somewhere in the header and it was a simple matter of editing that object member. I guess the VDI file structure is listed somewhere on this site?

Re: Change Size of Virtual Disk

Posted: 4. Dec 2010, 12:29
by mpack
shawnlau wrote:I guess the VDI file structure is listed somewhere on this site?
There's a tutorial called "All About AVIs" (see the "Howtos and Tutorials" forum) which gives a good description of the technical aspects. Of course the definitive source of structure information is the VirtualBox source code.

Changing a VDIs size isn't hard, but it's more than just changing a value in a header field. Eg. the block table needs to change to suit the new image size.