Page 1 of 1

unregister a hard disk image

Posted: 26. Aug 2010, 04:48
by jinjou
I tried to set up a raw host hard disk as described in "9.7.1 Using a raw host hard disk from a guest" of the manual. I got pretty much the same result as this:

Difficulty enabling raw partitions
http://forums.virtualbox.org/viewtopic. ... ds#p150566

except I was using MS Windows Vista x64 as the host. I assumed the problem was related to:
"Creating the image requires read/write access for the given device. Read/write
access is also later needed when using the image from a virtual machine. If this is not
feasible, there is a special variant for raw partition access (currently only available on
Linux hosts) that avoids having to give the current user access to the entire disk."
which is in "9.7.1.2 Access to individual physical hard disk partitions"

So, OK, fine. But before that, in order to make it work, I tried this:
"Just like with regular disk images, this does not automatically register the newly created
image in the internal registry of hard disks. If you want this done automatically,
add -register"
which is explained better in "9.7.1.1" than in "9.7.1.2", and which of course didn't work.

However, now I'm stuck with a registered hard disk image that's not associated with any VM. How do I unregister it? Turns out the documentation makes no formal mention of anything related to "internalcommands" anywhere else in the manual that I could find. It also doesn't explain how to unregister a hard disk image. What's a poor boy to do? Do I have to reinstall VB? Will that even help?

*****

This was interesting reading (I only skimmed) but it didn't cover the above and seemed oriented towards a more technical understanding:

Tutorial: All about VDIs
http://forums.virtualbox.org/viewtopic.php?t=8046

Discuss All about VDIs
http://forums.virtualbox.org/viewtopic.php?t=8048

It does look like the right place for a discussion of the issue I'm confronted with.

Re: unregister a hard disk image

Posted: 26. Aug 2010, 15:06
by mpack
Go into File | Virtual Media Manager. Select "Release" to disassociate the hard disk from all VMs ("Release" will be grayed out if it isn't mounted in any VM). Then select "Remove" to unregister the disk. When asked if you want to physically delete the virtual disk file answer yes: don't worry, this only deletes the VMDK descriptor file, not your partition.

Re: unregister a hard disk image

Posted: 29. Aug 2010, 20:26
by jinjou
First, I should mention that the reason I didn't get back to this sooner is that I was busy reading all 33 pages of the CloneVDI post, which was very interesting (until about page 31 when things began to become more and more off topic :)).

Second, what mpack suggested worked great with the .vdi file that I had since created with the VM I'm trying to set up, and so I added a little more experience to my slowly accumulating wealth. But the VMDK descriptor file never appeared in the Virtual Media Manager in the first place. I was never able to successfully add it, therefore it was never available to unregister nor remove.

Last, what I'd like to do is what is suggested in "9.7.1 Using a raw host hard disk from a guest" of the manual.

At first I created a non-registered virtual disk with this command:
VBoxManage internalcommands createrawvmdk -filename "P:\VirtualBox\HardDisks\DOS.vmdk" -rawdisk \\.\PhysicalDrive1 -partitions 1

RAW host disk access VMDK file P:\VirtualBox\HardDisks\DOS.vmdk created successfully.
However, when I tried to include that in the VM, it failed with an error.

The instructions include the possibility of "registering" the virtual disk which I thought/hoped might be the basis of the error:
VBoxManage internalcommands createrawvmdk -filename "P:\VirtualBox\HardDisks\DOS.vmdk" -rawdisk \\.\PhysicalDrive1 -partitions 1 -register

ERROR: VMDK: could not create new file 'P:\VirtualBox\HardDisks\DOS.vmdk'
Error code VERR_ALREADY_EXISTS at D:\tinderbox\win-3.2\src\VBox\Devices\Storage\
VmdkHDDCore.cpp(3539) in function vmdkCreateRawImage
Error while creating the raw disk VMDK: VERR_ALREADY_EXISTS
The raw disk vmdk file was not created
So I deleted the file(s) (there seem to be two that result from creation) and tried again:
VBoxManage internalcommands createrawvmdk -filename "P:\VirtualBox\HardDisks\DOS.vmdk" -rawdisk \\.\PhysicalDrive1 -partitions 1 -register

RAW host disk access VMDK file P:\VirtualBox\HardDisks\DOS.vmdk created successfully.
When I tried to include that in the VM, it failed with an error again, so registering the disk wasn't the problem.

After re-reading the manual, I thought I might be able to get away with this:
VBoxManage internalcommands createrawvmdk -filename "P:\VirtualBox\HardDisks\DOS.vmdk" -rawdisk \\.\PhysicalDrive1 -partitions 1 -relative -register

(...bunch of deleted help text...)

Syntax error: Invalid parameter '-relative'
I'm using Vista x64 so I knew it shouldn't work, but I was beginning to suspect a permission issue and didn't see any harm in trying.

I then manually deleted the registered virtual disk files and tried this:
VBoxManage internalcommands createrawvmdk -filename "P:\VirtualBox\HardDisks\DOS.vmdk" -rawdisk \\.\PhysicalDrive1 -partitions 1 -register

RAW host disk access VMDK file P:\VirtualBox\HardDisks\DOS.vmdk created successfully.
ERROR: Cannot register the hard disk 'P:\VirtualBox\HardDisks\DOS.vmdk' with UUID {7cf5c2ef-df2f-4f51-aa8f-684c27347315} because a hard disk 'P:\VirtualBox\Hard Disks\DOS.vmdk' with UUID {23a1f987-88fe-4888-8971-f1cc75214860} already exists in the media registry ('C:\Users\Owner/.VirtualBox\VirtualBox.xml')
Details: code E_INVALIDARG (0x80070057), component VirtualBox, interface IVirtualBox, callee IUnknown
Context: "OpenHardDisk(filename, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())" at line 1441 of file VBoxInternalManage.cpp
OK, so I created the files again (I hadn't noticed this when I tried the command, but I found the files later, much to my confusion). So now how do I unregister the old files so that the new ones can be registered?

I tried some other commands to demonstrate the validity of what the manual was saying, and to try and assess the situation:
VBoxManage internalcommands listpartitions -rawdisk \\.\PhysicalDrive1

Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0x0b 0 /1 /1 1 /254/63 15 63
2 0x07 2 /0 /1 1023/254/63 64244 32130
3 0x07 1023/0 /1 1023/254/63 126519 131604480
It's the first one I'm after. It's Ms-DOS because of my preferences for disk utilities.
VBoxManage list hdds

UUID: 23a1f987-88fe-4888-8971-f1cc75214860
Parent UUID: base
Format: VMDK
Location: P:\VirtualBox\HardDisks\DOS.vmdk
State: inaccessible
Type: normal
There's the culprit, now how do I get rid of it?

Tried this just for grins:
VBoxManage storagectl "DOS" --name DOS --remove
ERROR: Could not find a registered machine named 'DOS'
Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee IUnknown
Context: "FindMachine(Bstr(a->argv[0]), machine.asOutParam())" at line 758 of file VBoxManageStorageController.cpp
One more time:
VBoxManage list hdds

UUID: 23a1f987-88fe-4888-8971-f1cc75214860
Parent UUID: base
Format: VMDK
Location: P:\VirtualBox\HardDisks\DOS.vmdk
State: inaccessible
Type: normal
I then created a regular .vdi disk with the Virtual Media Manager. But I can't boot off of it, which was the whole point in the first place.

At this point I went looking for help on the forum. Not finding much (I'm guessing I used the "internal search"; I certainly didn't use Google), I registered and created this topic. Then I got lost reading a lot about CloneVDI :).

I read mpack's post and resumed my effort. Tried this again:
VBoxManage list hdds

UUID: 8a0e8690-0112-4efe-849d-cd182a058328
Parent UUID: base
Format: VDI
Location: P:\VirtualBox\HardDisks\DOS.vdi
State: created
Type: normal
Usage: DOS (UUID: 0e8c94bb-e1ea-4f3e-82d6-197037c35b7f)
Hmm, no .vmdk this time. Oh, that's right I created a .vdi, but what happened to the .vmdk?

Then I followed the instructions in mpack's post. Then I started composing this post. Then I tried this:
VBoxManage list hdds

(...no output...)
OK, so what happened to the .vmdk? Is it actually gone/unregistered? Can I safely delete the files now?

Geez, what a saga!

Sorry for all the blow by blow, but it beats having to provide it anyway when "plain English" fails to suffice. Oh, and I still don't have what I wanted, which was a bootable DOS virtual disk. That'll have to wait for another post, or more likely, a new topic.