Ubuntu – How to increase the hard disk size of the virtual machine in ubuntu?
Tags: ubuntu
Published: 2021-12-07 18:40:10

---
title: Ubuntu – How to increase the hard disk size of the virtual machine in ubuntu?
published: true
date: 2021-11-27 10:54:35 UTC
tags: Ubuntu
canonical_url: https://stackallflow.com/ubuntu/ubuntu-how-to-increase-the-hard-disk-size-of-the-virtual-machine-in-ubuntu/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">hard drive</span><span style="font-size: 1.2em; color: initial;">virtualbox</span><span style="font-size: 1.2em; color: initial;">windows xp</span></p>
</header>

![enter image description here](https://i.stack.imgur.com/HGT26.png)

I have run out of space on my WinXP virtual machine, which I only gave 10 GB space for when I created it. Is there an easy way to increase it to, say, 20 GB? I can’t see any obvious option in VirtualBox settings.

* * *

The suggestion below gives this error

```
wim@wim-ubuntu:/media/data/winxp_vm$ VBoxManage modifyhd wim.vdi --resize 20000
VBoxManage: error: Cannot register the hard disk '/media/data/winxp_vm/wim.vdi' {46284957-2c09-4e70-8a49-bfbe0f7f681d} because a hard disk '/home/wim/VirtualBox VMs/winxp_vm/wim.vdi' with UUID {46284957-2c09-4e70-8a49-bfbe0f7f681d} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBox, interface IVirtualBox, callee nsISupports
Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, AccessMode_ReadWrite, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 210 of file VBoxManageDisk.cpp

```

* * *

Removing the .vdi from VirtualBox before calling VBoxManage command, then adding it back in, was successful. But now I can’t boot the virtual machine, I get this worrying screen:

![enter image description here](https://i.stack.imgur.com/nifd1.png)

By the way, it says `FATAL: Could not read from the boot medium! System halted.`

* * *

The vdi must be reattached to the VM after VBoxManage command. Further, the partition will need to be resized from WITHIN windows, because you will have this empty space:

![enter image description here](https://i.stack.imgur.com/5eQ1P.png)

I was able to resize the partition easily using a bit of freeware called [EASEUS Partition Master 9.1.0 Home Edition](http://download.cnet.com/EaseUS-Partition-Master-Home-Edition/3000-2248_4-10863346.html).

#### Best Answer

Open a terminal and navigate to the folder with the VirtualBox disk image, then use the following command:

```
VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB

```

replacing `YOUR_HARD_DISK` and `SIZE_IN_MB` with your image name and desired size. `sudo` might be necessary in some machines or you might encounter an error. This answer and a fuller explanation are [here, on webupd8](http://www.webupd8.org/2011/02/how-to-easily-resize-virtualbox-40-hard.html). Credit to Andrew there for posting this answer.

After resizing, the extra [virtual hard drive space needs to be partitioned and formatted](https://askubuntu.com/a/558215/3940) for the guest to use it. This can be done with gparted by booting the guest from a live ISO. We can also resize the existing partition using gparted. For this we may need to disable `/swap` and create a new swap partition.

In case if VBoxManage is not found in your system, just set the path to:

```
set PATH=%PATH%;"C:Program FilesOracleVirtualBox" 

```

and it should resolve path issue. Do make sure “VBoxManage” is present at this path before setting it.

The post [Ubuntu – How to increase the hard disk size of the virtual machine in ubuntu?](https://stackallflow.com/ubuntu/ubuntu-how-to-increase-the-hard-disk-size-of-the-virtual-machine-in-ubuntu/) appeared first on [Stack All Flow](https://stackallflow.com).