Wrong larger virtual HD Size

Discussions related to using VirtualBox on Linux hosts.
Locked
wolverine79936
Posts: 3
Joined: 19. Sep 2019, 23:34

Wrong larger virtual HD Size

Post by wolverine79936 »

Quick question: I already set everything up and made a mistake on hd size... I set it for 500GB and don't have that much space. Is there some way to reset the limit on the HD size or will it just tell me it's out of hard drive when the host OS is out of hard drive?
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Wrong larger virtual HD Size

Post by socratis »

If you haven't done too much with the VM, delete what you've done, start from scratch, be careful.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
wolverine79936
Posts: 3
Joined: 19. Sep 2019, 23:34

Re: Wrong larger virtual HD Size

Post by wolverine79936 »

We are in the 21st century, right? I should think there would be a way to resize the virtual hard drive like we can with a Windows Partition these days. This sounds more like 1980s talk. Start over from scratch. :( No offense, socratis, this just a major pain in the neck.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Wrong larger virtual HD Size

Post by socratis »

Oh really? You really want to see major pain? I offered you the simplest solution, the hassle-free one. 21st century doesn't change the laws of mathematics/computers, neither can easily reverse PEBKACs... :roll:

Let me "sort of" draw the process. Warning: Oversimplification.

In the following:
  • the letters are occupied sectors,
  • the spaces " " are empty/unallocated sectors,
  • the dashes "-" are sectors that were allocated at some point or another but not anymore,
  • the stars "*" are sectors that have been marked as "zeroed out" after running 'zerofree' on a Linux guest, or 'sdelete c: -z' on a Windows guest,
  • and finally, the "||" is where you divide your disk with GParted to have a smaller accessible partition.
Original VDI state contains data (randomly located), free, and previously used sectors:
+-----------------------------------------------------------------+
| l d --- od--- skkjs    gsosgg   ds    dl  k  sl   ks f  po ss-- |
| j s     k l---j--sd  v   k sd j  s dl kj s d  sd g jk ls d  js  |
| d  l---s j  o  ;   s d j lk-s---j-sl---a-s al sd  sd hk l as  5 |
| has   d h ig----w  2 4       pu t g  df b j; af s j--as-l-as--b |
+-----------------------------------------------------------------+
Run 'zerofree'/'sdelete c: -z' in your Guest, and all the previously used sectors are marked as zero sectors:
+-----------------------------------------------------------------+
| l d *** od*** skkjs    gsosgg   ds    dl  k  sl   ks f  po ss** |
| j s     k l***j**sd  v   k sd j  s dl kj s d  sd g jk ls d  js  |
| d  l***s j  o  ;   s d j lk*s***j*sl***a*s al sd  sd hk l as  5 |
| has   d h ig****w  2 4       pu t g  df b j; af s j**as*l*as**b |
+-----------------------------------------------------------------+
Run 'VBoxManage modifymedium "<VDI>" --compact' from your Host, and all the zero sectors are emptied:
+-----------------------------------------------------------------+
| l d     od    skkjs    gsosgg   ds    dl  k  sl   ks f  po ss   |
| j s     k l   j  sd  v   k sd j  s dl kj s d  sd g jk ls d  js  |
| d  l   s j  o  ;   s d j lk s   j sl   a s al sd  sd hk l as  5 |
| has   d h ig    w  2 4       pu t g  df b j; af s j  as l as  b |
+-----------------------------------------------------------------+
Boot the VM using a Gparted ISO. Shrinking the partition with Gparted and all the data are moved to the front, they are restricted onto their own, smaller partition, and you don't allow anything to access the "No Access" partition:
+---------------------------------------++------------------------+
| ldodskkjsgsosggdsdlkslksfposs         ||                        |
| jskljsdvksdjsdlkjsdsdgjklsdjs         ||   N O    A C C E S S   |
| dlsjo;sdjlksjslasalsdsdhklas5         ||                        |
| hasdhigw24putgdfbj;afsjaslasb         ||                        |
+---------------------------------------++------------------------+
Good luck!

PS. You didn't mention Host, Guest, so I gave you both options. Please read Minimum information needed for assistance next time you post a problem.

PPS. You can simply forget the whole procedure for which GParted cannot shrink a partition, e.g. HFS+, LVM containers, or other exotic ones...

PPPS. And no snapshots, right? That's a given.

PPPPS. The HD in your VM is still going to show as 500 GB. You won't simply be able to use that, only the shrunk partition.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
wolverine79936
Posts: 3
Joined: 19. Sep 2019, 23:34

Re: Wrong larger virtual HD Size

Post by wolverine79936 »

Forgive me, @socratis. It's been a long day and I'm spoiled by windows and their oversimplified method of doing everything. You don't even need the command prompt any more for like 75% of what the average person does. All i have is Win 10 and Office on there right now. I just didn't want to waste 45 minutes installing all that again because of a stupid brain fart. But thanks for both sides of the coin. This is the first linux system I have worked with in about 15 years where I didn't have it break already. Four days is a personal record at the moment. Normally after a few hours, it stops working or I find something that only windows can do. Linux Mint Cinnamon is actually worth the time to download as a host operating system. I just wish that MS would make Office for Linux now. Thanks again and my apologies for displaying my frustration for you earlier.
Plagrö
Posts: 140
Joined: 27. May 2018, 14:57

Re: Wrong larger virtual HD Size

Post by Plagrö »

I have a "windows XP" guest in a Linux host.

I have done the steps ...
-Run 'zerofree'/'sdelete c: -z' in your Guest
and
-Run 'VBoxManage modifymedium "<VDI>" --compact' from your Host

But my VDI has still the same size! ?

I do not understand the following (in step 3):
-Boot the VM using a Gparted ISO.

Can you give me a little bit more details?
What is a Gparted ISO?
Do I have to make an iso from my VDI with Gparted?
How can I boot my VM using Gparted? I usually boot my VM using VirtualBox.

Thank you.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Wrong larger virtual HD Size

Post by scottgus1 »

Plagro, Socratis gave Wolverine the worst-case fix, because Wolverine balked at the easiest solution Socratis presented before.

Please start a new topic with a description of your original problem.
Locked