Page 1 of 1

[SOLVED] "raw partition" access vmdk - VBOX_E_IPRT_ERROR

Posted: 10. Apr 2013, 05:00
by fermulator
Hello VBox experts!

I'm fairly familiar with VirtualBox on a Linux host, however this is my first time using it on a Windows host. I have the following partition setup:
Image

Basically, the first 3 partitions are of type "NTFS" (for Windows), and the last partition (5) [on the logical partition 4], is intended as my "raw partition" for my guest OS.

So, I have read the documentation (like any good user should): http://www.virtualbox.org/manual/ch09.html#rawdisk

I have learned that the GUI does not support the managing of "raw disks", and we have to use the VBoxManage utility.

Now, I list the partitions as VBoxManage knows them:

Code: Select all

C:\Program Files\Oracle\VirtualBox> VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0x07  0   /32 /33  12  /223/19           100         2048
2       0x07  12  /223/20  1023/254/63         61339       206848
3       0x07  1023/254/63  1023/254/63        307200    125829120
5       0x06  1023/254/63  1023/254/63        119639    754976768
And, create my vmdk file as follows:

Code: Select all

C:\Program Files\Oracle\VirtualBox> VBoxManage.exe internalcommands createrawvmdk -filename "D:\Virtual Machines\fermmy-ubuntu\virtual_disk.vmdk" -rawdisk \\.\PhysicalDrive0 -partitions 5
It creates without error:
RAW host disk access VMDK file D:\Virtual Machines\fermmy-ubuntu\virtual_disk.vmdk created successfully.
Yet, when I attempt to add it in the GUI, it yields:
Image

I looked in the manual, to try with the command line VBoxManage utility, and the same error is presented:

Code: Select all

C:\Program Files\Oracle\VirtualBox>VBoxManage storageattach fermmy-ubuntu --storagectl "SATA" --port 0 --device 0 --type hdd --medium "D:\Virtual Machines\fermmy-ubuntu\virtual_disk-pt.vmdk"
VBoxManage.exe: error: Could not get the storage format of the medium 'D:\Virtual Machines\fermmy-ubuntu\virtual_disk-pt.vmdk' (VERR_NOT_SUPPORTED)
VBoxManage.exe: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component Medium, interface IMedium, callee IUnknown
VBoxManage.exe: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp
VBoxManage.exe: error: Invalid UUID or filename "D:\Virtual Machines\fermmy-ubuntu\virtual_disk-pt.vmdk"
NOTES:
* Done as much googling as I can. I re-ran all of the above, by executing "cmd.exe" as Administrator, AND VirtualBox as Administrator...
* The "Partition5" is a RAW DISK -- I haven't tried initializing it as NTFS ... because I thought the point was to use an unformatted partition for performance gains. (i.e. the guest doesn't have to go through the host filesystem...)

Anyone have any other ideas I can try?

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 10. Apr 2013, 12:20
by mpack
Enabling raw access to Win7 / Win2k8 disks.
viewtopic.php?f=6&t=38914#p175089

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 10. Apr 2013, 14:52
by fermulator
Darn I really thought that would've worked! ... it did not.

So I opened DISKPART, and listed the disks in the system:

Code: Select all

Microsoft DiskPart version 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: FERMMY-GAMER

DISKPART> LIST DISK

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          476 GB  1024 KB
Select the only disk (Disk 0), and view the partitions

Code: Select all

DISKPART> SELECT DISK 0

Disk 0 is now the selected disk.

DISKPART> LIST PARTITION

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    Primary            100 MB  1024 KB
  Partition 2    Primary             59 GB   101 MB
  Partition 3    Primary            300 GB    60 GB
  Partition 0    Extended           116 GB   360 GB
  Partition 4    Logical            116 GB   360 GB
It's clear to me, that I'm interested in the 116GB partition (as per my original post outlines).

I noticed that the ATTRIBUTES command only works on "DISK" or "VOLUME":

Code: Select all

DISKPART> ATTRIBUTES

Microsoft DiskPart version 6.1.7601

VOLUME      - Manipulate volume attributes.
DISK        - Manipulate disk attributes.
Therefore, I have to consider my 'raw partition' as a volume:

Code: Select all

DISKPART> LIST VOLUME

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     E                       DVD-ROM         0 B  No Media
  Volume 1         System Rese  NTFS   Partition    100 MB  Healthy    System
  Volume 2     C   Windows 7    NTFS   Partition     59 GB  Healthy    Boot
  Volume 3     D   Games        NTFS   Partition    300 GB  Healthy
  Volume 4                      RAW    Partition    116 GB  Healthy

DISKPART> SELECT VOLUME 4

Volume 4 is the selected volume.
Now, list the attributes

Code: Select all

DISKPART> ATTRIBUTES DISK
Current Read-only State : No
Read-only  : No
Boot Disk  : Yes
Pagefile Disk  : Yes
Hibernation File Disk  : No
Crashdump Disk  : Yes
Clustered Disk  : No

DISKPART> ATTRIBUTES VOLUME
Read-only              : Yes
Hidden                 : No
No Default Drive Letter: No
Shadow Copy            : No
OK so now I need to offline the volume, clear the read-only flag, and Bob should now be my Uncle right?

Code: Select all

DISKPART> OFFLINE VOLUME

DiskPart successfully offlined the selected volume.

DISKPART> ATTRIBUTES VOLUME CLEAR READONLY

Volume attributes cleared successfully.

DISKPART> ATTRIBUTES VOLUME
Read-only              : No
Hidden                 : No
No Default Drive Letter: No
Shadow Copy            : No
FAIL. Same error in VBox GUI and command line ....

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 10. Apr 2013, 15:07
by fermulator
It is probably worthy to note here that for this entire post, I have been trying to load the "virtual_disk-pt.vmdk" (binary) file that is created by VBoxManage internalcommands createrawvmdk. It /also/ has created a vritual_disk.vmdk file... The virtual_disk.vmdk is "raw text" (viewable) and the virtual_disk-pt.vmdk is a non-human-readable binary.

Here's the virtual_disk.vmd file:

Code: Select all

# Disk DescriptorFile
version=1
CID=3f8869da
parentCID=ffffffff
createType="partitionedDevice"

# Extent description
RW 63 FLAT "virtual_disk-pt.vmdk" 0
RW 1985 ZERO 
RW 204800 ZERO 
RW 125622272 ZERO 
RW 629145600 ZERO 
RW 63 FLAT "virtual_disk-pt.vmdk" 63
RW 1985 ZERO 
RW 245020672 FLAT "\\.\PhysicalDrive0" 754976768
RW 2560 ZERO 

# The disk Data Base 
#DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="16383"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.uuid.image="7b61119a-94f3-49aa-8e80-14638be93c56"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
If I load the "virtual_disk.vmdk" (raw-text), it says that the disk is ~476G! So I assume that VBoxManage created the "raw disk" (virtual_disk.vmdk) and the "raw partition" (virtual_disk-pt.vmdk)... That is also to say, that I assumed that this file is NOT the right file to use ... as I'm expecting only ~116G of space for this partition.

Despite being able to load the virtual_disk.vmdk file without errors, I'm absolutely terrified to start the guest host with this storage attached to it, in fear that it will overwrite my Windows7 partition!

Image

Is it a bug?

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 10. Apr 2013, 15:27
by mpack
Raw disk access means that a second PC will be accessing your hosts hard disk at the same time as your host. If you have any doubts whatsoever about your expertise then you should leave it alone.

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 10. Apr 2013, 15:28
by mpack
As to the error, I'm surprised to see a logical partition still being used in this day and age. Lack of support for that is possibly what is causing the error.

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 10. Apr 2013, 20:20
by fermulator
OK am I using the wrong thing for my use case?

I want to simply have a guest OS, to consume the entire 4th partition of the hard disk. In reading, because I want the best performance possible, I want that guest OS to utilize the "raw disk".

If I don't use "raw disk", I'm basically:
1. Formatting the 4th partition for NTFS.
2. Having a new VMDK or VDI virtual disk (fixed size) for the full size of the partition, on top of the NTFS filesystem.


... I'm trying to AVOID the "NTFS" part... since I assume I'll have worse performance in my guest OS if it's utilizing a virtual disk on top of the host NTFS filesystem...

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 11. Apr 2013, 06:24
by fermulator
mpack wrote:As to the error, I'm surprised to see a logical partition still being used in this day and age. Lack of support for that is possibly what is causing the error.
I tried be removing the logical partition and sticking to 4x primary partitions (used gparted to reset this). The same issue persists.

Re: "raw partition" access within vmdk - VBOX_E_IPRT_ERROR

Posted: 11. Apr 2013, 06:58
by fermulator
Alright. FIXED

As it turns out, my entire confusion is that we /should/ be using virtual_disk.vmdk file, and NOT the virtual_disk-pt.vmdk file.

In addition, to my concern about "VirtualBox potentially wiping me entire disk because it shows it as a full size" this was simply a mis-understanding. The "Raw Disk" pointer that is created, still in fact is "aware" of the entire disk. But denoting with "-partitions" specific partitions, the guest OS only has "read-only" access to those partitions.

This was enlightened to me by re-reading: http://www.sysprobs.com/access-physical ... n-software
Warning

Raw hard disk access is for expert users only. Incorrect use or use of an outdated configuration can lead to total loss of data on the physical disk. Most importantly, do not attempt to boot the partition with the currently running host operating system in a guest. This will lead to severe data corruption.

Raw hard disk access — both for entire disks and individual partitions — is implemented as part of the VMDK image format support. As a result, you will need to create a special VMDK image file which defines where the data will be stored. After creating such a special VMDK image, you can use it like a regular virtual disk image

Access to entire physical hard disk

While this variant is the simplest to set up, you must be aware that this will give a guest operating system direct and full access to an entire physical disk. If your host operating system is also booted from this disk, please take special care to not access the partition from the guest at all. On the positive side, the physical disk can be repartitioned in arbitrary ways without having to recreate the image file that gives access to the raw disk.
To re-iterate, I performed the following steps:

Code: Select all

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0x07  0   /32 /33  12  /223/19           100         2048
2       0x07  12  /223/20  1023/254/63         61339       206848
3       0x07  1023/254/63  1023/254/63        307200    125829120
5       0x06  1023/254/63  1023/254/63         30720    754976768
6       0x06  1023/254/63  1023/254/63         88918    817893376
So (as a small change from the original post), I now have an extended partition setup (#4), with 2 logical partitions (#5 for / [root], and #6 for /home -- yes, a Linux GuestOS).

Then I simply created the vmdk files necessary to access those partitions.

Code: Select all

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "D:\Virtual Machines\fermmy-ubuntu\virtual_disk.vmdk" -rawdisk \\.\PhysicalDrive0 -partitions 5,6
RAW host disk access VMDK file D:\Virtual Machines\fermmy-ubuntu\virtual_disk.vm
dk created successfully.
And, running VirtualBox as administrator on the Windows host, I added the storage device: "D:\Virtual Machines\fermmy-ubuntu\virtual_disk.vmdk". It shows up as the FULL DISK disk ... but when you get into the GuestOS level, while it can see all partitions, you must take special care to ONLY utilize the partitions available to it. (in my case /dev/sda5 & /dev/sda6)

WARNING: Ubuntu would want to install grub on the "root" drive -- You MUST choose the alternate installing the boot loader on the partition!!!

Re: [SOLVED] "raw partition" access vmdk - VBOX_E_IPRT_ERRO

Posted: 11. Apr 2013, 07:22
by fermulator
uggg, one more thing.

Turns out there are some bugs in Vbox at the moment. (https://www.virtualbox.org/ticket/9926) Namely, its unable to boot from a sub-partition from the main disk. So installing the MBR to anything OTHER Than the master MBR of the disk, won't work by default.

There's a trick!
http://superuser.com/questions/430331/v ... ot-booting

I basically follows that, and created my vmdk file with that mbr (copied from /dev/sda5), and voila!

Code: Select all

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "D:\Virtual Machines\fermmy-ubuntu\virtual_disk.vmdk" -rawdisk \\.\PhysicalDrive0 -partitions 5,6 -mbr "D:\Virtual Machines\fermmy-ubuntu\fermmy-ubuntu.mbr"
RAW host disk access VMDK file D:\Virtual Machines\fermmy-ubuntu\virtual_disk.vmdk created successfully.