How to re-size a VirtualBox Virtual machine

How to re-size a VirtualBox Virtual machine I have recently had to re-size my Ubuntu development VM twice as I keep adding Drupal sites and their files to my local dev environment. 

watch It is basically pretty simple but can be quite time consuming, I am writing this as I wait for one of the steps to complete myself! I have just installed a new hard drive for the new VM so I am moving the location of the "Default Machine Folder" as will from the VirtualBox GUI, doing this before making the initial clone is the easiest way to do so. I am planning on using as much of the newly mounted drive as possible so I don't have to do this for a very long time. 

go Step 1 (Optional)
Clone your existing VM so you can always go back to the original if something goes wrong. If you want to change the default location of your VMs beforehand to a new hard drive for example this is the right time to do so, just go to " File > Preferences" and enter the new location before starting the clone operation.

here بيع أسهم الحمادي Step 2 (Optional)
Start up your cloned VM just to make sure everything is happy and you won't waste any time resizing a broken VM. If you did change the location of the VirtualBox default machine folder your new VMDK files will be in the new location. source link Step 3 
So now we need to clone the VMDK file to a VDI file using VBoxManage on the command line. Open a command prompt, CD to your new default machine folder and type the following: "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd "oldname.vmdk" "newname.vdi" --format vdi 

The reason we have to do this is that the VBoxManage application can not re-size a VMDK disk image.

لمسة واحدة الخيارات الثنائية تجريبي Step 4 
The next step is to re-size the disk with the modifyhd application, the numeric parameter in the example below is the number or MB to re-size it to so if you need 450GB the number you need is the result of (450*1024). 

 follow site "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd "newname.vdi" --resize 460800 

For more information about this part of the procedure have a look here or just search Google for "Expand a vmdk file". 

كم عدد الاسهم التي ستخصص لكل مكتتب في البنك الاهلي Step 5 
Now you should have a VMDK and a VDI image of exactly the same VM. Now just configure your VM to use the VDI instead of the VMDK using the VirtualBox GUI. Go to " Settings > Storage" and remove the VMDK and add the existing VDI. 

You can delete the VMDK file once you have done this if you are planning on using as much of the available space as possible it is probably a good idea!

استراتيجية مضاعفة خيار ثنائي Step 6 
Now attach a GParted ISO to the IDE controller of your VM in the GUI and boot in to GParted to assign all that unallocated space to your VM's hard disk. Step 7 
Now boot the VM to the main OS and if you are using Ubuntu you will have to re-size the LVM and file system. Find out the name using "fdisk -l" and "vgdisplay" commands.

Having determined the available free space you have to add to your system do the following:

lvextend -l +9999 /dev/sda2/your-lv-name
resize2fs -p /dev/sda2/your-lv-name

You should now be able to see the extra space available in your file system with "df -h"


Useful Links



I have been trying to get that right for ages, this really helped!


Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.