Createrawvmd in vb 7.0.0 fails with error

Discussions related to using VirtualBox on Linux hosts.
Post Reply
rahrah
Posts: 3
Joined: 19. Oct 2022, 22:15

Createrawvmd in vb 7.0.0 fails with error

Post by rahrah »

I just tried to create a vmdk file using the command:

Code: Select all

$ VBoxManage internalcommands createrawvmdk -filename usbboot.vmdk -rawdisk /dev/sdd
under vb 7.0.0 r153978, on a Linux host. I get an error with no .vmdk file.

Code: Select all

$ VBoxManage internalcommands createrawvmdk -filename usbboot.vmdk -rawdisk /dev/sdd
VBoxManage: error: VMDK: Image path: 'usbboot.vmdk'. Getting config interface failed
VBoxManage: error: Error code VERR_INVALID_PARAMETER at /home/vbox/tinderbox/lin64-rel/src/VBox/Storage/VMDK.cpp(4481) in function int vmdkRawDescParseConfig(PVMDKIMAGE, char**, uint32_t*, uint32_t*, void**, size_t*, bool*, char**)
VBoxManage: error: VMDK: could get raw descriptor for 'usbboot.vmdk'
VBoxManage: error: Error code VERR_INVALID_PARAMETER at /home/vbox/tinderbox/lin64-rel/src/VBox/Storage/VMDK.cpp(5296) in function int vmdkCreateImage(PVMDKIMAGE, uint64_t, unsigned int, const char*, PCVDGEOMETRY, PCVDGEOMETRY, PCRTUUID, PVDINTERFACEPROGRESS, unsigned int, unsigned int)
VBoxManage: error: Cannot create the raw disk VMDK: VERR_INVALID_PARAMETER
VBoxManage: error: The raw disk vmdk file was not created
After rolling back to 6.1.38, the command worked fine. Once the vmdk is created under 6.1.38, vb 7.0.0 access to the device works fine.

The device /dev/sdd is a partitioned usb drive, 256 GB (233 GiB) in size
using a gpt partition table with one partition and a FAT32 file system.

The listpartitions command (7.0.0) works fine:

Code: Select all

$ VBoxManage internalcommands listpartitions -rawdisk /dev/sdd
Number  Type   StartCHS       EndCHS      Size (MiB)  Start (Sect)
1       0x00  0   /0  /0   0   /0  /0         238559           64
I'm running Slackware-current, kernel 5.19.14, glibc-2.36

VB in both 7.0.0 and 6.1.38 is the standard "All distributions" version:

VirtualBox-7.0.0-153978-Linux_amd64.run

I'd be happy to provide any other relevant info.

Thanks for reading.

All the best,

===Rich
granada29
Volunteer
Posts: 704
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

Re: Createrawvmd in vb 7.0.0 fails with error

Post by granada29 »

In VirtualBox 7.0.0 the syntax for creating a raw vmdk has been changed.

See https://www.virtualbox.org/manual/UserM ... age-config where you will see the command is now something like:

Code: Select all

VBoxManage createmedium disk --filename path-to-file.vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sda
I have been unable to have this work successfully on macOS so I am interested to learn if it works on Linux. I filed a bug at https://www.virtualbox.org/ticket/21125 and there has been discussion at viewtopic.php?f=15&t=106934
rahrah
Posts: 3
Joined: 19. Oct 2022, 22:15

Re: Createrawvmd in vb 7.0.0 fails with error

Post by rahrah »

Thank you, granada29, for sharing your experience with this.

I've just tried the command, now, and can confirm that the stanza as given:

Code: Select all

$ VBoxManage createmedium disk --filename $(pwd -P)/try_5.vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sdd
does *not* produce a working vmdk file for me under Linux. No ddb.geometry.* information is shown in the file, and the 'Extent description' lines differ between the working file and the one created with the createmedium sub command.

For the working command under vb 6.1.38:

Code: Select all

$ VBoxManage internalcommands createrawvmdk -filename usbboot.vmdk -rawdisk /dev/sdd
I get this in the vmdk file:

Code: Select all

# Extent description
RW 488570880 FLAT "/dev/sdd" 0
For the command:

Code: Select all

$ VBoxManage createmedium disk --filename $(pwd -P)/try_5.vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sdd
I get this in the vmdk file:

Code: Select all

# Extent description
RW 0 FLAT "/dev/sdd" 0
I made some attempts with:

Code: Select all

/opt/VirtualBox/VBoxManage createmedium disk --filename "$(pwd -P)/try_5.vmdk" --format=VMDK --variant RawDisk --property RawDrive=/dev/sdd --property Partitions=1
but this didn't work, either, though:

* The extents seemed more sensible

* There was ddb.geometry information in the text file.

* This ddb.geometry entry seems questionable ddb.geometry.cylinders="1"

* A secondary try_5-pt.vmdk file was made, that looked like a binary dump of the partition table, and all sectors before the main partition.

I had a look at the vmdk-basics.html file pointed to the thread to which you refer, but it needs some careful reading.

I'll try to do a bit more experimentation tomorrow.

Once gain, thank you for sharing this with me.

===R
granada29
Volunteer
Posts: 704
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

Re: Createrawvmd in vb 7.0.0 fails with error

Post by granada29 »

Thanks for posting and confirming similar errors on Linux to what I see on macOS. I'll add a link to this thread for the bug I have raised, but maybe you should also raise one for Linux.
granada29
Volunteer
Posts: 704
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

Re: Createrawvmd in vb 7.0.0 fails with error

Post by granada29 »

This bug has been noted by the devs (https://www.virtualbox.org/ticket/21125) and a fix is in progress.
paulson
Oracle Corporation
Posts: 28
Joined: 6. Jun 2019, 20:16

Re: Createrawvmd in vb 7.0.0 fails with error

Post by paulson »

A separate bug has been filed for the broken 'VBoxManage internalcommands
createrawvmdk' functionality:

Can't create a raw vmdk in Virtualbox 7.0.2
https://www.virtualbox.org/ticket/21214

Both #21214 and #21125 will be addressed in the next maintenance release of
VirtualBox 7. As I mentioned in the tickets, creating raw VMDK images on
VirtualBox 7 is currently non-functional. The temporary workaround for
now is to install VirtualBox 6.1.x and use 'VBoxManage internalcommands
createrawvmdk' there.
rahrah
Posts: 3
Joined: 19. Oct 2022, 22:15

Re: Createrawvmd in vb 7.0.0 fails with error

Post by rahrah »

Hi,

Contrary to other reports, I cannot make this work in 7.0.4r154605, under Linux Using a disk image files (rather than an actual disk (usb) or or /dev/sdXY device files):

Code: Select all

/opt/VirtualBox/VBoxManage createmedium disk \
  --filename "$(/bin/pwd)/test.vmdk" \
  --format=VMDK \
  --variant RawDisk \
  --property RawDrive=/home/test/test.img
I got this:

Code: Select all

0%...VBOX_E_FILE_ERROR
VBoxManage: error: Failed to create medium
VBoxManage: error: Could not create the medium storage unit '/home/VirtualBox VMs/xxx/test.vmdk'.
VBoxManage: error: VMDK: Image path: '/home/VirtualBox VMs/xxx/test.vmdk'. Failed to get the sector size for '/home/test/test.img' (VERR_INVALID_FUNCTION) (VERR_INVALID_FUNCTION).
VBoxManage: error: VMDK: could not create raw descriptor for '/home/VirtualBox VMs/xxx/test.vmdk' (VERR_INVALID_FUNCTION)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 634 of file VBoxManageDisk.cpp
When using:

Code: Select all

/opt/VirtualBox/VBoxManage internalcommands createrawvmdk -filename "$(/bin/pwd)/test.vmdkj" -rawdisk /home/test/test.img
I get a similar error:

Code: Select all

The 'createrawvdk' subcommand is deprecated.  The equivalent functionality is
available using the 'VBoxManage createmedium' command and should be used
instead.  See 'VBoxManage help createmedium' for details.

0%...VBOX_E_FILE_ERROR
VBoxManage: error: Failed to create medium
VBoxManage: error: Could not create the medium storage unit '/home/VirtualBox VMs/xxx/test.vmdk'.
VBoxManage: error: VMDK: Image path: '/home/VirtualBox VMs/xxx/test.vmdk'. Failed to get the sector size for '/home/test/test.img' (VERR_INVALID_FUNCTION) (VERR_INVALID_FUNCTION).
VBoxManage: error: VMDK: could not create raw descriptor for '/home/VirtualBox VMs/xxx/test.vmdk' (VERR_INVALID_FUNCTION)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium
VBoxManage: error: Context: "RTEXITCODE handleCreateMedium(HandlerArg*)" at line 634 of file VBoxManageDisk.cpp
The image still boots with a .vmdk file created with a previous version of VB.
Can the createmedium use disk images (like a dd of a complete usb drive) as did createrawvmdk? Or am I doing something wrong?

Thanks,

===Rich

Edit:
I was able to create a vmdk file by registering the file
as a loop device, then running the createmedium on that.

Code: Select all

losetup --show -f -P /home/test/test.img
Which gives

Code: Select all

/dev/loop0
(or some other /dev/loopX device).

Then run:

Code: Select all

/opt/VirtualBox/VBoxManage createmedium disk \
  --filename "$(/bin/pwd)/test.vmdk" \
  --format=VMDK \
  --variant RawDisk \
  --property RawDrive=/dev/loop0
(may have to be run as root for permission reasons).

After running the above command, disassociate the loop device:

Code: Select all

losetup -d /dev/loop0
The test.vmdk file can then be edited:

Code: Select all

# Extent description
-RW 10485760 FLAT "/dev/loop0" 0
+RW 10485760 FLAT "/home/test/test.img" 0
then associated with a vm and used successfully (at least for me,
YMMV).
Post Reply