VHD cannot resize

Discussions about using Linux guests in VirtualBox.
Post Reply
dclxvi
Posts: 3
Joined: 2. Aug 2021, 10:06

VHD cannot resize

Post by dclxvi »

Hi,

My guest VHD (Ubuntu 20.14) became nearly full (150GB), so I shutdown and in Windows using the Virtual Media Manager I resized to 200GB using the slider.

While doing this an error occurred, which I cannot recall, so I tried again. However now the VHD has been made to 300GB, and allocated more space than I even had free on the Windows HDD. Bit the bullet, and ended up having to delete a lot of data to free up some space for Windows to work correctly and keep the VHD at 300GB.

Now, if I go into the VM and open GParted it still only shows 150GB, with no space to enlarge into. The VDH does not grow into the extra space and a lot of operations fail with "Error: Error: Disk space is low!" messages.

I cannot clone and size as I originally intended, as I only have 65GB "free" on the HDD. I definitely cannot delete and start again - the data takes 1 week to redownload and I don't have the bandwidth.

I'm a bit stumped, and hoping someone could help me.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VHD cannot resize

Post by mpack »

I suggest you read: How to resize a Virtual Drive.

It sounds like you need to pay particular attention to the discussion of snapshots.

I don't know what attracted you to VHD. That format is notoriously error prone.
dclxvi
Posts: 3
Joined: 2. Aug 2021, 10:06

Re: VHD cannot resize

Post by dclxvi »

I don't use SnapShots - I never mentioned snapshots.

I've read that link before, and I gathered my option was to clone, but as I mentioned the error the VirtualMediaManager made has now consumed most of my drive space.

What I would prefer is to remove the extra 150GB that was somehow allocated to the drive in the first place.

"I don't know what attracted you to VHD. That format is notoriously error prone."

I'm just learning here, dude. Thanks for explaining the reasons it's not ideal, and what are the common issues. Condescending to say the least.

If Fixed drives aren't supported why does the Virtual Media Manager allow you to move the slider to resize them?

So I was hoping someone could be helpful, and knew of another method.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VHD cannot resize

Post by mpack »

dclxvi wrote:Condescending to say the least.
I see nothing of that nature in my previous reply, but if you do then I guess my best bet is to leave you to it, since I certainly wouldn't want to risk offending you further.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VHD cannot resize

Post by scottgus1 »

dclxvi wrote:If Fixed drives aren't supported why does the Virtual Media Manager allow you to move the slider to resize them?
Could be a bug.
dclxvi wrote: I never mentioned snapshots.
There's a lot of folks that don't mention the full story and it only comes out three forum pages, several days, and dozens of volunteer-posted suggestions later. :lol:
dclxvi wrote:What I would prefer is to remove the extra 150GB that was somehow allocated to the drive in the first place.
dclxvi wrote:if I go into the VM and open GParted it still only shows 150GB, with no space to enlarge into.
This could be because the VHD is fixed size.

The real problem with VHD is a design flaw that causes loss of the data if the host glitches while the VHD is being expanded to allow more data to be written. Dynamic VHD can die a horrible death. Fixed VHD is actually safer, because it never gets bigger so the design flaw cannot trigger.

I suspect that the VHD file itself may still be 150GB-ish in size, though Virtualbox reports it as 300GB? Or is the actual VHD file on the host now 300GB in size?

The only way that I see to get your VHD bigger and fix the size error is to mount both the existing VHD and a new drive file (Dynamic VDI would be recommended as fully supported by all Virtualbox tools, but a new fixed VHD would be OK, too) to a new Ubuntu VM. Then boot the Ubuntu VM with an Ubuntu LiveCD ISO, and clone the contents of the VHD to the new disk using whatever tool Ubuntu can provide (dd?). Then attach the new drive file to your old VM in place of the old VHD. You might have to edit the grub loader to reflect the UUID of the new disk file.

If you don't have disk space for this, you'll have to get some. I don't know of another way to fix this.
dclxvi
Posts: 3
Joined: 2. Aug 2021, 10:06

Re: VHD cannot resize

Post by dclxvi »

Firstly, thank you for the info. Very grateful.
scottgus1 wrote:
dclxvi wrote:If Fixed drives aren't supported why does the Virtual Media Manager allow you to move the slider to resize them?
Could be a bug.
I think so. I just tried another smaller resize (2GB), just to see what the error was again - in case it could be helpful. It seems the VirtualMediaManager ignores the size you chose & starts allocating _all_ available free space on the drive to the VHD, and only throws an error when the Host drive runs out of space. So once again my space that I struggled to free up is allocated to the VHD (65GB), and now it sits at 365GB.

Where can I report this?
scottgus1 wrote: There's a lot of folks that don't mention the full story and it only comes out three forum pages, several days, and dozens of volunteer-posted suggestions later. :lol:
I can understand the frustration with that :) No snapshots. Just busy learning the Linux environment etc.
scottgus1 wrote: The real problem with VHD...
Ah, I understand. Thank you. I started with a VDI on my first VM, but I quickly needed to re-expand etc, so I chose the Fixed Size on the second VM as it says it is faster, and since I had code that was pulling a lot of data and writing it to the drive... I wish I had stayed with VDI :lol:
scottgus1 wrote: I suspect that the VHD file itself may still be 150GB-ish in size, though Virtualbox reports it as 300GB? Or is the actual VHD file on the host now 300GB in size?
It is actually a 365GB file on the Host HDD now. If I navigate to the VM location (C:\Users\dclxvi\VirtualBox VMs\Daemons) on the Host HDD, Daemons.vhd is 365GB.
scottgus1 wrote: The only way...
If you don't have disk space for this, you'll have to get some. I don't know of another way to fix this.
Thank you for the full explanation. It's as I feared :(

Gonna have to bite the bullet and buy another SSD. Corona has not been friendly to the pocket as many of us know.
mcyenikoylu
Posts: 5
Joined: 7. Oct 2021, 12:16
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows 10 PRO
Location: Turkey
Contact:

Re: VHD cannot resize

Post by mcyenikoylu »

Hi dclxvi,

I am having the same problem. I wanted to increase the file size with Virtual Media Manager but it grew until my disk was full and Actual Size grew.

I can't reduce the capacity back. I'm out of space on my current disk. I deleted my files to free up space and ran it again and it filled up again until my disk was full. I tried on the last portable disk and had to close the process halfway. Now the OS on my VHD disk won't boot either.

Also, I wanted to add my VHD file to the Windows 10 system on another computer, but I got an error.

I don't know what to do please help. How did you solve this problem?

Thanks.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VHD cannot resize

Post by scottgus1 »

mcyenikoylu, If you do have exactly the same problem as dclxvi, with a fixed-size VHD format disk file, then the solution is dclxvi's:
dclxvi wrote:Gonna have to bite the bullet and buy another SSD
You'll have to get enough disk space to store the drive file. Fixed disk formats use up all of the expected space immediately on creation.

Or restore the backed-up VHD file you have stored in your host's backups.

You could try cloning the VHD to a different disk using Mpack's CloneVDI. It will make a dynamic VDI out of the fixed VHD, in a smaller file size, but might allow the disk's OS to boot.
Post Reply