Page 1 of 1

How to create an arbitrary multiextent vmdk?

Posted: 12. Jun 2017, 16:33
by 940607
Hi. I have a 256060514304-bytes ssd and I want to create a multiextent vmdk consisting of 3 extents: virtual, raw, virtual.
Something similar can be achieved by "createrawvmdk" with "-rawdisk" and "-partitions". This creates a small *-pt.vmdk for partition table.

I want to create my vmdk using a text editor. Here's what I do:

Code: Select all

# create pt and tail
VBoxManage createhd --filename ssd-micron-fakebig-PhysicalDrive0-pt.vmdk --size 1 --format VMDK
VBoxManage createhd --filename ssd-micron-fakebig-PhysicalDrive0-tail.vmdk --size 150000 --format VMDK
ssd-micron-fakebig-PhysicalDrive0.vmdk:

Code: Select all

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

# Extent description
RW 2048 FLAT "ssd-micron-fakebig-PhysicalDrive0-pt.vmdk" 0
RW 500116144 FLAT "\\.\PhysicalDrive0" 2048
# ..500118192
RW 307200000 FLAT "ssd-micron-fakebig-PhysicalDrive0-tail.vmdk" 0
# ..807318192

# The disk Data Base 
#DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.uuid.image="d82e6e03-2ae0-4aa4-8e80-114b16ecd65a"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
ddb.geometry.cylinders="0"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
But during the start of my Linux VM a lot of errors are printed to the console. Besides, I cannot read past 64kb:

Code: Select all

[il@reallin ~]$ dd iflag=direct if=/dev/sdb of=/dev/null
dd: error reading '/dev/sdb': Input/output error
128+0 records in
128+0 records out
65536 bytes (66 kB, 64 KiB) copied, 0.138835 s, 472 kB/s
[il@reallin ~]$
VBox.log:

Code: Select all

00:03:35.299047 AHCI#0P1: Read at offset 65536 (512 bytes left) returned rc=VERR_EOF
00:03:35.315964 AHCI#0P1: Read at offset 65536 (512 bytes left) returned rc=VERR_EOF
00:03:35.330204 AHCI#0P1: Read at offset 65536 (512 bytes left) returned rc=VERR_EOF
00:03:35.343750 AHCI#0P1: Read at offset 65536 (512 bytes left) returned rc=VERR_EOF
00:03:35.357037 AHCI#0P1: Read at offset 65536 (512 bytes left) returned rc=VERR_EOF
00:03:35.370572 AHCI#0P1: Read at offset 65536 (512 bytes left) returned rc=VERR_EOF
- Why does "showhdinfo" on a *-pt.vmdk created by VBoxManage print VERR_NOT_SUPPORTED?
Is it because "FLAT" expects a raw image, not a real .vmdk file? Is it possible to use a dynamic image as an extent?

Some other questions:


- My 1st partition starts at sector 2048. Why does the created *-pt.vmdk have size 64-sectors and the rest is filled with zeros?

Code: Select all

# partition table
RW 63 FLAT "linux-pt.vmdk" 0
# padding. Why?
RW 1985 ZERO 
# 1st partition (not used)
RW 718897152 ZERO 
# linux swap
RW 8196096 FLAT "\\.\PhysicalDrive2" 718899200
# linux
RW 249677872 FLAT "\\.\PhysicalDrive2" 727095296

Re: How to create an arbitrary multiextent vmdk?

Posted: 12. Jun 2017, 17:16
by mpack
That drive geometry looks like nonsense to me. 0 cylinders? 16 heads? What led you to believe this is correct?

IMHO better to leave this out of the header entirely, if you can't provide sensible values.

Also, are you confusing VMDK extents with filesystem partitions? I ask because while you mention a partition map, I don't see where it comes from (certainly the one in PhysicalDrive0 will not be correct). You also list a number of extents while referring to them as partitions. That's fine if you're careful to match your extent size to your actual partition sizes.

Finally, I hope PhysicalDrive0 doesn't refer to the boot drive? Because that would be very dangerous.

Re: How to create an arbitrary multiextent vmdk?

Posted: 12. Jun 2017, 17:34
by 940607
mpack wrote:That drive geometry looks like nonsense to me. 0 cylinders? 16 heads?
These lines were added by VirtualBox when I launched my VM for the first time.
mpack wrote:Also, are you confusing VMDK extents with filesystem partitions?
In the past I created vmdk files with "createrawvmdk" with "-rawdisk" and "-partitions".
Now I use those vmdk files as a reference to create a multi-extent vmdk file, completely unrelated to partitions.
mpack wrote:Finally, I hope PhysicalDrive0 doesn't refer to the boot drive? Because that would be very dangerous.
For now it's not the boot drive. Wish me luck.
Unfortunately, there's no way to refer a physical drive from a vmdk file using, for example, its manufacturer and serial number.

Re: How to create an arbitrary multiextent vmdk?

Posted: 12. Jun 2017, 18:07
by ChipMcK
if the external hard disk is physically a USB external hard drive, why not attach to whole drive to the virtual machine?

The Guest OS should be able to handle the partitioning.

Re: How to create an arbitrary multiextent vmdk?

Posted: 12. Jun 2017, 18:13
by 940607
ChipMcK wrote:if the external hard disk is physically a USB external hard drive, why not attach to whole drive to the virtual machine?
There's two reasons.
Until the very end I want to hide from the host OS the partitions I create on the SSD. This is why the leading 2048-sector image.
Also, from the guest OS I want to write 150Gb more data than the SSD can handle. This is why the tail image.

Re: How to create an arbitrary multiextent vmdk?

Posted: 12. Jun 2017, 19:10
by mpack
I would try setting the "createType" field to "monolithicflat".

Re: How to create an arbitrary multiextent vmdk?

Posted: 12. Jun 2017, 19:37
by 940607
Thnaks. I replaced FLAT with SPARSE and now it doesn't fail.

Re: How to create an arbitrary multiextent vmdk?

Posted: 13. Jun 2017, 08:43
by mpack
That doesn't make sense. Are you saying that the .vmdk extent files you included in the header are not raw? Kindof an important fact to leave out!

Re: How to create an arbitrary multiextent vmdk?

Posted: 13. Jun 2017, 09:53
by 940607
mpack wrote:That doesn't make sense. Are you saying that the .vmdk extent files you included in the header are not raw? Kindof an important fact to leave out!
uh:
940607 wrote:

Code: Select all

# create pt and tail
VBoxManage createhd --filename ssd-micron-fakebig-PhysicalDrive0-pt.vmdk --size 1 --format VMDK
VBoxManage createhd --filename ssd-micron-fakebig-PhysicalDrive0-tail.vmdk --size 150000 --format VMDK

Re: How to create an arbitrary multiextent vmdk?

Posted: 13. Jun 2017, 10:11
by mpack
Ah, I see, thanks.