How to Resize Dynamic Disk in Oracle VirtualBox (Updated). Features of working with VirtualBox virtual disks

The specifics of my work are such that I often have to test programs, services, etc. Also in everyday life I install many programs I need on my computer. First, I check new programs, and then, if the program is worthy, I install it on my computer. I'm testing applications outside of my home. operating system(hereinafter referred to as “OS”) so as not to clutter it. Many don't knowledgeable people The question will immediately arise: “Where do you test, if not in the main OS?” The answer is simple: “In the guest OS!” If you don’t know anything about this, then study information about virtualization systems. In this article I will tell people who know what virtualization systems are how to increase the disk of a virtual machine that runs on “VirtualBox”.

Many people using “VirtualBox” often encounter a problem when the guest OS runs out of space on the hard disk (virtual hard disk). In this case, many people add a second hard drive to the guest OS.

However, there is a way to increase hard volume disk on which the guest OS is directly installed. Let us consider in order the issue of increasing the capacity of the hard drive; for this it is necessary to perform a number of operations. So let's get started.

You can increase the disk size if it is in the native VirtualBox format, with the extension vdi. If you exported a virtual machine, then most likely your disk is in the format vmdk and the operations described below are not for you.

1) The guest OS must be turned off.

2) Delete all the “snapshots” you took, I hope you know what they are (see Fig. 1).

3) Find the path where you installed “VirtualBox” itself, by default it is installed in the path “C:\Program Files\Oracle\VirtualBox\VBoxManage.exe”.

4) Find where it is virtual hard the drive of your guest OS and the name of the drive (see Fig. 2). For me it is located along the path: “C:\VM (VirtualBox)\Win7-x64\Win7-x64.vdi”.

5) Launch command line, to do this, type “cmd” in the “Start” menu and press “Enter” (see Fig. 3).

If it doesn’t work, then run it manually, it is located at the path: “c:\Windows\System32\cmd.exe”.

6) At the command line, enter the command “modifyhd -resize” and press “Enter”.

For example, I will get the following command:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd "C:\VM (VirtualBox)\Win7-x64\Win7-x64.vdi" --resize 25000

Thus, I increased the disk to 25,000 megabytes, or almost 25 gigabytes (we won’t calculate exactly). But that's not all, because guest machine does not see the added free space, to do this you need to launch the guest OS and expand the disk under it, because we added space to the disk. Let's get started...

7) We launch the guest OS.

8) Go to computer management (see Fig. 5).

9) We go to disk management and here we see our “C” drive and the free unallocated space that has appeared, which we will add to the “C” drive (see Fig. 6).

10) We expand the volume (drive “C”), to do this, click right click mouse on the “C” drive and select the “Extend volume” menu item (see Fig. 7).

11) In the next window, click the “Next” button and a window will open in which we will see that the system itself automatically offers to add all the free space to the “C” drive. We leave everything as is, without changing anything, and click the “Next” button (see Fig. 8).

In the next window, click the “Finish” button.

All. Now the size of the “C” drive in the guest OS has become larger. We enjoy our future work.
Those who are not familiar with virtualization systems, I recommend that you get acquainted with them, as they are useful, and for many, vital.

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 volume base disk. Fortunately, this is very easy to do, just open the command line, go to the directory VirtualBox installations, then run the modifyhd –resize command, specifying the new virtual volume hard drive. 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” on the command line hard disk operation for this format is not implemented yet!" 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 sites dedicated to computer topics you 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 reality there is a much simpler and effective way expand the disk and that’s what we’ll 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, in at the moment Our 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 new image To SATA controller, then open the virtual machine, go to the disk management section and use the added unallocated space in the way you want. You can delete the old VDI file.

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

In case when creating a virtual machine you did not guess the size, in Oracle VirtualBox There is standard feature resize the virtual disk. It’s true that you won’t be able to change the disk size from the graphics tool; to do this you’ll have to use console utility VboxManage.exe, included with VirtualBox.

Increase in size

Open a command prompt and go to the C:\Program Files\Oracle\Virtual Box directory (the default VirtualBox installation directory). Let's display information about the virtual disk WKS2.vdi with the command:

VboxManage.exe showhdinfo C:\VM\WKS2.vdi

The Logical size line indicates maximum size disk - 25600 MB (25 GB). Let's increase it to 30 GB (30720 MB) with the following command:

VboxManage.exe modifyhd C:\VM\WKS2.vdi −−resize 30720

And then let's look at the disk data again.

After increasing the size of the virtual disk, you need to go into the guest system and increase the size logical drive. You can do this from the Disk Management snap-in (discmgmt.msc) by selecting context menu"Extend volume" item. This feature is available in all Windows operating systems, starting with Vista\Server 2008. In other operating systems you will have to use third party programs, For example Acronis Disk Director.

Downsizing

The opposite situation is also possible, when it is necessary to reduce the size of the disk space occupied by the virtual machine. In this case, the algorithm of actions is different.

First, we go into the guest system and delete everything unnecessary. Then we will clean up free sectors of the disk using the Sdelete utility from Sysinternals. The utility does not require installation; you just need to unpack it and run the command Sdelete.exe -s -z from the command line.

Note. On Linux, you can use the ZeroFree utility to clean up your disk.

After cleaning, turn off the virtual machine, open the command line on the host machine and run the command:

VboxManage.exe modifyhd C:\VM\WKS2.vdi −−compact

This command compresses the virtual disk image, reducing the amount of disk space it takes up. In this case, the logical size of the disk will remain unchanged. You cannot reduce the disk size using the resize key; this method only works towards increasing it.

In conclusion, upsizing is only possible for dynamic VDI ​​or VHD disks, and compression is only possible for VDI disks. All other options are not supported, but at least for now. And yet, before resizing the disk, do not be lazy to do it backup copy, just in case :)

Oracle VM VirtualBox is one of the most popular and stable software, with which users can install and test operating systems different versions and assemblies. When creating a new virtual machine image, VirtualBox allows users to select the virtual disk size they need, RAM, and graphics subsystem memory. But after installing the operating system on a virtual machine, users cannot always resize the virtual disk so easily. This option is not available in 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 the virtual hard drive, 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 size of virtual disk space 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 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, disk space which 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 hard size disk 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 grow 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 in 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 it will be located image of a tough disk. 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. Click on it right key mouse and select "Create Volume".


Step 7

In the volume creation wizard, you will have to specify its size step by step,


assign a letter, and also select a file system.


After this, next to one virtual disk, you will have a second one created, while absolutely not affecting the first one.

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 virtualbox program, the assigned volume may not be enough during the work process. 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 to dynamic, then work will be carried out with the clone. For those who are not in the know, all information (folders, files, installed programs) from a donor. 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 drives select the one you want, 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 ensure 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 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.

Let's go to my computer and see that the volume remains the same as 20GB. The whole point is that in the very virtual system you need to expand the volume. When creating a clone, it is created exact copy, 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 we need to add this section to the section (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 see, there is no longer any undistributed space, so it has found distribution in local disk(WITH:).

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!