How to increase the size of a VirtualBox virtual disk. How to Change Dynamic Disk Size in Oracle VirtualBox (Updated)

16 answers

If you want to stop vmdk hard drive backup (maybe you are interested in using the drive also in vwmare), follow these steps:

VBoxManage clonemedium "source.vmdk" "cloned.vdi" --format vdi VBoxManage modifymedium "cloned.vdi" --resize 51200 VBoxManage clonemedium "cloned.vdi" "resized.vmdk" --format vmdk

The above will change the hard drive size to 50GB (50*1024MB).

To complete things you need to resize the disk too! To achieve this, you can download an iso and boot from that iso to resize your disk (select iso in virtual box settings).

PS If your new size is too small you will get the same error even with your new vdi file.

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

  • Launch a new larger vmdk image.
  • Go to the Start menu and right-click Computer and select Manage.
  • Select "Disk Management"
  • You should see some gray space on your (in my case) C drive
  • Right-click drive C and select Extend Volume.
  • Select size and click

Sweet! I preferred to use a third party tool with data loss warnings.

Actually, only these commands are needed:

VBoxManage clonehd "source.vmdk" "cloned.vdi" --format vdi VBoxManage modifyhd "cloned.vdi" --resize 51200

You can then select cloned.dvi from the Virtualbox GUI storage.

After that, launch virtual windows and expand your C drive like Code Chops methods.

There is no need to convert the *.vdi file to a *.vmdk file.

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

And then you just do:

1023856-vdiskmanager-windows-7.0.1.exe -x 30720M Machine-disk1.vmdk

This avoids cloning and then expanding the disk. Now you need an additional tool and vmdk is a VMWare disk format and you are still using Virtualbox so there may be incompatibilities.

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

Qemu-img resize Machine-disk1.vmdk +8G

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

You can use Vmware player to resize vmdk. This removes the round trip conversion (see other posts) if you want to save it in vmdk format. Just make sure when adding a vmdk to vmware, don't select the update format when prompted, keep the current one if VirtualBox won't accept it.

Tried all the solutions here, but nothing worked. After hours of digging, I found this blog post and like magic, everything works. I had to make some minor adjustments, so here's a modified version. Tested with Docker version 17.06.0-ce, build 02c1d87.

Once developers actually start containerizing their applications, they often generate a large number of images and quickly fill up the 20GB hard drive space allocated to the default Docker VM. To ensure that the Docker VM has enough disk space, we must resize /dev/sda1 to a more reasonable number.

VirtualBox for Windows

Changing the file size on disk when preservation virtual machine settings!

Step 1 - Change file size on disk

Run cmd.exe

cd to the Oracle VM VirtualBox directory (on 64-bit systems: "C:\Program Files\Oracle\VirtualBox\")

Run these commands (as above):

VBoxManage clonehd "C:\path\to\source.vmdk" "C:\path_to\cloned.vdi" --format vdi VBoxManage modifyhd "C:\path\to\cloned.vdi" --resize 51200

Windows Explorer and "copy address as text" via the address bar should help you find the path you want.

On a Windows system, the VirtaulBox VM directory under your user may contain an XML database file with the settings you have configured for your virtual machine. Rename this file with a .bak extension (it has a .vbox extension). Rename the original .vmdk file with the .bak extension as well to avoid repeating errors. You can now safely complete the third step without an error message to convert the machine back to .vmdk format or with a "duplicate disk" error.

VBoxManage clonehd "C:\path_to\cloned.vdi" "C:\path_to\source.vmdk" --format vmdk

You will be presented UID token. Copy this token by dragging it out from the Windows Command Interpetor window and using Ctrl+C

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

In line delete old UID marker between brackets and insert the one you copied from the command prompt window. Make sure you leave the parentheses on the spot !

Save this file and exit the text editor. Rename the .vbox.bak file to return it to the expected .vbox extension.

Step 2 - Remove junk

It is now safe to delete the .bak files remaining in the directory. What remains is the .vmdk size with the updated .vbox data while with the previously saved VirtualBox Manager settings.

Step 3 - Resize the disk partition to fill up the free space

You can now launch VirtualBox VM Manager and start your virtual machine using the appropriate operating system tools to fill the new free space.

For Windows virtual machines use diskpart from the command line downloaded from the Windows Recovery Consule (recovery partition) in SELECT DISK 1 , LIST PARTITION and collect the partition number of your C:\ drive, then SELECT PARTITION # . You can use EXTEND SIZE=mb to resize the Windows C:\ drive to the appropriate size. Don't forget to leave room for recovery and boot partitions! To get this value, you can safely subtract 4096 MB from your new virtual disk size due to Windows Shadow Copy and Recovery files.

For Linux virtual machines A live gparted .ISO that you can download with the virtual machine disk file can be found at: http://gparted.org/. It will open you directly to gparted-gtk based GUI from where you can fill your free space.

For PPC/Mac virtual machines Disk Utility from Finder will help you fill up the free space, but you might want to consider gparted Linux variant since currently the only way to boot MacOSX into VirtualBox is hackintosh and you can't extend it. your volume when booting into MacOSX. You can also temporarily gparted the virtual machine settings for gparted to load it. MacOSX partitions are recognized by gparted as HFS - "Heaping File System" partitions.

Step 4 - Cat Photos

Because the Internet. ;) You're done. Enjoy your new .vmdk virtual .vmdk disk with VirtualBox for Windows!

Here you can change the VirtualBox disk size, whether it is a fixed or dynamic format. In particular, it prevents the error you are experiencing with a fixed disk format.

⚠️ Virtual disk backup. You never know what could go wrong.

On the host:

    Open a terminal window.

    On Windows: Open a cmd prompt.

  • Go to the directory with the virtual disk you want to change. For example:

    Cd "My VMs"

    Create a new VirtualBox disk with the desired file name, size (in megabytes), and format (either Standard (dynamic) or Fixed). For example, to create a 50 GB fixed format disk named MyNewDisk.vdi:

    VBoxManage createmedium --filename "MyNewDisk.vdi" --size 50000 --variant Fixed

    If VBoxManage is not recognized as a command, provide the full path to it. It can be found in the VirtualBox installation directory. On Windows, the specified command would look like this:

    "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" createmedium --filename "MyNewDisk.vdi" --size 50000 --variant Fixed

  • Copy the original disk to the new disk.

    VBoxManage clonemedium "MyOriginalDisk.vdi" "MyNewDisk.vdi" --existing

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

    VBoxManage showmediuminfo "MyNewDisk.vdi"

    Change the virtual machine to use the new disk.

    I have it here because I needed to resize the disk for my Docker development environment (CoreOS).

    Oracle VM VirtualBox is one of the most popular and stable software through which users can install and test operating systems of various versions and builds. When creating a new virtual machine image, VirtualBox allows users to select the size of the virtual disk, RAM, and graphics memory they need. But after installing the operating system on a virtual machine, users cannot always change the size of the virtual disk so easily. This option is not available in a virtual environment. In this article we will tell you how to fix this situation and increase the size of your virtual disk space.

    IMPORTANT! When performing any manipulations with a virtual hard disk, always make a backup copy of it!

    Method 1 - Using the Command Line

    Note: increasing the size of virtual media is only supported in dynamic disks in VDI or VHD format.

    If you want to increase the virtual disk space size using the following rules:

    Step 1

    Go to your main operating system and open a command prompt with administrator privileges.


    Step 2

    Type the following command and press Enter:

    CD C:\Program Files\Oracle\VirtualBox\

    Step 3

    After that, enter the following command:

    vboxmanage 30000 modifyhd-[new disk size] "D:\VirtualBox\Windows 8.1 Preview.vdi"

    Instead of the specified path, you need to specify the path where your image is stored.


    Note: This command will increase the amount of virtual disk space on VirtualBox, but to use it you need to follow the steps below:

    Step 4

    Open VirtualBox and start the virtual machine whose disk space you want to expand.

    Step 5

    If you have Windows installed, then you need to launch the Disk Management console (press the Win+R key combination and enter “diskmgmt.msc” in the field, then click “OK”).

    Step 6

    In the Disk Management console, the disk space you added will appear as unallocated. To enable it, right-click on the virtual disk and select "Extend Volume".


    Step 7

    Increase the disk capacity to the limit and click OK. The procedure will take a few minutes, after which the size of the hard drive will be changed.

    Note: Before performing the steps described above, we recommend that you create a backup copy of the virtual machine whose disk capacity you want to increase. Also pay attention to the fact that the partition on which you store the virtual machine (.VDI) must have enough free space to be able to expand the virtual disk.

    Method 2 – Create a second partition

    In some cases, the above method may lead to data loss, so we will consider the second method - the safest. It consists of creating a second virtual hard disk and connecting it to your current virtual machine. You can do this as follows:

    Step 1

    Shut down the virtual machine and go to its settings.


    Step 2

    Go to the “Media” submenu and in the “Storage media” field, click on the “Add device” icon. Select "Add Hard Drive".


    Step 3


    Step 4

    A configurator will open in front of you, in which you need to specify the name and path where the hard disk image will be located. Also, do not forget to indicate its size and type (preferably VDI). After you have set the values ​​that suit you, click the “Create” button. A new virtual HDD will be created and immediately added to the virtual machine.


    Step 5

    Start the virtual machine, go to the disk manager as described in method 1 (step 5).

    Step 6

    You will see an unallocated disk partition. Right-click on it and select “Create Volume”.


    Step 7

    In the Volume Creation Wizard, you will step by step specify its size,


    assign a letter, and also select a file system.


    After this, next to one virtual disk, you will have a second one created, without affecting the first one at all.

    What to do if you have a virtual Linux OS?

    If you have Linux installed on your virtual machine, then the expansion in the physical OS is done in the same way as in the methods described above, but when starting a guest OS, you need to act differently, since there is no disk manager in Linux OS, as such. To add a created disk or expand an existing one, do the following:

    Step 1

    Open the console, type "su" and press enter.

    Step 2

    Enter the administrator password and press Enter.

    Step 3

    Install the "GParted" package. To do this, enter the command in the console:

    For Ubuntu, Debian, Mint distributions it will look like this:

    sudo apt-get install gparted

    For Fedora, Centos, the command will look different:

    su yum install gparted

    Step 4

    Wait until the package is downloaded and installed. For the installation to complete successfully, your virtual OS must be connected to the Internet.

    Step 5

    Launch GParted. In the main window you will see a list of all available drives. Here you will also find the area you added. It will be marked as unmarked.


    Now, depending on which of the methods above you chose, do the following:

    For method 1:

    1. Right-click on your current disk on which the OS is installed and select “Resize”.
    2. In the new window, use the slider to specify the new disk size, taking into account the amount of space that you have allocated. After that, click the “Resize” button.
    For method 2:

    When creating a virtual disk in the virtualbox program, the assigned volume may not be enough during operation. Then you will need to somehow increase the disk size. In principle, this is not difficult to do in the case of dynamic media, but complications can arise if the disk is fixed. Since the program does not provide for an increase in the volume of this type of created media.

    But don’t despair, there is still a solution, although it will take more time. This method is carried out by cloning a fixed disk and converting it into a dynamic one, then work will be carried out with the clone. For those who do not know, all information (folders, files, installed programs) from the donor is transferred to cloned disks. Well, let's look at this issue using a visual example.

    Cloning a fixed disk in VirtualBox

    Open the program and go file -> virtual media manager.

    In the list of virtual hard disks, select the one you need, right-click and click copy. In my case, this is a fixed Windows 7, with a capacity of 20 GB.

    We have already selected the disk, so click next.

    We indicate the type of clone to be created, I prefer VHD, you can choose another one.

    In this window we are naturally interested dynamic virtual hard disk.

    Set any name for the future disk and click copy.

    We wait approximately 10-15 minutes for the cloning process to complete.

    After completing the procedure, go to the folder with virtual disks to make sure that the media has been created.

    Increasing disk size in VirtualBox

    Having made sure of creation, we proceed to the procedure for increasing the size. Here we will need to open the command line. If you have Windows 10, then right-click on the start menu and open the command line, preferably as an administrator.

    In the case of seven, press start and enter in the search cmd, run the found file as administrator.

    Now we will need to enter a specific command, but first we need to make sure the location of the folders with the program files and the virtual disk (clone).
    Once you are sure, enter the command:

    "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd "H:\VirtualBox VMs\Windows 7\Windows 7_2.vhd" --resize 31000

    • C:\Program Files\Oracle\VirtualBox\VBoxManage.exe- path to the folder with virtualbox program files.
    • H:\VirtualBox VMs\Windows 7\Windows 7_2.vhd- location of the created disk (clone).
    • --resize 31000- command to resize up to 31000MB.

    We are waiting for the end of the process.

    Create a virtual machine

    After opening virtualbox, press the button create.

    In expert mode, enter the desired name, OS type 1, indicate the required amount of memory (RAM) 2, select the item use an existing virtual hard disk 3 and press the review button 4.

    Select our clone and click the open button.

    Now click create.

    As we can see the machine has been created, let’s launch it.

    We go to my computer and see that the volume remains 20GB. The thing is that in the virtual system itself you need to expand the volume. When creating a clone, an exact copy is created, and the volume itself must be increased manually in the system.

    Increasing the disk size in a virtual machine

    To do this, go to control computer by right-clicking on the My Computer icon and selecting the appropriate item.

    Here we are interested in the tab disk management. As you can see, there is unallocated space in the size 9 GB. That's exactly what we need. Now you need to add this partition to the partition (C:), to do this, right-click on (C:) and select the item expand volume.

    The size of the allocated space should be maximum, since we are transferring the entire disk volume.

    Ready.

    As we can see, there is no longer any unallocated space, so it has found distribution in the local disk (C:).

    When we log into my computer we will see that the disk size has been increased.

    Perhaps you will say The disk is also dynamic, but we wanted to increase the size of the fixed one. So, now you clone the created clone and convert it to a fixed one, fortunately you have already learned how to do this and will get what you wanted.

    ABOUTGive your opinion about this article, and of course, ask your questions if something suddenly goes wrong for you.

    Thank you for your attention!

    How to expand a virtual disk in VirtualBox?

    Hello dear readers of the Internet resource!!!

    Sometimes when working with a VirtualBox virtual machine, you may need to increase the size of the base disk. Fortunately, this is very easy to do, just open the command line, go to the VirtualBox installation directory, and then run the modifyhd –resize command, specifying the new size of the virtual hard disk. And everything was just fine, if not for one small “but”.

    You can only expand a dynamic virtual disk in this way; this trick will not work with fixed disks, and you will receive the error “Resize hard disk operation for this format is not implemented yet!” on the command line. This means that this function, that is, resize, is not implemented for a fixed disk type.

    It's a pity, but so far there are no ways to expand a fixed disk in VirtualBox. However, we can use a little trick. We will convert a fixed disk into a dynamic one, after which we will add the volume we need in a well-known way.

    On the pages of a number of websites devoted to computer topics, one can find a description of a method for “expanding” a fixed disk using the SelfImage utility, a method that is clearly inconvenient and cumbersome, because in this case the user had to perform at least eight different operations.

    In addition, in addition to SelfImage itself, which is now practically unused, the user had to resort to the diskpart utility in order to “align” the disks.

    In fact, there is a much simpler and more effective way to expand the disk, and that is exactly what we will use. So let's get started. Open a command prompt and go to the VirtualBox installation directory:

    cd C:/Program Files/Oracle/VirtualBox

    As you already know, you can get information on a virtual disk using the showhdinfo command.

    VboxManage.exe showhdinfo "D:/Virtual Box/Windows 8.0/Windows 8.0.vdi"

    As you can see, at the moment the disk type (format variant) is fixed, and the size (capacity) is 18432 MB. Now we need to convert the static disk to dynamic.

    Since this cannot be done directly, we clone the first one and thus get what we were looking for. To do this, use the clonehd command:

    VBoxManage clonehd "D:/Virtual Box/Windows 8.0/Windows 8.0.vdi" "D:/Virtual Box/Windows 8.0/Clone Windows 8.0.vdi"

    If there are spaces in the path to the original VDI image and its clone, we enclose the path in straight quotes. The cloning process may take some time.

    Once the copying is complete, you can run showhdinfo again and see what you got. Let's check our clone:

    VboxManage.exe showhdinfo "D:/Virtual Box/Windows 8.0/Clone Windows 8.0.vdi"

    If everything goes smoothly, then the format variant will no longer be fixed, but dynamic, which is what we have. But now we can use the familiar resize command.

    VBoxManage modifyhd --resize 40960 "D:/Virtual Box/Windows 8.0/Clone Windows 8.0.vdi"

    As you can see, there were no errors, and the disk successfully expanded to the specified value. Well, that’s practically all, all that remains is to connect the new image to the SATA controller, then open the virtual machine, go to the disk management section and use the added unallocated space in the way you need. The old VDI file can be deleted.

    This is where I will probably end my non-trivial story for now and until new educational meetings with you, dear friends...

    Rating: / 9

    Badly Great

    You know, I was wrong when I said that 20 Gb is enough for development. After the release of the XCode 4.2 update, or rather the iOS SDK update to iOS 5, I ran into the problem that I didn’t have enough 4 GB of free space for installation.

    It's a pity, it's a pity. Again - dancing with a tambourine and shamanic things.

    Let's get started?

    To expand the dynamic disk (I hope you won't shrink it), you need to follow these steps:

    1. I would recommend saving the .vdi of your disk, just in case
    2. run CMD.exe (and again I would recommend running it as administrator)
    3. go to the folder where VirtualBox is installed. If you didn’t think of anything during installation, it will be here:

      C:\Program Files\Oracle\VirtualBox

    4. Next you need to run the following command:

      VBoxManage modifyhd (path to your virtual machine folder)\osx64.vdi --resize (size in megabytes)

      Something like this: VBoxManage modifyhd d:\vms\osx64.vdi --resize 65000

    We check:

    Actually, we have already persuaded VirtualBox. All that remains is for Mac OS X Lion to believe in miracles.


    We launch our virtual machine with Mac OS X Lion, go to Finder and see...

    hmm... not very nice.

    Well, let's fight!

    Launching Mac OS Disk Utilities

    Let's look at Partision. And we see that we now have plenty of space:

    That's it... you can live, there are only a couple of manipulations left until victory!

    We are expanding our spaces:

    Thus, we expand the selected partition of the Mac OS hard drive to the maximum.

    You must click Apply and agree to change the size of the selected partition.

    Now close/open Mac OS Disk Utilities and...

    HOORAY! We defeated everyone!!!

    It took me about 4 minutes in total to change the size, from searching for information to actually doing things, and I also spent 10 minutes writing this article. Don't listen to anyone who says that resizing a dynamic disk on a MacOS X Lion guest operating system is a labor-intensive and time-consuming task! No no and one more time no.

    With thanks to the sources:

    • How to resize a VirtualBox disk with a guest OS installed

    DEDICATED TO EVERYONE WHO HAS READ SO far!

    Unfortunately, I have to inform you that the trick will not work! Resizing the main partition as it is installed with Mac OS is not possible without completely deleting the data on it . Those. - complete re-creation of the section. If you give yourself a reason to work hard, then this is confirmed on the official Apple website in the documentation.

    What should I do?


    Of course there is a solution. True, it no longer fits into 4 minutes. I told you how to create a backup copy. If you haven't done this yet, now is the time.

    Having created a backup copy, we restart the guest Mac OS in VirtualBox and start it from the boot disk. Mac OS will happily inform us that, alas, dear man, it’s no good, because you won’t be able to shave anymore. Those. I can’t install, I can only restore. Well, okay. For now, we don’t need either one or the other. And we need to go to disk utilities, which are currently located in the top of the screen in the system menu.

    We launch disk utilities, select our long-suffering disk and... we try to do the same thing that we have already done and get, of course, a shock. Wiping away a stingy man's tear with our sleeve, we stupidly recreate the disk by selecting setting 1 (i.e., we allocate all the space in the partition for it). We give him the same name, but we can give him another name, but for what? And we agree to kill.

    This procedure is instant. I pressed it, got a new clean disk and that’s it. Then all that remains is to start restoring from the backup copy, selecting the second disk (which I call backup) and the most recent copy on it. Restoring 20 Gb took me 45 minutes.

    What I really regret and am more and more inclined to the idea of ​​​​buying an Apple Mac and not fooling around with VirtualBox anymore

    Yes, I completely forgot. Another solution would be to use all sorts of paragons and other iPortitions. True, they are worth it... But the inquisitive mind of a Russian programmer will always find a thread for the most cunning cutting. To be honest, searching for threads is comparable in time to the method I described above.