Resizing a .vdi

Discussions related to using VirtualBox on Linux hosts.
Post Reply
obelix6410
Posts: 7
Joined: 1. Nov 2018, 22:09

Resizing a .vdi

Post by obelix6410 »

Hello,
On Manjaro, I have a Windows 7.vdi that initially was 500 GB.
Since then, I took a snapshot that reduced the size of the virtual disk to 131 GB.
How do I find my original 500 GB?
The command:

Code: Select all

VBoxManage modifymedium ~/VirtualBox_VMs/Windows7/Windows\ 7.vdi' --resize 476837Mio
gives me
Syntax error: --resize: RTGetOpt: Command line option has argument with bad format.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Resizing a .vdi

Post by mpack »

obelix6410 wrote: Since then, I took a snapshot that reduced the size of the virtual disk to 131 GB.
That is not how snapshots work - they don't replace anything and disk space used will certainly never go down.

When you create a snapshot the current disk contents are locked and a new VDI file is created in the snapshots subfolder. This new VDI is an offshoot of the original VDI, it is not a replacement. The new VDI will contain only the sectors that have changed since the snapshot, so if it's 131GB then that means you wrote 131GB worth of sectors since the snapshot.

If you use snapshots then all snapshots states are considered active, all files must remain online indefinitely. If you want to go back to a single file then use the VM settings snapshots panel to delete (not revert to) the snapshot.

Be thankful that you got your command line syntax wrong, since your attempt to reduce the base VDI size would have killed the VM. But not to worry, you obviously must have made a backup before testing such dangerous commands.
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: Resizing a .vdi

Post by socratis »

obelix6410 wrote:Windows 7.vdi that initially was 500 GB. Since then, I took a snapshot that reduced the size of the virtual disk to 131 GB.
I don't think that you've completely understood how the Snapshots feature works... Start by reading the Snapshot basics post. As mpack said Snapshots record the "differences in the disk sector". If you create a dynamic VDI with a maximum size at the time of the creation of let's say 500 GB, it can never go down, you can't decrease its size, only increase it. So, you cannot possible have reduced the VDI size, what you're seeing is the amount of modified sectors, 131 GB modified sectors.

I would suggest to merge your snapshots so that you have a single "Current State" one. Then, you don't even have to use the command line if you're having trouble with it (apparently). Go to the menu "File" » "Virtual Media Manager..." » select the "Hard Disks" tab » find your VDI » make sure the "Properties" button on top is enabled » select the "Attributes" tab on the bottom is selected » change the VDI's size, either by the slider or by entering the value directly on the size control to the right.

Be careful!!!
You can only enlarge the VDI, not shrink it!

Press the "Apply" button...
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.
obelix6410
Posts: 7
Joined: 1. Nov 2018, 22:09

Re: Resizing a .vdi

Post by obelix6410 »

I really don't understand it.
I cloned the 500 GB disk without the snapshot.
The clone of the virtual disk tells me in the information 500 GB and actual size 150 GB.
When I look at the properties of the C disk in Windows 7, I still have a capacity of 150 GB and I no longer have a snapshot.
So what exactly do I have to do now as a shell command to solve the increase in capacity of this Windows 7 C disk?
I forgot to mention that I completely deleted the first.vdi disk completely with the snapshot.

I've understood my mistakes :

"People often confuse that a "Snapshot" is and what the "HD state" is. They think that when they're taking a snapshot they take a differential backup of the files and if they delete a snapshot manually they can recover from it. No. Snapshots are NOT backups!"
Post Reply