I'm investigating how to deliver our network print appliance as a vmware appliance.
We build the linux based os from a script whichn generates boot, root and configuration partitons as raw images.
These can be pulled together in a disk image created using standard unix tools like dd and fdisk.
I found that you can use qemu-img to convert that raw disk image into a vmware 3 or 4 compatible image.
My problem is that this presents as an ide disk which would require us to rewrite our software
Is there a tool i can use offline to create a scsi vmdk image from a raw disk image?
thanks, seb james
You can convert the disk using vmkfstools or vmware-vdiskmanager (depending on the VMware product you use).
Hi there,
Thanks for the quick reply. I was writing my initial post on a small mobile device, and omitted to mention that I'd looked at vmware-vdiskmanager - I'm using VMWare Server 1.0.6 to run my virtual machines. I haven't managed to find the vmkfstools download; perhaps this is part of a different vmware product, as your message suggests.
I did investigate vmware-vdiskmanager - it seems to allow me to create a vmdk, but doesn't seem to have the ability to either create the vmdk from a raw disk image (such that the vmdk would contain the data in the raw disk image) or to manipulate the new vmdk after creation - that is to create partitions, copy data, get a bootloader installed.
Having had a look at the documentation for the disk development kit, it seems I can use the C++ api to create a vmdk, then copy data across, so I will try to:
1) Create vmdk
2) Copy data, bit for bit, from my raw disk image into the vmdk, using the C++ api
I'd prefer not to have to write this (admittedly small) program, so any suggestions to alternative methods would be gratefully received!
Thanks again,
Seb James
vmkfstools is part of ESX.
You need the convert function of vmware-vdiskmanager.
Hi, thanks again from the prompt reply.
The -r <source-disk> feature in vmware-vdiskmanager won't convert from my raw disk image file:
$ vmware-vdiskmanager -r rootfs.raw -t0 test2.vmdk
Using log file /tmp/vmware-seb/vdiskmanager.log
Failed to open the disk 'rootfs.raw' : The file specified is not a virtual disk (15).
The example given in the usage instructions for vmware-vdiskmanager imply that the source disk must itself be a vmdk disk image:
ex 3: vmware-vdiskmanager -r sourceDisk.vmdk -t 0 destinationDisk.vmdk
I have successfully modified the vix-disklib-sample to copy a raw image into a new vmdk file, so I'm in business now. It's a simple job to rewrite the DoFill() function in vixDiskLibSample.cpp to copy data from the raw image file into the vmdk.
Cheers,
Seb James
So you are using a complete raw disk instead of a raw partition...
That's correct. We already build our network appliance with an embedded Linux OS, which lives on 4 partitions of a disk. To create a vmdk of the appliance, I've modified our existing build scripts to create a disk image (dd if=/dev/zero of=.....etc) then partition it (using sfdisk) then make and populate filesystems on the partitions (mkfs.* and tar -xf to populate or copy in a squashfs image using dd) then install a bootloader into the image.
Apart from installing the bootloader, which I still have to do within the vmware image using a Linux LiveCD, this is all working now, and I just booted our first vmware appliance! The bootloader issue is not a vmware problem.
Thanks,
Seb James
Established that there is no tool to convert a raw disk image into a vmware vmdk image, but that it is simple to modify vixDiskLibSample.cpp from vmware-vix-disklib-distrib to copy a raw disk image into a newly created vmdk.
It is probably easier to add a VMDK of the desired size to the VM and image the disk (using Ghost, dd, ...).
It is probably easier to add a VMDK of the desired size to the VM and image the disk (using Ghost, dd, ...).
I want my "build a vmware appliance" script to run entirely outside the vmware environment.
qemu-img --help
'-s' indicates that the target image must use of type SCSI (vmdk format only)
$ qemu-img convert -s -f raw diskimage.img -O vmdk scscidisk.vmdk
That's useful information, thanks for posting. The version of qemu-img I
was using didn't have that feature (it was 0.8.2 from Debian Etch).
That's not in the official source... Do you have a patch for that?
The patch is included in Ubuntu. See http://www.mail-archive.com/qemu-devel@nongnu.org/msg15054.html