Resizing virtual disk image(VDI) with fixed size storage

Discussions related to using VirtualBox on Windows hosts.
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Resizing virtual disk image(VDI) with fixed size storage

Post by a cooperator »

Hi,

I have installed the latest version (v 4.3.6 r91406) of virtual, and I installed a windows 7 from a disc image file [iso] saved on an external hard disk. As screen shot below shows.

Image

Also, virtula disk image(VDI) is shown in the settings of VM

Image

I have applied the command to rezise virtual disk, but a little error is still showing me.
Image

I have read this section:

Re: How to resize a Virtual Drive

Postby mpack » 25. Aug 2013, 11:47

What if I used Fixed Disks or Snapshots, or VMDK?

As the advice above states, resizing of fixed VDIs or VHDs is not directly supported, nor is resizing of formats other than VHD/VDI, nor can you resize disks which are part of a snapshot chain.

However, all of these problems are easily addressed if you clone the disk to a supported format first, using :-
Code: Select all Expand view
VBoxManage clonehd <infilename or UUID> <outfilename> --format VDI --variant Standard



You can then resize the resulting dynamic VDI using "VBoxManage modifyhd" as described in the previous message.

If a snapshot chain is involved then <infilename> should be the name of the latest snapshot VDI in the "Snapshots" subfolder. Do not make the rookie mistake of cloning the base VDI. In this case "clonehd" will create a merged clone and it's important that you not incorporate this back into a VM which is still expecting a chain of difference disk images. Either build a new VM around the clone, or delete all the snapshot markers from the original VM, then replace the disk file. If the VM did not use difference images (no immutable drive, linked clone or snapshot) then you can use the Storage settings panel to remove the old disk and replace with the new one.

----------------
Could anyone please be more detailed about what I can write in-place of of each of these below?
in 'infilename' and
outfilename
--format vdi
--variant Standard
Last edited by a cooperator on 26. Feb 2014, 02:25, edited 2 times in total.
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 virtual disk image(VDI) with fixed size storag

Post by mpack »

The input filename (i.e. "infilename") is shown in your screenshot. Surely you can work it out from there? When I show something in angle brackets it acts as a placeholder for the specifics of your own case.
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by a cooperator »

mpack wrote:The input filename (i.e. "infilename") is shown in your screenshot. Surely you can work it out from there? When I show something in angle brackets it acts as a placeholder for the specifics of your own case.
Thanks a lot,
I am sorry to say that I am still a little bit confused about this command.
Then you mean that command would be written as follows:

VBoxManage clonehd D:\Users\Mohammad\.VirtualBox\HardDisks\windows.vdi D:\Users\Mohammad\.VirtualBox\HardDisks\windows1 --format VDI --variant Standard
Image

Thus, I got this output filename which is named with 'windows1'. However, 'Windows.vdi' is input file name

Image


Now, I have two virtual hard disks, a cloned hard disk created now(windows1) and the first old one (windows.vdi). Then I can now load VM with either virtual hard disk(Windows1 or Windows.vdi)?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by Perryg »

You should have named it Windows1.vdi when you created it. Not sure if you can rename it now or not but I doubt that you can. Worth a try, but if not use the same command with the .vdi
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by a cooperator »

Perryg wrote:You should have named it Windows1.vdi when you created it. Not sure if you can rename it now or not but I doubt that you can. Worth a try, but if not use the same command with the .vdi
Thank you so much indeed,

Yes, but now whenever check the settings of VM, I found there is Virtual guest additions.iso, which wasn't there before running the 'clone' command.

Image

Note, I can still only boot VM from old windows.vdi, which is still fixed size storage, then what benefit is there from new one?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by Perryg »

First you have created another CD Drive in the IDE controller. Not a good idea. I would remove one of them.
Next if you click on the Windows.vdi and then go to the right (attributes) of that you can select what drive you want attached. I would assume that you want the Windows1.vdi.
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by a cooperator »

Perryg wrote:First you have created another CD Drive in the IDE controller. Not a good idea. I would remove one of them.
Next if you click on the Windows.vdi and then go to the right (attributes) of that you can select what drive you want attached. I would assume that you want the Windows1.vdi.
I really haven't created that CD drive called 'VBoxGuestAdditions' at all, this is why I am asking you what created it(i.e, what set it up in the settings).
NOTE: in that screen shot in previous post that CD drive located directly over the VBoxGuestAdditions contains the iso file which VM needs present to be loading if I remove it, VM will not be loading.

You will aslo notice in this screen shot of the guest OS the 'VBoxGuestAddtions' I never created nor set up.
Image

You should have named it Windows1.vdi when you created it. Not sure if you can rename it now or not but I doubt that you can. Worth a try, but if not use the same command with the .vdi
You said that I should have named output file with 'Windows1.vdi'. Then, I would get two VDIs. Then what difference is there between them? Is it only:
Virtual disk image with fixed size storage
Virtula disk image with dynamic size storage

I think that no need to name output file with Windows1.vdi, or otherwise:
1- that command will not contain the option 'variant Standard'
2- I couldn't be able to load VM from the windows1 created with only windows1 without any extensions.( I think VM can boot from any virtual disk drive)
Image
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by a cooperator »

Perryg wrote:You should have named it Windows1.vdi when you created it. Not sure if you can rename it now or not but I doubt that you can. Worth a try, but if not use the same command with the .vdi

Could you please continue replying to me to finish this problem pending?
I really reuse the same command with the .vid

C:\program files\oracle\virtualbox\ VBoxManage clonehd D:\Users\Mohammad\.VirtualBox\HardDisks\windows.vdi D:\Users\Mohammad\.VirtualBox\HardDisks\windows1.vdi --format VDI --variant Standard

Thus, I got virtula disk image with dynamic storage.
Image

However, when I want to resize it, I found the same error that 'vdi' is not supported yet.

Image



I have even tried cloning the existing VDI with with format VHD, then resizing it, but it still not suppored to be resized.

Image

Also, with 'vhdx', and the same error.
Image


Thus, I figured out now that the problem is not whether VDI is fixed or dyanmic size storage. However, it is resizing of formats ( vdi, vhd, vhdx) which are not supported to be resized.

Then what type of formats are supportd to be resized?

-----------------------------------------------------------------------
I can now conclude that

1- there is some wrong in this:

As the advice above states, resizing of fixed VDIs or VHDs is not directly supported, nor is resizing of formats other than VHD/VDI, nor can you resize disks which are part of a snapshot chain.

However, all of these problems are easily addressed if you clone the disk to a supported format first, using :-

2- the cloned hard disk to be created will have extension according to what is written in 'outfilename' and not for 'format vdi'.(whatever 'format vid' is, it doesn't matter)
For instance, if I wrote 'VBoxManage clonehd <D:\Users\Mohammad\.VirtualBox\HardDisks\windows.vdi D:\Users\Mohammad\.VirtualBox\HardDisks\windows1.vdi --format VDI --variant Standard, then the cloned disk will be VDI.

if I wrote 'VBoxManage clonehd <D:\Users\Mohammad\.VirtualBox\HardDisks\windows.vdi D:\Users\Mohammad\.VirtualBox\HardDisks\windows1.VHD --format VDI --variant Standard, then the cloned disk will be VHD.
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 virtual disk image(VDI) with fixed size storag

Post by mpack »

There is no problem renaming "windows1" to "windows1.vdi", except that you can't do it while it's registered in VBox - you should unregister the VDI, rename it, then add it back.

Perry didn't say that you added a CD drive called "VBoxGuestAdditions". What he pointed out was that you added a 2nd CD drive to the VM as you can clearly see in your own screenshot. You then caused the "VBoxGuestAdditions.iso" virtual cd image to be mounted in that drive. This means that you are not mounting CDs properly - you're adding a new drive every time you mount a CD. In any case this has nothing to do with the resizing question, please start a new topic if you want to discuss that.

Resizing is supported for dynamic VDI and VHD. If you give it an unsupported format it will tell you, as you've already seen. If the command includes the modifier "--format VDI" then the resulting format will be VDI. The extension you put on the end of the filename does not determine (or even truly indicate) file format. Putting the wrong extension on a file could however be confusing for you in the future.

Finally, I see that your VM is still using the obsolete v3.x folder structure, or some nasty hybrid. You should look to correct this soon. Cloning the VM (as opposed to the VDI) is the easiest way.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by Perryg »

Plus the VDI you have is already 20GB and the size you have chosen is 10240 ( 10GB ). VBox will not shrink the drive.
Assuming you want to actually add 10GB the resize would be --30720 ( 30GB )
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by a cooperator »

mpack wrote:There is no problem renaming "windows1" to "windows1.vdi", except that you can't do it while it's registered in VBox - you should unregister the VDI, rename it, then add it back.
I really have tried renaming the windows1 to 'windows1.vdi' by clicking on its properties, and then putting 'vdi' in the end of file name. Thus, I got windows.VDI. However, whenever I open 'windows1.vdi' renamed, I found an error.
Failed to open the hard disk file D:\Users\Mohammad\.VirtualBox\HardDisks\windows1.all files.vdi.

Cannot register the hard disk 'D:\Users\Mohammad\.VirtualBox\HardDisks\windows1.vdi' {6b49ccfb-44f5-4a6e-bc53-32da8d6abd7e} because a hard disk 'D:\Users\Mohammad\.VirtualBox\HardDisks\windows1' with UUID {6b49ccfb-44f5-4a6e-bc53-32da8d6abd7e} already exists.

Result Code: E_INVALIDARG (0x80070057)
Component: VirtualBox
Interface: IVirtualBox {fafa4e17-1ee2-4905-a10e-fe7c18bf5554}
Callee RC: VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)


.
Resizing is supported for dynamic VDI and VHD. If you give it an unsupported format it will tell you, as you've already seen. If the command includes the modifier "--format VDI" then the resulting format will be VDI. The extension you put on the end of the filename does not determine (or even truly indicate) file format. Putting the wrong extension on a file could however be confusing for you in the future.
I am sorry to say I don't agree with you about that the extensioin I put on the end of the filename doesn't determine file format. On the contrary, it does, however the "--format VDI" modifier doesn't do anything at all. I have really tried running that command many times, even I have tried running that command without putting the extension on the end of the filename. However, I have put '--format VDI' modifier. Thus, I got a output filename such what is in this screenshot below:(it is only shown if I choose file type 'all files'.

Image

Also, I have tired:
'VBoxManage clonehd <D:\Users\Mohammad\.VirtualBox\HardDisks\windows.vdi D:\Users\Mohammad\.VirtualBox\HardDisks\windows2.vdi --format VDI
i got VDI

'VBoxManage clonehd <D:\Users\Mohammad\.VirtualBox\HardDisks\windows.vdi D:\Users\Mohammad\.VirtualBox\HardDisks\windows3.VHD --format VDI --variant Standard
I got VHD:

'VBoxManage clonehd <D:\Users\Mohammad\.VirtualBox\HardDisks\windows.vdi D:\Users\Mohammad\.VirtualBox\HardDisks\windows4.Vhdx --format VDI --variant Standard

I got VHDX:

Look at the screenshot below:
Image

Finally, I see that your VM is still using the obsolete v3.x folder structure, or some nasty hybrid. You should look to correct this soon. Cloning the VM (as opposed to the VDI) is the easiest way.
I don't know what is meant with that, but I have the most recent version of VBox
Image

If you mean with structure folder C:\Program Files\Oracle\VirtualBox', I would be saying that the old one was 'C:\Program Files\sun\Oracle\VirtualBox'

However, If you mean with sturcture folder with where Virtualbox program saves its data, I would be saying that the old one is 'D:\Users\Mohammad\.VirtualBox\HardDisks, and when I have installed the new version, the same path was still until I have created a new VM, then another path was created in D:\Users\Mohammad\VirtualBox VMs\Windows 7 64Bit.

Note: I now have two different folders for virtualBox program on my host windows existing user account.
'D:\Users\Mohammad\.VirtualBox
D:\Users\Mohammad\VirtualBox VMs
Last edited by a cooperator on 27. Feb 2014, 09:34, edited 2 times in total.
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by a cooperator »

Perryg wrote:Plus the VDI you have is already 20GB and the size you have chosen is 10240 ( 10GB ). VBox will not shrink the drive.
Assuming you want to actually add 10GB the resize would be --30720 ( 30GB )
Thank you very much indeed,

Yes, you have eventually known to put the nail in the right place, Mr/MS. PerryG, I really appreciate that, because this error took much more time than it deserved.
But the error showing me was supposed to be that 'file size' was not supported in order to explain that error was not associated with a file format.

Image

Also, when resizing successfully completed, then open the VDI resized. However, I have received the error when VM was loading.

Image

I have booted VM from a virtual optical drive with MiniTool partition wizard , and I saw that the whole Virtual disk became unallocated.
Image

Then, resizing is useless if it doesn't preserves OS. If I need to reinstall windows system, then I will create a new VM with a virtual disk with a space of 30GB.
Last edited by a cooperator on 27. Feb 2014, 02:51, edited 1 time in total.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by Perryg »

I have been watching this topic and you had several things that were keeping you from success. Each one needed to be taken care of and after you posted the screen shot and I saw the size it was apparent that was the last thing standing in your way. That said you have something that is corrupt now so I would clean out all the cruft that you have now in the folder and start over now that you have a handle on it. Remove everything except the original files.
a cooperator
Posts: 85
Joined: 3. Feb 2014, 07:02
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7
Location: Hadramawt -Yemen

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by a cooperator »

Perryg wrote:I have been watching this topic and you had several things that were keeping you from success. Each one needed to be taken care of and after you posted the screen shot and I saw the size it was apparent that was the last thing standing in your way. That said you have something that is corrupt now so I would clean out all the cruft that you have now in the folder and start over now that you have a handle on it. Remove everything except the original files.
thanks a lot,
I am afraid to say I really don't get what is meant with 'That said you have something that is corrupt now so I would clean out all the cruft that you have now in the folder and start over now that you have a handle on it. Remove everything except the original files'

The resizing was successfully completed, but , resizing is useless if it doesn't preserve OS. If I need to reinstall windows system, then I will create a new VM with a virtual disk with a space of 30GB. ( VDI had a Windows 7 installed on it, however, after resizing the VDI, the VDI became unallocated, everything on that VID was lost)
Last edited by a cooperator on 27. Feb 2014, 02:58, edited 1 time in total.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Resizing virtual disk image(VDI) with fixed size storag

Post by Perryg »

Are you sure that the original file is corrupt, or missing the OS?
Post Reply