13
9
How can I resize my Virtual Machine, it is only 10GB and I need probably 50GB for this.
Is it easy to resize the image?
13
9
How can I resize my Virtual Machine, it is only 10GB and I need probably 50GB for this.
Is it easy to resize the image?
10
No easy way, I'm afraid. I had to do the same thing last week and this is the only help that I got to:
http://crookedspoke.wordpress.com/2008/03/15/resize-disk-image/
This is what you've got to do:
Type:
fdisk -l
Type:
dd if=/dev/hda of=/dev/hdb(this will probably take a long time)
6
You want (at least wanted year and a half ago) to resize virtual disk used by your virtual machine. You're using VirtualBox, so it's most likely a VDI file. VDI files can be fixed or dynamic. Fixed one has all blocks (units of data in VDI files, each one has 1MB by default) allocated from the beginning, so 10GB image's size is 10GB (a bit more actually, because you have some metadata, but it would be presumably even less than 50KB in your case). Dynamic file grows as you write to it, at the beginning having 0 preallocated blocks (VDI consists only of metadata).
I describe only expanding of the image. It's up to you what you'll do with a new space. Your partitions with file systems can be resized after expanding or you can create new partitions. It's a separate problem, but Tomas Sedovic pointed you to GParted Live CD, which can help you in performing such tasks. Personally I prefer Parted Magic, because it has other useful tools on ISO.
If you have fixed VDI, then you can use my little tool called vidma - Virtual Disks Manipulator. There is ready to use exe
file for Windows (2000 and above) users. For POSIX systems (like Linux) users there is a source code that you can simply compile using make
.
Vidma supports resizing in-place, i.e. it can resize your image without creating new file. In your case it would mean that you need only 40GB and a few MBs of free space to expand your image from 10GB to 50GB. It's very useful (and the main reason I wrote this tool), but if anything goes wrong (Murphy's laws are merciless) and you don't have copy of your image, then you have a real problem. That's why it's not recommended, especially for inexperienced users.
To continue you must have 50 GB and a few MBs of free space.
vidma image.vdi 51200 newimage.vdi
Before deleting old image, you should carefully check whether newimage.vdi works without problems. vidma
does not change UUID of the image, so you have to remove old one from VirtualBox Virtual Media Manager before you can add resized one. You can also change UUID of new image to avoid removing the old one.
VBoxManage internalcommands sethduuid newimage.vdi
Since VirtualBox 4 you can resize dynamic VDI using VBoxManage
:
VBoxManage modifyhd image.vdi --resize 51200
This command expand VDI file to 51200MB, i.e. 50GB. It will be done in-place and number of allocated blocks won't be increased, so you don't really need additional 40GB, but it's obviously required to be able to fully utilize resized image.
EDIT
vidma
since version 0.0.3 also supports resizing dynamic VDI files.
To get a better grasp of vidma
, beside checking linked before GitHub repository, you can go to thread at VB forum. Reading vidma(1) manual page is recommended.
just to point out, that VBoxManag is a program found in the virtual box installation. By default, you can find it at : C:\Program Files\Oracle\VirtualBox. – Black Horus – 2011-10-26T13:39:42.080
4
The first link is now borked... – Kevin Pullin – 2010-05-13T03:48:05.423
ok it worked, but for some reason if I remove the old hard disk, whenever I reboot and try and login the screen just goes all blue with the sound going off like I just logged in. If I re-add the old hard drive, it works (it is set to primary slave). very strange! – user3183 – 2009-08-16T22:24:02.887
You can access the link without images via the wayback machine.
– Jim McKeeth – 2011-04-27T22:36:00.5934
Consider the easiest thing to do: add another virtual hard drive. 10GB is sufficient for a "system" partition, even for Windows. Then you add a 50GB "d:" drive. In VirtualBox you just use the Virtual Media Manager, make the drive, and add it to your machine.
Advantage: you can revert it independently of the system partition. You can even wipe and reinstall the system partition and not have your "data" partition be affected. Another one is that you can use it in more than one virtual machine (not at once, I think), INCLUDING a Windows AND a Linux guest. Nice!
If Windows is your guest OS, 10GB is enough for Windows and any other "uncool" Windows programs (most) which install all kinds of stuff in the registry and in the Windows directories. Some stuff can be installed on the data partition, like graphics libraries for programs etc.
2
I don't believe it was available at the time the question was asked, but since VirtualBox 4.0 you can use vboxmanage modifyhd --resize command and then use GParted from a LiveCD to resize the operating system partition.
http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi
how will I boot from that iso image? – user3183 – 2009-08-16T21:04:13.517
I've added steps that explain that. If anything else is unclear, feel free to ask :-) – Tomas Sedovic – 2009-08-17T07:24:11.887
To copy the files over,
cp -a
should probably be used instead ofdd
.dd
copies the full filesystem, including the empty space, hence it takes a lot longer.cp -a
takes care of the two things that typically pose a problem withcp
: user-permissions and following of symlinks. – None – 2009-08-17T07:38:03.320nagul: wouldn't
cp -a
hurt all that boot sector info? I thought that cp is for files and directories copying.But in this case, a perfect clone of the hard disk is needed. I guess. – Tomas Sedovic – 2009-08-17T10:59:39.590
Specify the bock size to the
dd
command to make it take much less time (but still quite a long while).dd if=/dev/hda of=/dev/hdb bs=16M
– Chris Nava – 2012-12-05T14:48:30.620