VDI: How to increase initial capacity?

This is for discussing general topics about how to use VirtualBox.
Post Reply
AntiMatter
Volunteer
Posts: 176
Joined: 2. Nov 2008, 06:48
Primary OS: Ubuntu 12.04
VBox Version: PUEL
Guest OSses: All Windows (x32 & x64), Linux
Location: Canada

VDI: How to increase initial capacity?

Post by AntiMatter »

Hi,

I went through all the options of VBoxManage. I don't see any command to increase the capacity of the VDI. Here is what I would like to do. The VDI was created with an initial size of 10 GB, and the type is a dynamically growing disk. How to increase this capacity to 15 GB?

Of course, the guest OS won't adjust automatically to the bigger hard drive. At least I know how to handle this part, I will set the VM to boot on an Ubuntu Desktop ISO, start the LiveCD and use Gparted to resize the guest OS partition to the newer size. But for now the first step is to increase the initial capacity of the VDI, how to do that?

Thanks in advance for any help.
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: VDI: How to increase initial capacity?

Post by vbox4me2 »

You've been here a few months, 44 posts and still unable to use Google or read the stickies??? Even Terry is starting to have bad dreams about this question... :lol:
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Re: VDI: How to increase initial capacity?

Post by TerryE »

Can I adopt a different tack? Antimatter, having tracked your posts, I would classify you as an active and proficient VBox user who uses the forum for support but one has quite yet moved to the comfort zone of offering others the benefit of your knowledge. In some areas your expertise is now probably top rate, and yet you are not aware of this issue of how to resize VDIs, and my general advice that you should always allocate perhaps a 200% oversizing in your dynamic VDIs (leaving this space unallocated for partition growth).

Please don't take this as a personal criticism, but more one of a discussion of how we support users such as yourself: how we provide accessible information to enable competent users such as yourself to find out what you need without need to post Qs which have been answered many times before? I know we keep saying search before you post, but to be quite honest I sometimes look for an article where I know I've answered a Q on the same issue, but the fact is that unless you get the correct search phrase, they can sometimes be almost impossible to find.

I would value your thoughts on this. For example, I use php and I like the php documentation because as well as the formal documentation, each page has dozens of user posts giving examples (and the pitfalls) of using each function. Would a wiki copy of the documentation be useful where we could supplement the bare formal text with comments and caveats? Would you use it?
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
AntiMatter
Volunteer
Posts: 176
Joined: 2. Nov 2008, 06:48
Primary OS: Ubuntu 12.04
VBox Version: PUEL
Guest OSses: All Windows (x32 & x64), Linux
Location: Canada

Re: VDI: How to increase initial capacity?

Post by AntiMatter »

Hi Terry,

Thank you for your answers. I did read the section "How can I resize the partitions inside my VDI? " in the VDI FAQ. I didn't understand the answer as it describes the use of GParted on existing partitions. May be it works differently with a VirtualBox hard disk. But I think it should behave like a physical hard drive. Which means, if the HD capacity is 10 GB, Gparted will see only 10 GB. You can resize partitions, but the max total partition size is still 10 GB. What I wanted to do is to extend the max limit from 10 GB to 15GB before Gparted kicks in.

For example, here is the VMWare syntax to increase the capacity of the virtual hard drive to a new capacity (even if it is a boot drive):

Code: Select all

"C:\Program Files\VMware\VMware Server\vmware-vdiskmanager.exe" -x 15Gb "C:\Virtual Machines\myVM.vmdk"
I was expecting the same with VirtualBox (something I would imagine like VBoxManage extendhd ... or VBoxManage clonehd MyVM newcapacity=xxx). That was why I was reading all the options of VBoxManager but found no obvious answer. I've also found some hits by Google but most of the times the solution was to attach a 2nd virtual HD or recreating another VDI. This sounds overly complicated for a somewhat benign operation. Come on guys ... extending a VDI by recreating a new bigger one and restoring from the old one. Sorry for being picky but this is what people do with physical machines. The solution is not VM-friendly in my opinion. In the VM world, a virtual HD of 10 or 15 GB is still virtual, there should be a simple trick somewhere to avoid restoring the entire HD. So then I concluded that should be some syntax complication I am not aware of. Hoping this should be something quite common that someone could give me a quick hint. If someone was asking how to do such operation in VMWare, I would of course give the answer right away.

Thank you for valueing and somewhat overrating my level. I have probably past the novice level, I understand basic underlying concepts. But still have shortcoming in areas such as VDI or Snapshots as you could see recently. Too busy at the moment with a project. Will try to help later time. For now I am still stuck a lot with VMWare as it is the official VM tool used at work. Also I used to read the documentation, but sometimes it is tempting to ask a question in the forum.
TerryE wrote:I would value your thoughts on this. For example, I use php and I like the php documentation because as well as the formal documentation, each page has dozens of user posts giving examples (and the pitfalls) of using each function. Would a wiki copy of the documentation be useful where we could supplement the bare formal text with comments and caveats? Would you use it?
Is that a wiki looks like? http://www.php.net/manual/en/ ? if so then yes, I like this better than a PDF, mainly for fast search & better GUI and navigation. But if a PDF is well done (has index, Table of Content and the content is pertinent) then can use the PDF too. But i a doc is a single text file 1000+ pages, I will not use it.

Sorry for harassing you about this same question, call me stupid but I don't know yet the real answer. I am going to ask you the question differently, based on your VDI FAQ. My VDI has the initial capacity of 10 GB. Whether these 10 GB was a good idea or not, for the sake of education, let's assume that now it needs to be extended to 15 GB without major re-work. I boot the Live CD. Gparted sees 10 GB. How do you use Gparted so it can see 15 GB?
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: VDI: How to increase initial capacity?

Post by Sasquatch »

What I wanted to do is to extend the max limit from 10 GB to 15GB before Gparted kicks in.
That is described in his tutorial. You create a new VDI file of the desired size, add that to the VM like a normal physical hard drive, then you can clone the data from the first drive to the second.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Re: VDI: How to increase initial capacity?

Post by TerryE »

In the case of a dynamic VDI, the image file comprises 3 areas: a fixed 512 byte header, a mapping block and N x 1MByte pages. There is a 4byte entry in the mapping block for each 1Mbyte of the logical size (plus a filler to round its size to a 512 byte sector boundary), so this map is 40K long for a 10Gb VDI and 60K long for a 15Gb VDI -- so you can't do this in place as all 1Mbyte pages need to shift offset by 20Kb. As logical as it might seem, there isn't a newcapacity=xxx or equivalent option with clonehd. You just need to create a second VDI of the correct size, using the GUI disk manager or the VBoxManage createhd commmand then attached it to your VM, boot a GParted LiveCD and use Gparted in 2 disk mode to copy the partitions from old to new. By making your new VDI 40Gbyte long and only allocating 15Gb, this costs an extra 100Kb mapping overhead (which is tiny in comparison to the 15Gb), but this means that you can do future partition grows in-place.

In terms of the Wiki vs PDF, the current documentation has a limited intro to the syntax and purpose of VBoxManage createhd, say, but no further discussion of issues or use. If you pick a random PHP page, Function rtrim say, here we have 1 screen's worth which is the documentation developed by the PHP documentation team giving the formal definition, but then there is also 7 screens of user provided examples which are useful in really working out hoe to use it in practice. We just need some vehicle to make our knowledge a lot more accessible to VBox users.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
AntiMatter
Volunteer
Posts: 176
Joined: 2. Nov 2008, 06:48
Primary OS: Ubuntu 12.04
VBox Version: PUEL
Guest OSses: All Windows (x32 & x64), Linux
Location: Canada

Re: VDI: How to increase initial capacity?

Post by AntiMatter »

Hi Terry,

Thank you for your detailed answer. I now understand I should have had the answer if I spent enough time to absorb the technical details of your VDI FAQ. The real answer to my question is actually A VDI capacity is immutable. Once created, it cannot be extended to a greater capacity. The work around is to create a new VDI and use 3rd party disk cloning tool to replicate the content of the initial VDI. That was the kind of "simple" hint I was looking for. The tricks using 2 VDIs, cloning, Gparted, etc. are just details that are consequences of the simple fact that a VDI capacity is immutable. And may be that was the confusion in the wording of my question. I was looking for the cause (yes/no VDI can be extended), not the work around tricks.

It is a wonder that just adding 20K in the beginning of a VDI file requires that much gymnastic. VBoxManage can clone a hard drive, can convert VDI to VMDK (which actually is not working, even in 2.14). And yet it is not capable of shiting an VDI byte stream to insert a few K? Sound like I am going to submit a feature suggestion.
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

Re: VDI: How to increase initial capacity?

Post by TerryE »

How about
  • A VDI capacity is fixed. Once created, a VDI cannot be extended to a greater capacity. The work around is to create a new VDI and use 3rd party disk cloning tool to replicate the content of the initial VDI
Perhaps the adjective immutable will be lost on end-users, and for IT professionals immutable has a slightly different meaning. The irony is that this is exactly the same situation as physical disks: you can't grow their size, but you can swap one out for a larger disk having copied across the contents. Yes, the documentation could do with some some sensible discussion of these issues.

On all current file systems (Windows, Linux, etc.) adding 20K in the beginning of a VDI file does require that much gymnastic as all OSs treat a file as a byte (or sometimes record) stream. Ironically what it could easily do would be to relocate the first 1Mb page and use this as an overflow.

The one slight performance issue with having a dynamic disk with say 200% unallocated space is that the map vector is loaded into RAM, but them again what is the odd 100Kb these days? My iPod install takes up 10Mb of RAM (unless I kill the processes) even when I am not using it.

Having a size parameter on the clone would be a good idea. I will raise a ticket on this one.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
AntiMatter
Volunteer
Posts: 176
Joined: 2. Nov 2008, 06:48
Primary OS: Ubuntu 12.04
VBox Version: PUEL
Guest OSses: All Windows (x32 & x64), Linux
Location: Canada

Re: VDI: How to increase initial capacity?

Post by AntiMatter »

Oh of course, fixed is certainly better suited for the description. I was just influenced by the programmatic terminology. Thanks for taking care.
rperillac
Posts: 1
Joined: 20. Jun 2009, 03:33
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows XP

Re: VDI: How to increase initial capacity?

Post by rperillac »

I have found that is possible but little tricky. The easiest way is to use Norton Ghost (I used the one that comes in a CD called HIRENS version 9.8 ) and cloned the old virtual disk into a new hard disk defined with larger capacity (in my case was growing from 2 Gb to 30 Gb). Norton Ghost copies all the infomration and leaves the disk ready with the 28 Gb free and available. From the moral part, I think that can be used free tools but to use for a single time, I think is not a big deal
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VDI: How to increase initial capacity?

Post by mpack »

For the benefit of readers who came to this thread via Google/Bing or the "Quick Click FAQ, please note that while many of the above suggestions will still work, things have moved on since early 2009, and there are faster methods now available.

Today (v4.1.8 ), the official way to resize a VDI or VHD is to use "VBoxManage modifyhd <vdiname|vhdname|disk UUID> --resize sizeinMB", with the following caveats. See section 8.22 of the user manual for full details.
  1. This only increases the disk size. VBoxManage is ignorant of the data structures (a.k.a. "partitions") used by the guest OS to manage disk space, hence you need a separate tool fix those, called a partition manager. GParted is a good free one, Vista and later have DiskPart built in, though that does not always work on a live system drive. I prefer to use GParted even on Windows, mainly because I know it works. For unusual guests you may have to research how partition sizes are changed.
  2. You must not use this technique if you have used snapshots, because enlarging the supposedly frozen base VDI in a snapshot chain does... nothing good, and VBoxManage does not currently support enlarging a difference file. If you have used snapshots then your only options are to delete them first, or clone the VM (VBox 4.1.x or later), discarding the snapshots. Both options leave you with a stand alone VDI which can then be enlarged.
The "modifyhd --resize" command currently only works on dynamic VDI and dynamic VHD. For handling fixed size variants of these formats, or to handle other formats such as VMDK and HDD, see the CloneVDI tool below.

An unofficial way to resize a VDI is to use the third party CloneVDI tool. This tool is designed for Windows hosts, but is known to work well under Wine on Linux and Mac OS X hosts. CloneVDI is a cloning tool which has an option to resize the disk as it clones. As a cloning tool it doesn't matter if the source uses snapshots: you must however choose the latest snapshot as the source (don't make the mistake of cloning only the base VDI), the result will be a single VDI which is a merge of all the snapshot data. CloneVDI has a separate option to enlarge the partition at the same time it enlarges the disk, however this only currently works with FATx and NTFS partitions - other filesystems will require you to use GParted as before.
GTA_doum
Posts: 3
Joined: 2. Mar 2012, 07:48

Re: VDI: How to increase initial capacity?

Post by GTA_doum »

Hello,
I successfully increased the virtual drive size, and it shows in media manager ! But Windows XP continue to see it as a 10 Gigs instead of the now 20 Gigs size shown in media manager (I mean the drive size, not the partition size) !

What else is needed to make the Windows inside the VM see the new hard drive size ?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VDI: How to increase initial capacity?

Post by mpack »

Did you actually read the message directly above yours? I don't see how that could be, since the two possible answers to your question are both given (see caveats 1 and 2).
Post Reply