VirtualBox

Opened 13 years ago

Last modified 7 years ago

#9103 reopened defect

modifyvm --resize doesn't work with snapshots

Reported by: jonsiddle Owned by:
Component: virtual disk Version: VirtualBox 4.0.8
Keywords: modifyhd resize Cc:
Guest type: other Host type: Linux

Description (last modified by Frank Mehnert)

I have a 20GB dynamic .vdi which I want to resize to 40GB so I issue:

VBoxManage modifyhd /full/path/to/hd.vdi --resize 40960

and it responds (instantly) with:

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Running VBoxManage showhdinfo on the image tells me:

... Logical size: 40960 MBytes Current size on disk: 18464 MBytes Type: normal (base) Storage format: VDI Format variant: dynamic default ...

and also reports the same logical size for the snapshot files.

The problem is that gparted reports that the drive is still 20G (not the partition; the whole drive).

Windows disk management also sees the drive as 20G.

It looks like while VirtualBox can see the new logical size, it's not reporting it to the guest correctly.

Change History (19)

comment:1 by long, 13 years ago

So I ran into this same problem and the reason it doesn't work is because you have snapshots. I hope you have a backup of your .vdi before you resized it because you will need it. Basically you will need to fall back to the original .vdi and then delete all of your snapshots before trying to resize it. It seems to me that modifyhd shouldn't let you resize a .vdi that has snapshots associated with it.

comment:2 by Klaus Espenlaub, 13 years ago

Resolution: invalid
Status: newclosed

Sorry, the answer by the previous user is not correct.

You can resize a VM which has snapshots, but you must resize the right thing.

Resizing the first snapshot (more accurately the base image) only affects that one. It doesn't magically change anything else.

So what you need to do is to identify the diff image which is associated with "Current State", i.e. what is attached to the VM. This image needs to be resized.

This is working correctly, so I'm closing this ticket.

comment:3 by thierrybo, 13 years ago

Please explain what you mean by "identify the diff image which is associated with "Current State", i.e. what is attached to the VM. "?

I look for my HOME .VirtualBox folder and only found the base vdi and snapshots. Where is the Current State?

comment:4 by Frank Mehnert, 13 years ago

Have a look at VBoxManage showvminfo VM_NAME. The status text contains the current hard disks which is attached to the VM. If the VM has a snapshot, the information will show the current differential image.

comment:5 by thierrybo, 13 years ago

OK, but I just see snapshots I can already see in the GUI, but not further "current state". IF I run:

VBoxManage modifyhd "~/.VirtualBox/Machines/XPPRO/Snapshots/{6a9489b3-3d02-4492-b0f4-00b4027a1925}.vdi" --resize 25000

on the last snapshot I get: Progress state: VBOX_E_NOT_SUPPORTED VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

but it works on the base vdi

comment:6 by Ivan, 11 years ago

I'm having exactly the same problem as thierrobo wrote. Using VB 4.1.22

I've run the resize action on my primary vdi file, it completed successfully. I run VBoxManage showvminfo on my machine, looked at what UUID is associated with my current state HDD snapshot, run showhdinfo on that, it shows the new, resized logical size. But the guest OS still sees the old size. modifyhd on the UUID of the snapshot throws VBOX_E_NOT_SUPPORTED.

Oracle folks, please explain the steps that we need to do for the guest OS to see the updated size.

Thanks

comment:7 by Ivan, 11 years ago

Resolution: invalid
Status: closedreopened

comment:8 by JSW, 11 years ago

I am seeing the same not supported message using VirtualBox 4.2.4

VBoxManage modifyhd \{5f4afe34-8165-4f90-b3b5-1e9d88716cad\}.vdi --resize 40960
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

Please advise ASAP

comment:9 by Frank Mehnert, 11 years ago

Description: modified (diff)

Resizing of differential images is not supported. To resize the hard disk you have to merge the differential images with the base image (delete all snapshots) and then resize the base image. And resizing does only work if you increase the size, decreasing is not implemented.

comment:10 by carter, 10 years ago

I ran into this same problem: I resized the original disk image, did not see the new size in the guest, found this bug. Then I tried to delete the snapshots, but virtualbox crashed while merging the first snapshot.

Suggestion: The resize command should fail when applied to a disk image attached to a VM that has snapshots. In the meantime please update the documentation of modifyhd and add a warning that this command will not work correctly and will cause data loss if you have snapshots.

comment:11 by humber81, 9 years ago

Hello All

I already tested a solution for the issue with the resize command, here i explain what i did:

First, remove your virtual disk from the virtual machine (note: just remove from the list not delete it from your host machine)

Second, resize the virtualdisk.

Third, add again your virtual disk to the virtual machine and when you have been added you can check that the size is the correct on the properties of the harddisk into your VM.

now for assign the free space added you need to do it with a live cd and the gparted tool if you are using linux on the guest machine, on windows just with the disk management can do it.

for the VBOX_E_NOT_SUPPORTED error, that's occurred because if you are trying to expand a disk with VMDK format, the 'VBoxManage modifyhd' command don't support this type of format just VDI or VHD, for resize this type of disk format first need to be cloned with the 'VBoxManage clonehd' command specifying the new format and extension for the output harddisk file, then resize the cloned harddisk and add it to the virtual machine (the original disk can be removed from the list without problems before turn on the VM because both virtual disks have the same data stored, just the size is different).

Here i put you the example that i tested too with a cloned harddisk:

[humberto@Fedora-Toshiba OL6]$ VBoxManage modifyhd OL6HardDisk1.vmdk --resize 51200 0% Progress state: VBOX_E_NOT_SUPPORTED VBoxManage: error: Resize hard disk operation for this format is not implemented yet!

[humberto@Fedora-Toshiba OL6]$ VBoxManage clonehd OL6HardDisk1.vmdk OL6HardDisk1.vdi --format VDI 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone hard disk created in format 'VDI'. UUID: 3ad33b28-9a1e-462e-bbd0-b34fb56829f2

[humberto@Fedora-Toshiba OL6]$ VBoxManage modifyhd OL6HardDisk1.vdi --resize 51200 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% [humberto@Fedora-Toshiba OL6]$

Well i hope this help to everybody to solve this problem.

Regards

comment:12 by david.fraser, 9 years ago

I've tested this in VirtualBox 4.3.10 running on Ubuntu; resizing the base image and all snapshots worked successfully, and after restarting VirtualBox I could go back to a snapshot and the increased disk space was visible with fdisk -l (of course, you need to get your guest operating system to adjust the disk partitions to be able to use the space at any point):

$ VBoxManage modifyhd base.vdi --resize 30000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ VBoxManage modifyhd Snapshots/\{85332f93-dc84-4a86-9738-364a8331561d\}.vdi --resize 30000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
$ VBoxManage modifyhd Snapshots/\{69469bae-e563-412b-8acc-a2f961d1ae43\}.vdi --resize 30000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

So I think this ticket should be marked as fixed...

comment:13 by Jim Avera, 8 years ago

david.fraser - what exactly did you do to resize a vdi with snapshots?

Simply running VBoxManage modifyhd ... on the base .vdi and all Snapshots .vdi files did NOT work for me using VirtualBox 5.0.6r103037

$ cd $HOME/'VirtualBox VMs/vmname'
$ for f in *.vdi Snapshots/*.vdi ; do VBoxManage modifyhd "`pwd`/$f" --resize  16000 ; done
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

...but the guest OS still thinks the physical disk is still 8GB (according to gparted)

comment:14 by S8ER, 8 years ago

I just had this error after successfully running the command on the exact same vdi (no snapshots).

bash-3.2$ VBoxManage modifyhd W10New.vdi --resize 80000
0%...
Progress state: VBOX_E_NOT_SUPPORTED
VBoxManage: error: Resize medium operation for this format is not implemented yet!

5.0.10 r104061

I expanded the vdi...booted the VM and discovered I had it set higher than I wanted. Now when I attempt to resize I get the error on both the original vdi and the clone I created using humber81s method.

in reply to:  13 comment:15 by david.fraser, 8 years ago

Replying to jimav:

david.fraser - what exactly did you do to resize a vdi with snapshots?

Sorry I didn't reply earlier; as far as I recall I did exactly the same as you, so I'm not sure why it's not working... and haven't tried again since I wrote that

comment:16 by Frank Mehnert, 8 years ago

Please be aware that increasing the size of VDI images is implemented while decreasing the size is not. Probably this explains the VBOX_E_NOT_SUPPORTED error message.

I don't think it's really necessary to decrease the size of a virtual disk image. Keep in mind that the guest OS will only occupy space according to the guest partition. As long as you didn't change the guest partition information (e.g. using gparted) the virtual disk image will not grow further.

comment:17 by robert@…, 7 years ago

+1

This ticket should have "with snapshots" in the title, to make it findable.

Also see

  • "modifyhd --resize should warn users about existing snapshots" (#10818), and
  • "modifyhd --resize should not be permitted when snapshots exist" (#13046).

Workaround without losing the snapshots: Clone the machine, remove the snapshots there, resize there.

(Can someone add me to Cc please? It seems I can't do this myself.)

Last edited 7 years ago by robert@… (previous) (diff)

comment:18 by Klaus Espenlaub, 7 years ago

Summary: modifyvm --resize doesn't workmodifyvm --resize doesn't work with snapshots

in reply to:  17 comment:19 by Klaus Espenlaub, 7 years ago

Replying to robert@…:

This ticket should have "with snapshots" in the title, to make it findable.

Done. Very good suggestion, didn't think of this really obvious one.

Also see

  • "modifyhd --resize should warn users about existing snapshots" (#10818), and
  • "modifyhd --resize should not be permitted when snapshots exist" (#13046).

Workaround without losing the snapshots: Clone the machine, remove the snapshots there, resize there.

5.1.28 (due out soon) and 5.2.0 will detect if there's potential data loss for a snapshot deletion due to image capacity differences caused by resize, so the worst pitfall is now handled in a sensible way.

(Can someone add me to Cc please? It seems I can't do this myself.)

Everyone who ever posted a comment to some ticket will get all further ticket updates if the email address in Preferences is set correctly. Lots of people have it empty or put an address there which is by now invalid.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use