How to resize a disk of a virtual machine in VirtualBox?

VirtualBox

The use of a virtual machine in our system can be a great help to be able to test applications in different systems and configurations and it is even an excellent option to be able to test different operating systems without having to reinstall on our computer or compromise our data.

In order to achieve all this we must make some previous configurations to be able to run the virtual machine on our computer. Among these is to allocate a disk space in our system.

By doing this, a virtual disk is created which serves to store the information of the virtual machine, this space can be assigned from the creation of the virtual machine.

This disk space usually gives you a few GB of space, since many times it is not necessary to have to install many applications or store personal information.

However in some occasions the case happens in which this disk space is not enough so we have to allocate more space to the virtual machine disk.

Performing This process is no longer so simple, since from the application's graphical interface it is not possible so we must resort to executing some commands to be able to resize the space.

Resizing the disk space of a virtual machine

To carry out this process we must know in what format the disc was created Given the we will do this process for VDI, so that, if you have a disc in another format like for example vmdk, must convert to VDI to be able to perform the process size change.

Entonces We must locate where the configuration with the virtual machine disk is stored.

These are generally kept in the virtual machines folder of VirtualBox in our personal folder which the path is the following:

"~ / VirtualBox VMs"

Inside this folder the configurations of the virtual machines are saved, in it we will enter the folder where the disk of the virtual machine that we want to resize is stored.

Resize VirtualBox disk size

Already located the route, We must execute the following command which we will replace with the path of your machine virtual, as well as the name of the disk, as well as the space to be resized:

VBoxManage modifyhd /ruta/a/tu/disco.vdi --resize 20000

Where the size on disk is represented in MB after –resize

Now If your disk is in the vmdk format to convert to the vdi format we do it with:

clonehd VBoxManage "disco.vmdk" "disco.vdi" VDI --format

Once this is done, we can now proceed to modify the disk space with:

modifyhd VBoxManage "disco.vdi" --resize 20000

And finally we can restore the disk format to the previous one with:

clonehd VBoxManage "disco.vdi" "disco.vmdk" --format vmdk

If you created your disk in fixed size, you will receive this error:

0%...

Progress state: VBOX_E_NOT_SUPPORTED

VBoxManage: error: Resize medium operation for this format is not implemented yet!

To solve this problem we are going to clone the disk to the standard variant (dynamically assigned) with the following command:

vboxmanage clonehd nuevo-nombredel-disco.vdi /ruta/del/disco.vdi --variant Standard

Done this we run the resize command again:

VBoxManage modifyhd /ruta/a/tu/disco.vdi --resize 20000.

Allocating the new space.

After you have resized the disk space, andThis new space will be detected as unallocated space for some partition.

So basically the virtual machine system kept detecting the initial allocated space and would not use the one that was just allocated additionally.

To be able to allocate this space it is necessary to unmount the disk, so the system we are using in that virtual machine will not be able to do it.

That is why We need to use a live mode system or use another virtual machine and mount that disk that was resized on it.

The first option is the most viable since for GNU / Linux systems most of them usually offer the Live mode option and have the Gparted tool installed natively.


A comment, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   jordi ruiz said

    Very good post, it works the first time, thanks.