Screwed up a VirtualBox VM resize

This is for discussing general topics about how to use VirtualBox.

Screwed up a VirtualBox VM resize

Postby omro » 15. Jan 2012, 22:09

Hi,

So I made a total and utter goof when resizing a virtual box HD.

I typed

Code: Select all   Expand viewCollapse view
VBoxManage modifyhd "Windows XP.vdi" --resize 25165824


because for some reason, I did the number in kilobytes instead of megabytes.

Now when I try and start the VM it tells me that there is a disk error and to press Ctrl+Alt+Del which I've tried to do on my Mac, but that seems to get me nowhere.

I then tried to resize it back down again, with

Code: Select all   Expand viewCollapse view
VBoxManage modifyhd WindowsXP.vdi --resize 20480


and I get the error

VBOX_E_NOT_SUPPORTED

and now I'm not entirely sure what to try next. Any ideas would be gratefully appreciated!!
omro
 
Posts: 26
Joined: 15. Jan 2012, 22:03
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Screwed up a VirtualBox VM resize

Postby Perryg » 15. Jan 2012, 22:23

You can not reduce the size using VBoxManage, it is not supported (yet).
Did you back this up first?
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Screwed up a VirtualBox VM resize

Postby omro » 15. Jan 2012, 22:54

Sadly no.

Why is the original file no longer being read, should it really matter how big the drive size is set to be on a dynamic drive?
omro
 
Posts: 26
Joined: 15. Jan 2012, 22:03
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Screwed up a VirtualBox VM resize

Postby Perryg » 15. Jan 2012, 22:59

Not really sure but I believe VirtualBox has a 2TB file size limitation. I have never tried to resize anything that big so I can't be sure.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Screwed up a VirtualBox VM resize

Postby omro » 15. Jan 2012, 23:18

I just tried to access the vm using a linux live cd, the data all exists inside a smaller partition inside the VM. GParted shows that it's a huge drive with all the remaining space unallocated.
omro
 
Posts: 26
Joined: 15. Jan 2012, 22:03
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Screwed up a VirtualBox VM resize

Postby mpack » 16. Jan 2012, 12:25

First: I hope you made a backup after the goof, so you can't make things any worse with the post-goof meddling. If not, do that now.

You might also want to read the thread of the last guy to do this. Here. I only recommend his repair route if you really know what you're doing. If so then you would need to patch the nBlocks(=20480) and DiskSize(=20480x1024x1024) fields with a hex editor.

However... I confess that I'm a little bit puzzled as to how you can mount the disk in a VM if VirtualBox doesn't support disks of that size. However, given that you can mount the drive, have you tried dd'ing the partition to another drive? You would then need to fix the boot. Discussion of that is probably best done in a forum specific to your guest OS, rather than here.
mpack
Site Moderator
 
Posts: 33599
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Screwed up a VirtualBox VM resize

Postby omro » 16. Jan 2012, 15:17

I did indeed make an immediate backup lol

All I did was run the VM with the Linux Mint live cd doing the booting and it seems to be able to read the files within.

what is dd'ing?
omro
 
Posts: 26
Joined: 15. Jan 2012, 22:03
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Screwed up a VirtualBox VM resize

Postby mpack » 16. Jan 2012, 15:36

omro wrote:what is dd'ing?

"dd" is a Unix/Linux tool for copying disk and partition images from one drive to another. If you can access the drive with a Linux live CD then you can certainly run dd as well (or CloneZilla).

However, another possibility is to use dd/CloneZilla to dump the partition to a image file with a .raw extension, then use CloneVDI to repackage that partition as a VDI. Converting a Windows partition image to a working disk image is a special CloneVDI trick.
mpack
Site Moderator
 
Posts: 33599
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Screwed up a VirtualBox VM resize

Postby omro » 16. Jan 2012, 15:43

I read the link you sent me, that scared me.

Can you give me some dd code if it's command line or is it a GUI tool? I'm pretty new to linux.

Thanks, I appreciate the rays of hope!
omro
 
Posts: 26
Joined: 15. Jan 2012, 22:03
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Screwed up a VirtualBox VM resize

Postby Perryg » 16. Jan 2012, 16:01

However... I confess that I'm a little bit puzzled as to how you can mount the disk in a VM if VirtualBox doesn't support disks of that size


Hi Don,
Just guessing here but I believe that the image was already mounted is why VBox still sees it but refuses to use it due to the size limitation IMHO. He of course can see it with Gparted and a live cd because they would not have this restriction, again IMHO. I have heard of others using a recovery CD to shrink the size but for the life of me I have not found the process or which application they used (still looking though) that is easier than DD which is disastrous if you make a mistake in the command.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Screwed up a VirtualBox VM resize

Postby mpack » 16. Jan 2012, 16:07

Perryg wrote:I have heard of others using a recovery CD to shrink the size but for the life of me I have not found the process

That wouldn't help in this case because, unless I'm mistaken, the partition size was never increased, so there is nothing to decrease. The problem is with a bad VDI header, and nothing run from inside the guest would be able to fix that: except of course for copying the partition to a disk with a good header.
mpack
Site Moderator
 
Posts: 33599
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Screwed up a VirtualBox VM resize

Postby Perryg » 16. Jan 2012, 16:12

The header is what I was talking about. I did read where someone used a recovery CD and a specific application that does this but I did not bookmark it. Still looking though. I really hate it when I forget to bookmark a link that I found useful at one time.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Screwed up a VirtualBox VM resize

Postby mpack » 16. Jan 2012, 16:20

@omro. Ok, try this.

You will need that hex editor I referred to earlier, and you will need a clean copy of your vdi file (not messed with by you since the goof).

Run the hex editor, select "Open Partially" and read the first 10000 bytes into the editor memory. Configure the editor to show a stream of single bytes from the file (which may be its default, I don't remember).

Move the cursor to offset 0x170 (hex 170, decimal 368). Edit the 8 bytes starting from that offset so that they are "00 00 00 00 05 00 00 00". Next move to offset 0x180 (hex 180, decimal 384). Edit the 4 bytes starting from that offset so that they are "00 50 00 00".

Save changes, exit the editor.

That should give you a working disk.

Obviously, no part of VBox can be running when you do this.
mpack
Site Moderator
 
Posts: 33599
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Screwed up a VirtualBox VM resize

Postby omro » 16. Jan 2012, 17:02

Will that return it to a 60gb drive size?
omro
 
Posts: 26
Joined: 15. Jan 2012, 22:03
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Screwed up a VirtualBox VM resize

Postby mpack » 16. Jan 2012, 17:07

omro wrote:Will that return it to a 60gb drive size?

It will return it to 20480MB (20GB). I have assumed that is ok, since that was what you attempted with VBoxManage - and AFAICS you have never said what the old drive size was. Obviously the size chosen must not be less than the existing partition size, in fact for safety it should not even be close.

If, in the suggested fix, you replace all occurrences of 5 with 8 then the fix will make it a 32GB drive instead. I think to get a 60GB drive you would have to use 'F' instead of 5 or 8.
mpack
Site Moderator
 
Posts: 33599
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Next

Return to Using VirtualBox

Who is online

Users browsing this forum: Google [Bot] and 17 guests