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?
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)
cp -a
should probably be used instead of dd
. 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 with cp
: user-permissions and following of symlinks.
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.
Aug 17, 2009 at 10:59
dd
command to make it take much less time (but still quite a long while). dd if=/dev/hda of=/dev/hdb bs=16M
Dec 5, 2012 at 14:48
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.
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.
This articles gives step-by-step instructions on how it can be done with screenshots. There is also another good article on how to do this here.
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