VirtualBox and iSCSI disks

This is for discussing general topics about how to use VirtualBox.
Post Reply
dgmad
Posts: 7
Joined: 21. Feb 2011, 11:06
Primary OS: Other
VBox Version: OSE other
Guest OSses: linux

VirtualBox and iSCSI disks

Post by dgmad »

Hello,

I'm playing with VirtualBox 4.0.4 and iSCSI virtual disks. I'm using ZFS as the backend iscsi targets and this works ok. I was able to create a zpool and export it as an iscsi target and successfully install linux on the virtual drive from the virtual box guest os.

However, i would like to be able to copy vdi image into a ZFS pool device and vice versa.

I tried something like 'dd if=/dev/zvol/rdsk/rpool/debianvm of=/deb.vdi' and then try to boot the deb.vdi but virtualbox is not happy about the format. I also tried the reverse as well and get a 'PBR bad Sig'.

What is the correct procedure for copying vdi images into a ZFS pool device (or extract the image from a ZFS pool device into a vdi image) ? Is it a subset of the image which needs to be copied from the device ?

many thanks,

Thierry.
kebabbert
Volunteer
Posts: 321
Joined: 31. May 2008, 10:00
Primary OS: OpenSolaris 11
VBox Version: OSE other
Guest OSses: WinXP, RedHat, Ubuntu

Re: VirtualBox and iSCSI disks

Post by kebabbert »

I dont know, but maybe this text could help? You put your zone on iSCSI, and then you fire up VirtualBox in the Zone, and install windows in Virtualbox?
http://blogs.sun.com/JeffV/entry/zoit_s ... s_on_iscsi
dgmad
Posts: 7
Joined: 21. Feb 2011, 11:06
Primary OS: Other
VBox Version: OSE other
Guest OSses: linux

Re: VirtualBox and iSCSI disks

Post by dgmad »

I tried a few more things:

i was able to convert a linux disk image into a vdi disk file using
VBoxManage convertfromraw -format VDI sda.img squeeze.vdi
and successfully boot up the VM.

however, if i try to dd the above working squeeze.vdi into an iscsi device, the corresponding VM with the iscsi drive does not boot anymore.

Thierry.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: VirtualBox and iSCSI disks

Post by mpack »

A VDI file is a not a dumb dd style image dump. It's more like a map of the drive contents. If you want to dd the drive contents you either have to use "VBoxManage clonehd --format RAW", or dd directly from drive to drive inside a guest.
dgmad
Posts: 7
Joined: 21. Feb 2011, 11:06
Primary OS: Other
VBox Version: OSE other
Guest OSses: linux

Re: VirtualBox and iSCSI disks

Post by dgmad »

Yes i've realised that the vdi format is a container and is bit different.

I have created a working vdi image but i can't figure out how to make it work ok with an iscsi target. I tried to upload the vdi file to the iscsi target device but can't boot afterwards. Does the iscsi LUN has to be of exactly the same size as the vdi file image ? The ZFS pool i use for the iscsi target has to be a multiple of the zfs pool block size so it is difficult to match the size of the vdi file. Is there a trick i can use with virtualbox to overcome this ? Is there some kind of a partition table in the vdi container ? Can the LUN size be larger than the vdi file size image ?

Thierry.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: VirtualBox and iSCSI disks

Post by mpack »

A VDI is a simulation of HDD hardware. VirtualBox knows nothing about partitions, filesystems ZFS, NTFS, etc - just like your physical drive hardware doesn't. Those are all software features.

What you are attempting to do seems strange to me - copying one self contained drive image (presumably including guest partition map), onto part of another filesystem, and I'd have thought - an incompatible file system at that, though I don't know enough about ZFS to be sure.

One thing's for sure: VDI is a high level file format intended to be used by VirtualBox and other apps that understand its structure. If the target doesn't support VDI specifically then you are wasting your time.
dgmad
Posts: 7
Joined: 21. Feb 2011, 11:06
Primary OS: Other
VBox Version: OSE other
Guest OSses: linux

Re: VirtualBox and iSCSI disks

Post by dgmad »

I'm just using ZFS as a nice and easy way to provision block devices and export them as iscsi targets which can be consumed by the virtual box iscsi initiator. A pool in ZFS has a corresponding block device which can be exported an an iscsi target.

The setup works nicely when installing linux manually from scratch in the guest OS relying on an iscsi virtual drive. I'm actually seeing the following when doing fdisk on the iscsi block device:

Total disk size is 512 cylinders
Cylinder size is 4096 (512 byte) blocks

Cylinders
Partition Status Type Start End Length %
========= ====== ============ ===== === ====== ===
1 Active Linux native 0 463 464 91
2 EXT-DOS 464 511 48 9


What i'm trying to do is to automate the populating of the content of these iscsi virtual drive using a pre-created vdi image file.

It does work with dd on the iscsi block device provided it is the linux VM i installed manually. If i try to do the same on a vdi image created with vboxmanage convertfromraw then i can't boot.

Thierry.
dgmad
Posts: 7
Joined: 21. Feb 2011, 11:06
Primary OS: Other
VBox Version: OSE other
Guest OSses: linux

Re: VirtualBox and iSCSI disks

Post by dgmad »

actually 'VBoxManage clonehd' could do the job if it was supporting iscsi drives as an output...
dgmad
Posts: 7
Joined: 21. Feb 2011, 11:06
Primary OS: Other
VBox Version: OSE other
Guest OSses: linux

Re: VirtualBox and iSCSI disks

Post by dgmad »

I can see the disk geometry is hardcoded in the vdi file. I'm wondering whether i need to edit the vdi file to reflect the disk geometry in the vdi file. I've not seen any internalcommands to change these values.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: VirtualBox and iSCSI disks

Post by mpack »

dgmad wrote:I can see the disk geometry is hardcoded in the vdi file
The disk geometry is dictated by the size of the virtual HDD. You should not be editing it unless you are enlarging the virtual drive. Some guest OS's do reflect aspects of the drive geometry in their internal data structures, e.g. Windows stores a head count in its volume boot sectors. However this a legacy feature which becomes irrelevant for drives >8GB (because the head count maxes out).
dgmad
Posts: 7
Joined: 21. Feb 2011, 11:06
Primary OS: Other
VBox Version: OSE other
Guest OSses: linux

Re: VirtualBox and iSCSI disks

Post by dgmad »

i managed to do it. actually, the iscsi disk is just the raw guest image and not the raw vdi.
Post Reply