[Resolved] After converting hdd to vhd, internal size is too large

Discussions related to using VirtualBox on Windows hosts.
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

[Resolved] After converting hdd to vhd, internal size is too large

Post by hangerglide »

I'm not even sure if this is a virtualbox question, but it might be so I'll ask. I cloned a 1 tb ssd containing C and D partitions using disk2vhd, and it was rendered as a 400 gb vhd. I then used that as the basis for a new virtualbox vm.

The 500 gb ssd that hosts the vm is almost out of space now, for some reason it keeps growing. There are only about 330 gb of files between C and D, and I've been tossing some, but it still keep growing. I find that internally, the windows 7 pro guest thinks it still has a 1 tb drive to use for C and D, which makes sense. This might be part of the problem, why it keeps growing, thinking that it has all kinds of elbow room?

So that's one question, might that be contributing to the expansion?

And regardless, it has to make sense to let the windows 7 guest know that in fact it doesn't have 1 tb to play with, and adjust to a value that more closely resembles the 500 gb ssd that it's mounted on. Maybe there is no way to adjust that - maybe I should have reduced the partitions to fit better in a 500 ssd before I created the vhd. It does sound like this isn't so much of a vbox question but I'll ask here in case I get lucky.
Last edited by socratis on 11. Nov 2019, 21:31, edited 1 time in total.
Reason: Marked as [Resolved].
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: After converting hdd to vhd, internal size is too large

Post by socratis »

I would like to see the output of the following command from within the Guest:
  • 
    wmic logicaldisk get size,freespace,caption
And then from your Host, the output of the commands:
  • 
    VBoxManage showvminfo "<YourVMname">
    VBoxManage showmediuminfo "<FullPathToYourVHD>"
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.
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

Re: After converting hdd to vhd, internal size is too large

Post by hangerglide »

Thank you

Code: Select all

C:\Users\AT>wmic logicaldisk get size,freespace,caption
Caption  FreeSpace     Size
C:       339103674368  529963937792
D:       251930816512  430123773952
E:       0             77195264
I:

Code: Select all

E:\virtualbox>VBoxManage showvminfo "bloke7"
Name:                        bloke7
Groups:                      /
Guest OS:                    Windows 7 (64-bit)
UUID:                        63da554d-9469-408c-90ec-21f6a8ab008a
Config file:                 E:\virtualbox\msmachines\bloke7\bloke7.vbox
Snapshot folder:             E:\virtualbox\msmachines\bloke7\Snapshots
Log folder:                  E:\virtualbox\machines\bloke7\Logs
Hardware UUID:               63da554d-9469-408c-90ec-21f6a8ab008a
Memory size                  12288MB
Page Fusion:                 disabled
VRAM size:                   30MB
CPU exec cap:                100%
HPET:                        disabled
CPUProfile:                  host
Chipset:                     piix3
Firmware:                    BIOS
Number of CPUs:              2
PAE:                         disabled
Long Mode:                   enabled
Triple Fault Reset:          disabled
APIC:                        enabled
X2APIC:                      disabled
Nested VT-x/AMD-V:           disabled
CPUID Portability Level:     0
CPUID overrides:             None
Boot menu mode:              message and menu
Boot Device 1:               Floppy
Boot Device 2:               DVD
Boot Device 3:               HardDisk
Boot Device 4:               Not Assigned
ACPI:                        enabled
IOAPIC:                      enabled
BIOS APIC mode:              APIC
Time offset:                 0ms
RTC:                         local time
Hardw. virt.ext:             enabled
Nested Paging:               enabled
Large Pages:                 enabled
VT-x VPID:                   enabled
VT-x unr. exec.:             enabled
Paravirt. Provider:          Default
Effective Paravirt. Prov.:   HyperV
State:                       running (since 2019-11-08T16:02:50.461000000)
Monitor count:               1
3D Acceleration:             disabled
2D Video Acceleration:       disabled
Teleporter Enabled:          disabled
Teleporter Port:             0
Teleporter Address:
Teleporter Password:
Tracing Enabled:             disabled
Allow Tracing to Access VM:  disabled
Tracing Configuration:
Autostart Enabled:           disabled
Autostart Delay:             0
Default Frontend:
Storage Controller Name (0):            SATA
Storage Controller Type (0):            IntelAhci
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  30
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
SATA (0, 0): F:\BLOKE_cd_20191025.VHD (UUID: 5d490d6d-342a-4dbc-9f2c-0b456e1a06ac)
SATA (1, 0): C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso (UUID: 1f366df5-762a-458f-a7ef-b09d17c7e8aa)
NIC 1:                       MAC: 0800272DDE1C, Attachment: Bridged Interface 'Intel(R) Ethernet Connection (2) I219-V', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 2:                       disabled
NIC 3:                       disabled
NIC 4:                       disabled
NIC 5:                       disabled
NIC 6:                       disabled
NIC 7:                       disabled
NIC 8:                       disabled
Pointing Device:             USB Tablet
Keyboard Device:             PS/2 Keyboard
UART 1:                      disabled
UART 2:                      disabled
UART 3:                      disabled
UART 4:                      disabled
LPT 1:                       disabled
LPT 2:                       disabled
Audio:                       enabled (Driver: DSOUND, Controller: HDA, Codec: STAC9221)
Audio playback:              enabled
Audio capture:               disabled
Clipboard Mode:              Bidirectional
Drag and drop Mode:          Bidirectional
Session name:                GUI/Qt
Video mode:                  1727x1025x32 at 0,0 enabled
VRDE:                        disabled
OHCI USB:                    enabled
EHCI USB:                    enabled
xHCI USB:                    disabled

USB Device Filters:
<none>
Available remote USB devices:
<none>
Currently Attached USB Devices:
<none>
Bandwidth groups:  <none>
Shared folders:<none>
VRDE Connection:             not active
Clients so far:              0
Capturing:                   active
Capture audio:               not active
Capture screens:             0
Capture file:                E:\virtualbox\msmachines\bloke7\bloke7.webm
Capture dimensions:          1024x768
Capture rate:                512kbps
Capture FPS:                 25kbps
Capture options:             vc_enabled=true,ac_enabled=false,ac_profile=med

Description:

Guest:

Configured memory balloon size: 0MB
OS type:                     Windows7_64
Additions run level:         3
Additions version            6.0.14 r133895

Guest Facilities:

Facility "VirtualBox Base Driver": active/running (last update: 2019/11/08 16:02:57 UTC)
Facility "VirtualBox System Service": active/running (last update: 2019/11/08 16:03:16 UTC)
Facility "VirtualBox Desktop Integration": active/running (last update: 2019/11/08 16:42:15 UTC)
Facility "Seamless Mode": active/running (last update: 2019/11/08 16:02:57 UTC)
Facility "Graphics Mode": active/running (last update: 2019/11/08 16:02:57 UTC)
and then

Code: Select all

E:\virtualbox>VBoxManage showmediuminfo "f:\BLOKE_cd_20191025.VHD"
UUID:           5d490d6d-342a-4dbc-9f2c-0b456e1a06ac
Parent UUID:    base
State:          locked write
Type:           normal (base)
Location:       F:\BLOKE_cd_20191025.VHD
Storage format: VHD
Format variant: dynamic default
Capacity:       953869 MBytes
Size on disk:   475729 MBytes
Encryption:     disabled
In use by VMs:  bloke7 (UUID: 63da554d-9469-408c-90ec-21f6a8ab008a)
Last edited by socratis on 9. Nov 2019, 01:46, edited 1 time in total.
Reason: Enclosed the information in [code] tag for better readability
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: After converting hdd to vhd, internal size is too large

Post by scottgus1 »

hangerglide wrote:it still keep growing
Every time the guest OS writes to a sector of its expected disk space that isn't there in the virtual drive, Virtualbox makes another sector in the virtual drive to handle what the guest OS wants to write, even if the guest OS later decides to forget about what it wrote.

The guest OS thinks it has a terabyte of space available. Something inside the guest OS is writing to more and more sectors. This may be disk optimizing software, defragrementing, etc. If you rearrange the partitions so the guest OS thinks it has less space, the virtual drive will only fill up to the new smaller partition size. Example:

A virtual drive 1TB in size with a partition 400GB in size will only expand to 400GB max.

Since you have a Windows guest, you can use Disk Management to shrink the virtual drive's partitions so they total less than the 500GB host SSD. Then the guest OS will not run out of space. Google for how to adjust partitions with Disk Management.

'Gparted' is also a way to shrink and move partitions, especially if Windows fails to shrink and/or move the data so the drive is limited to a smaller size. Google for how to use Gparted if needed.

Note that you may need to make these adjustments on a platter drive 1TB or greater, then compact the virtual drive to get it down to the small size to fit on the SSD. See Mpack's CloneVDI for an easy virtual disk compactor.
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

Re: After converting hdd to vhd, internal size is too large

Post by hangerglide »

Thanks that's very interesting. If I am able to take the simple route, and simply shrink partitions, I would not need to remedy the guest OS's notion that it has a 1 tb hdd at all, correct? It'd remain as a 1 tb disk, with two undersized partitions on it?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: After converting hdd to vhd, internal size is too large

Post by scottgus1 »

Correct. The guest will wake up to find it has a smaller disk than it had when it shut down.

The compacting process will help if you shrink the usable partition size to smaller than the size of the virtual drive file on the SSD.
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

Re: After converting hdd to vhd, internal size is too large

Post by hangerglide »

I'm in the middle of restoring the vhd file to a 1 tb drive so that it can defrag and allow partitions to be made smaller.

One thing that is not critical but still might be worth trying for is to adjust so that the windows guest os thinks that it has a 500 gb disk, and not the 1 tb disk that carried over from the physical machine. If it was a physical machine, I'd shrink the partitions, back them up, and restore C and D to a new, smaller drive that it would boot from. I have not been able to figure out how to emulate that operation from the viewpoint of the guest os, which is where I think the 'action' has to take place.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: After converting hdd to vhd, internal size is too large

Post by scottgus1 »

Sorry, hangerglide, I may have been unclear earlier.
scottgus1 wrote:Since you have a Windows guest, you can use Disk Management in the guest while the guest is running to shrink the virtual drive's partitions
Gparted also runs in the guest. Just boot the guest with the Gparted ISO.
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

Re: After converting hdd to vhd, internal size is too large

Post by hangerglide »

Hi Scott I understood that aspect. What I am thinking of is the disk that the guest OS sees. Because it was created from a 1 tb physical disk via disk2vhd, vhd still appears as a 1 tb disk to the guest OS. Even if I shrink the partitions down to say 450 gb, according to the guest OS those two partitions (C and D) will reside on a 1 tb hdd. In reality this VM will be on a 500 gb ssd. I don't expect any issue if I leave the disk as a 1 tb disk, because the partition sizes are what matter, but this last question is the possibility of having the guest OS see the disk (which amounts to the vhd), as more like what the physical ssd is, around 500 gb. I'm not sure how to go about that with a vm.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: After converting hdd to vhd, internal size is too large

Post by scottgus1 »

The guest will see a 1TB disk, but it will only be able to write to a part of it, the partitions you pick. Pick them smaller than the 500GB SSD and you'll be good. (compacting after partition changes may be necessary.)
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

Re: After converting hdd to vhd, internal size is too large

Post by hangerglide »

Right, but can you see any way to change it so that the guest OS sees a 500gb disk? It won't matter operationally, unless I later forget and expand the partitions over 500 gb (and that won't happen this is kind of an archive of a workstation). But is there a way to do it? It would be possible with a physical machine but here, not sure how it could be done.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: After converting hdd to vhd, internal size is too large

Post by scottgus1 »

If you have 2 virtual drive files in the guest, one set to 450GB and the 1TB you have now, and use imaging software, like Macrium Reflect in the guest, to clone the 1TB to the 450GB, while adjusting the partitions, you'd then have the data on the 450GB drive.
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

Re: After converting hdd to vhd, internal size is too large

Post by hangerglide »

I had not realized that one could run a regular backup program like macrium in a guest os. If that's possible then I know what to do. I didn't have any specific reason to think a backup program wouldn't work 'normally' but had guessed that there might be issues.

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

Re: After converting hdd to vhd, internal size is too large

Post by scottgus1 »

hangerglide wrote:one could run a regular backup program like macrium in a guest os.
Easy as pie. Store-bought, that is. :lol:

If the hypervisor (Virtualbox in this instance) does its job well, the guest OS and programs running on it will think they are running on a real computer and perform equivalently. Macrium will run just fine in a guest.

Hope you have success!
hangerglide
Posts: 183
Joined: 29. Mar 2009, 00:53
Primary OS: MS Windows 7
VBox Version: OSE Debian
Guest OSses: ubuntu 8.10

Re: After converting hdd to vhd, internal size is too large

Post by hangerglide »

Here is what I did. On the guest I installed veeam agent for windows, a backup program that I am familiar with, and backed up system, C, and D to a spare partition on the existing vhd. I added a new virtual disk to the guest vm and gave it a size of 500 gb. I then restored system, C, and D to the new 500 gb drive inside the guest. All seemed to go well, but when I disconnected the original vhd so that the newly restored to vhd would be the sole drive, it does not boot from that drive. The error is "the boot selection failed because a required device is inaccessible'. The error message suggests booting to the windows install disk and selecting system repair, but after attaching the windows 7 iso, and pressing any key to get it to boot to that, it asks to select and OS to boot to, I choose windows 7, and get the previous error.

Again this may be outside of the virtualbox zone, and I have posted on the veeam forums, but just in case someone here knows the workaround for this, I post this note. If I discover the solution I'll post it here as well, someone else may find it useful.
Post Reply