Virtualbox Increase Disk Size Vmdk

Posted on
  1. Hard Disk Size

Is there an easy way to increase virtual hard disk space on VirtualBox?

Casebash

In all cases, confirm these before increasing the size of the virtual disk: All snapshots have. Type vmware-vdiskmanager -x 100Gb vm.vmdk and press Enter. Increase VirtualBox Disk Size 11 August 2012. I've recently had the need to increase my VirtualBox Disk size, and I thought it would be useful for others to share my experience and provide a tutorial of how to increase your VirtualBox Hard Drive size; this way you spend less time searching around. Is there an easy way to increase virtual hard disk space on VirtualBox? I have.vmdk files – chobo2 Aug 2 '12 at 21:45. @fikovnik I managed to modifyhd to a larger number and I can clearly see it in the virtualbox manager the disk size has increased, however, i cannot see the extra space disk after i booted into gparted, weird.

CasebashCasebash
2,86716 gold badges53 silver badges83 bronze badges

7 Answers

There is not an easy way to do this.

There is a complicated one, though:

Has a good screenshot-by-screenshot guide. Essentially you're copying your install onto a new virtual-disk file.

Update: As of VirtualBox 4 they added support for expansion.

That will resize a virtual disk image to 45GB.

SysAdmin1138SysAdmin1138

The Trivial Proof blog has a nice tutorial of the process for VirtualBox versions before and after 4.0. It includes the steps for adjusting the partition on the expanded disk.

Don KirkbyDon Kirkby

If you are running Windows Server 2012 and VirtualBox version 4 and above, there are only 4 steps:

  1. run the 'C:Program FilesOracleVirtualBoxVBoxManage.exe' clonehd .vdi --resize
  2. Boot Up Virtual Box
  3. In server managaer -->File And Storage Services --> Volumes --> Disks --> Tasks --> Rescan Storage
  4. Go to server manager -->File And Storage Services --> Volumes --> Right click on volume --> choose expand volume.

Go to file explorer and right click on the drive. You will seethat the volume has increased in size!!

user230405user230405

This worked perfectly (from Windows 7 and using VirtualBox 4.x).

Do the following:

  1. Open cmd as administrator.
  2. Go to the folder where the VirtualBox is installed so you can use the VBoxManage program.
  3. From there, run the following command:

    e.g.:VBoxManage modifyhd C:V-MACHINESSERVER2008WIN-2008.VDI --resize 26000

  4. You will see a message from 0 to 100% and done.
  5. Start your machine and go to 'Computer' (or 'My Computer', if applicable), right click and select 'Manage', go to 'Storage' → 'Disk Management', right click on the disk you want to expand, click on 'Extend Volume' and resize the disk as you wish.
  6. If necessary restart the VM.
Scott
17k11 gold badges44 silver badges91 bronze badges
Mauricio LucaMauricio Luca

Had to search a bit on how to run this command.

Navigate to folder having your-filename.vdi e.g:(cd /Users/binoy/VirtualBox VMs/)

Hard Disk Size

Then run the command to increase the space to 25 gb.

VBoxManage modifyhd filename.vdi --resize 25000

You would now have to attach the additional space using resize2fs or Gparted.

binoybinoy

There's also now a simple GUI too called Clone VDI for Windows users that @Eric Kigathi mentioned here: https://stackoverflow.com/a/5987875/1024735

Community
kevinmickekevinmicke
5853 gold badges8 silver badges20 bronze badges

Lets see the currently existing virtual hard drives of your virtual box(es)using the vboxmanage command

$ vboxmanage list hdds

In my case it lists only this one

Keep the location of the VDI file you want to resize /home/anonyn/WIN81_64BITS.vdi

Lets determine how much physical space is left on your real machine (Linux)

$ df -h

Since in my case I have 76GB free on /dev/sda2I can increase that WIN81_64BITS.vdi it by 36GB without any issues

Some simple math will allow you to get the desired new size

Now you are ready to build the command that will help you solve the problem

VBoxManage modifyhd [path/To/File.vdi] --resize [NewSizeInMB]

$ VBoxManage modifyhd /home/anonyn/WIN81_64BITS.vdi --resize 76755

$ VBoxManage modifyhd /home/anonyn/WIN81_64BITS.vdi --resize 76755 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Now boot that virtual machine and extend the desired partition following this steps

Mauricio Gracia GutierrezMauricio Gracia Gutierrez

Not the answer you're looking for? Browse other questions tagged virtualbox or ask your own question.

I've run out of space on a virtual machine disk which is a vmdk and need to resize the virtual image. Resizing with the command

gives the error

How can I resize a vmdk image?

rubo77
8,83715 gold badges76 silver badges162 bronze badges
BrianBrian
14.8k6 gold badges26 silver badges47 bronze badges

16 Answers

If you want to end having back a vmdk hard disk (maybe you are interested in using the disk in vwmare too), the complete steps are:

The above will resize the hard disk up to 50GB (50 * 1024MB).
To complete things you need to resize the drive too! To achieve this, you might want to download gparted iso and boot from that iso to resize your drive (select the iso from within the virtualbox settings).

P.S. If your new size is too small, you'll get the same error even with your new vdi file.

Luca BorrioneLuca Borrione
12k5 gold badges41 silver badges56 bronze badges

I was able to resize the vmdk by cloning it and then modifying and resizing.

allenhwkim
21.3k13 gold badges68 silver badges106 bronze badges
BrianBrian
14.8k6 gold badges26 silver badges47 bronze badges

I have a Windows 7 client on a Mac host and this post was VERY helpful. Thanks.

I would add that I didn't use gparted. I did this:

  1. Launch new enlarged vmdk image.
  2. Go to Start and right click Computer and select Manage.
  3. Click Disk Management
  4. You should see some grayed space on your (in my case) C drive
  5. Right click the C drive and select Extend Volume.
  6. Choose size and go

Sweet! I preferred that to using a 3rd party tool with warnings about data loss.

Cheers!

CodeChopsCodeChopsSize
1,4781 gold badge17 silver badges25 bronze badges

VBoxManage does the trick, but don't forget that you have to use GParted or another tool to allocate the free space created with VBoxManage.

Have a look to my blog post to get detailed information and step by step screenshots.

tvialtvial

Actually, Only this these commands are needed:

Then, you can select cloned.dvi in Virtualbox GUI storage.

After that, start the virtual windows and expand your C disk as the methods of Code Chops.

It is not necessary to convert the *.vdi file to *.vmdk file back.

Liviu T.
20.4k10 gold badges57 silver badges56 bronze badges
New BentleyNew Bentley

Since this is a vmdk file, you could use VMWare's vdiskmanager, if it's available for your platform. VMWare has x86 Linux, Windows, and OS X versions here.

And then you just do:

It avoids having to clone, then expand the disk. Now, the downside is you need the extra tool, and vmdk is VMWare's disk format, and you're still using Virtualbox, so there could be incompatibilities.

qemu-img might also work, but I'm not sure if it supports resizing vmdk files. It would look something like:

And just a reminder, with both, you still have to grow the partition after resizing the underlying disk. All these tools are essentially dd if=/dev/old_disk of=/dev/new_disk bs=16M.

David EhrmannDavid Ehrmann
5,6711 gold badge19 silver badges29 bronze badges

You can use Vmware player to resize a vmdk. This removes the round trip conversion (noted in other posts) if you want to keep it in vmdk format. Just make sure that when you add the vmdk into vmware, don't click upgrade format when prompted, keep the current one in case VirtualBox doesn't accept it.

micwallacemicwallace

For shrinking image size I use the following steps:

  1. On the client machine cat /dev/zero > z;sync;sleep 3;sync;rm -f z
  2. Shut down client machine
  3. On the host VBoxManage clonehd 'source.vmdk' 'cloned.vdi' --format vdi
  4. On the host VBoxManage modifyhd cloned.vdi --compact
  5. On the host VBoxManage clonehd 'cloned.vdi' 'resized.vmdk' --format vmdk
LonderenLonderen

As mentioned in the answer by Luca the required steps are:

  1. Clone the VMDK image to VDI format

    VBoxManage clonehd 'source.vmdk' 'cloned.vdi' --format vdi

  2. Resize the VDI image

    VBoxManage modifyhd 'cloned.vdi' --resize 51200

  3. Clone back to VMDK format

    VBoxManage clonehd 'cloned.vdi' 'resized.vmdk' --format vmdk

Step 3 is optional if you can use a VDI image instead.

All these steps can be carried out in the VirtualBox graphical user interface as well, under File -> Virtual Media Manager. Select the drive you want to clone, and then choose Copy. A dialog opens that allows you to choose the disk format and options. To resize a VDI image, just use the slider in the bottom (click on Properties if it's not visible).

Finally, you may need to change the disk size in the guest OS as well:

  1. Run the guest OS and resize the disk partition(s). If you are running Linux, you can use gparted or kparted.
teekarnateekarna

Tried all the solutions here, but nothing seemed to work. After hours of digging I found this blog post and like magic everything works. I had to make little adjustments so here is the modified version. Tested with Docker version 17.06.0-ce, build 02c1d87.

Once developers really start containerising their applications, they often generate a large number of images and quickly fill up the 20GB hard drive space allocated to the Docker virtual machine by default. To make sure the Docker virtual machine has plenty of disk space, we should resize /dev/sda1 to a number that is more reasonable.

  1. Download GParted Live CD/USB/HD/PXE Bootable Image.
  2. Stop the Docker virtual machine docker-machine stop default.

  3. Boot2Docker package installer ships with a VMDK volume, which VirtualBox’s native tools cannot resize. In order to resize the Docker disk volume, first clone the VDI volume from the default VMDK volume vboxmanage clonehd /full/path/to/disk.vmdk /full/path/to/disk_resized.vdi --format VDI --variant Standard.

  4. Resize the newly cloned VDI volume to the desired capacity. We recommend at least 64GB vboxmanage modifyhd /full/path/to/disk_resized.vdi --resize <size in MB>.
  5. Launch the VirtualBox application, select default VM and click on the “Settings” gear on top.
  6. Click on the “Storage” icon. Remove the default VMDK volume.
  7. Add a new IDE controller.
  8. Mount the GParted ISO via the “Add CD/DVD Device” option.
  9. Mount the cloned VDI volume via the “Add CD/DVD Device” option.
  10. If you are running Docker on a computer with a solid-state hard drive, please make sure the “Solid-state Drive” option is selected for the cloned VDI volume.
  11. Click on the “Start” icon to boot up the Docker virtual machine, which will launch the GParted ISO. Select “GParted Live (Default settings)”.
  12. Set the policy for handling keymaps to “Don’t touch keymap”.
  13. Set language preference to option “33”, which maps to “US English”.
  14. Select option “1” to run “Forcevideo” and configure X manually.
  15. Keep the default resolution of “1024×760” by selecting option “2”.
  16. Keep the default “vesa” as the VGA card.
  17. Keep the default colour depth of “24” by selecting option “0”.
  18. Once GParted launches, click on the “Resize/Move” icon.
  19. Set the new disk volume size to desired size by dragging the slider. In this example, the maximum size is 127,035MB. Click on the “Resize/Move” button to start the process.
  20. Confirm the resizing operation by clicking on the “Apply” button.
  21. Power off the machine after the resizing operation finishes.
  22. Remove the GParted ISO.
  23. Log into the Docker virtual machine to verify that the volume resizing was successful by starting machine docker-machine start default
  24. If you experience network issues, restart the docker-machine
AkoAko

VirtualBox for Windows

Resizing your disk file while preserving your virtual machine settings!

Step 1 - Resize the disk file

Virtualbox Increase Disk Size Vmdk

Start cmd.exe

cd to Oracle VM VirtualBox's dir (on 64-bit systems: 'C:Program FilesOracleVirtualBox')

Run these commands (as above):

Windows explorer and 'copy address as text' via the address bar should help you get the path you need.

On windows system, The VirtaulBox VM directory underneath your user may contain an XML formatted database file of settings you've configured for your VM. Rename this file, with a .bak extension (it has a .vbox extension). Rename the original .vmdk file with a .bak extension as well to avoid another error. You can now safetly perform the third step without the error message to convert the machine back to .vmdk format, or the 'duplicate disk' error.

You will be presented with a UID token. Copy this token by drag-highlighting it from the Windows Command Interpetor window and using the Ctrl+C keyboard shortcut.

Open the .vbox.bak file in a text editor such as Notepad++. You'll be presented with an XML-like database file. Look for these lines:

On the line <HardDisk uuid='{some uid}' location='C:path_tosource.vmdk' ..., delete the old UID token between the brackets and paste the one you copied from the command window. Make sure that you leave the brackets in place!

Save this file, and exit your text editor. Rename the .vbox.bak file to give it back its expected extension of .vbox.

Step 2 - Remove the junk

It is now safe to remove the .bak files remaining in the directory. What remains is a resized .vmdk with an updated .vbox database while with your previously preserved VirtualBox Manager settings.

Step 3 - Resize the disk's partition to fill the free space

You can now start the VirtualBox VM Manager and execute your VM, using the appropriate tools for the operating system to fill the new free space.

For Windows VMs, use diskpart from the command prompt booted from the Windows Recovery Consule (recovery partition) to SELECT DISK 1, LIST PARTITION and gather the partition number of your C: drive, then SELECT PARTITION #. You can use the EXTEND SIZE=mb to resize the Windows C: drive to the appropriate value. Make sure you leave room for the recovery and boot partitions! It's safe to subtract 4096 MB from your new virtual disk size to get this value, because of shadow copy and windows recovery files.

For Linux VMs, a live .ISO of gparted you can boot with the VM's disk file can be found at: http://gparted.org/ It will get you straight into a graphical user interface-based gparted-gtk, from where you can fill your free space.

For PPC / Mac VMs, Disk Utility from the Finder will asisst you in filling the free space, but you may want to consider the gparted Linux option, as currently the only method of which to boot MacOSX in VirtualBox is hackintosh, and you cannot extend your volume while booted into MacOSX. You may also want to seek out tweaking the VM's settings temporarily for gparted, to get it to boot. MacOSX partitions are recognized by gparted as HFS - 'Heaping File System' partitions.

Step 4 - Cat Photos

Because the internet. ;) You're finished. Enjoy your new resized virtual .vmdk disk image with VirtualBox for Windows!

Robert SmithRobert Smith

Here's a way to resize your VirtualBox disk, regardless of whether it is a fixed format or dynamic format disk. Specifically, it prevents the error you had when you disk is fixed-format.

⚠️ Backup the virtual disk. You never know what might go wrong.

On your host:

  1. Open a terminal window.

    On Windows: Open the command prompt cmd.

  2. Go to the directory with the virtual disk you want to resize. For example:

  3. Create a new VirtualBox disk with your desired filename, size (in megabytes) and format (either Standard (dynamic) or Fixed). For example, to create a 50 GB fixed-format disk called MyNewDisk.vdi:

    If VBoxManage is not recognized as a command, specify the full path to it. It can be found in the VirtualBox installation directory. On Windows the above command would become:

  4. Copy the original disk to the new disk.

  5. The resize is done! You can check the properties of the new disk if you want:

  6. Change the virtual machine to use the new disk instead.

Next, on your guest OS you need to resize the partitions to use the newly available space.

Daniel A.A. PelsmaekerDaniel A.A. Pelsmaeker
30.1k14 gold badges86 silver badges139 bronze badges

I've got here because I needed to resize a disk for my Docker (CoreOS) development environment.

CoreOS docs says there's no need to resize the OS partition - that's bogus. After you resize the virtual disk you should follow these instructions and resize the OS partition via GParted:

lucasmartinslucasmartins

A quick and simple option:

  1. Turn off machine
  2. Create new virtual box disk with desired size
  3. Move content from old disk to inside new disk:

  4. Turn on machine

  5. You may have to resize partition in OS to fill the rest of the disk

Warning

If new disk is shorter than source, you will loss the data located from the new disk size position on the source disk.

You may prevent this deallocating delta space, where delta = size(source-disk) - size(new-disk), at the end of source disk inside OS before step 1.

Andre FigueiredoAndre Figueiredo
8,0615 gold badges34 silver badges63 bronze badges

Download/Install/Use VMWare Workstation and create new VM Based on your current vmdk file and then you can resize your vmdk. For details regarding this matter google for VMWare.

kguest
3,5223 gold badges25 silver badges31 bronze badges
Prem for teaching of LCAPrem for teaching of LCA

Simply you have to follow the following steps:

  1. Power off your machine.
  2. Right click on virtual machine name > Settings > Storage
  3. Click on Controller : SATA > Add Hard Disk.
  4. Choose the new hard disk drive type size and hit create.
  5. Discard the machine state.
  6. Insert Ubuntu Live CD.
  7. Boot from ubuntu live cd.
  8. Open 'gparted' (It's installed, not need to installation).
  9. Check if the system see your new created hard disk.
  10. Open Terminal.
  11. Type the following code.
  12. sudo dd if=/dev/sda of=/dev/sdb (The first is the old partition path, the second is the new partition path).
  13. Wait until its finish copying data (This step may take some time according to your host specs).
  14. After finish copying, return to gparted and select refresh devices.
  15. Select the new partition /dev/sdb it must be typical to the old one after doing dd command.
  16. It'll show the expanded space as unlocated data.
  17. Delete Swap partition/Extended partition.
  18. Right click on root partition /dev/sdb > Resize
  19. Allocate the whole space without swap allocation.
  20. Create new extended partition > Choose extended > Create
  21. Create new linux-swap partition > choose linux-swap > Create
  22. Now turn off your running machine.
  23. Right click on machine > settings > Storage.
  24. Eject ubuntu live cd.
  25. Right click on the old hard disk > remove attachment.
  26. Now you can start your vm from the newly created hard disk.
  27. Check the storage by enter df -kh command.
  28. It must show you the new size.

Congratulation, enjoy your free space.
This video will help you:https://youtu.be/ikSIDI535L0

Mohammad NimerMohammad Nimer

protected by Aniket ThakurNov 13 '17 at 9:24

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged virtualbox or ask your own question.