VMware GSX

Using LVM as raw disks

If you want to use logical volumes as raw disks, you get stuck with VMware. Only /dev/sd* and /dev/hd* is supported. But there is a workaround for this problem. Some really tough guys in the VMware-forum have written a wrapper library to support other devices as well. You can find the original homepage here.

This little tutorial shows, how to support LVM with VMware GSX Server. Same applies to VMware Server too.

  1. get vmware-bdwrapper and compile as stated in the README
  2. mv /usr/sbin/vmware-serverd /usr/sbin/vmware-serverd.bin
  3. mv /usr/lib/vmware/bin/vmware-vmx /usr/lib/vmware/bin/vmware-vmx.bin
  4. mv /usr/lib/vmware/bin-debug/vmware-vmx /usr/lib/vmware/bin-debug/vmware-vmx.bin
  5. now write a script to /usr/sbin/vmware-serverd
    #!/bin/sh
    VMWARE_BDWRAPPER_DEVICES=/dev/sd0/test
    VMWARE_BDWRAPPER_LOG_LEVEL=-1
    LD_PRELOAD=libvmware-bdwrapper.so.0
    export LD_PRELOAD VMWARE_BDWRAPPER_DEVICES VMWARE_BDWRAPPER_LOG_LEVEL
    exec "$0.bin" "$@"
  6. hardlink this script to the vmware-vmx locations
    ln /usr/sbin/vmware-serverd /usr/lib/vmware/bin/vmware-vmx
    ln /usr/sbin/vmware-serverd /usr/lib/vmware/bin-debug/vmware-vmx
Now you are able to use LVM devices as raw disk. I recommend to name the volumegroups as sd0, sd1, sd2 and so on. You have to use sd as prefix, if you want to use other devices.

Wildcards with vmware-bdwrapper

The library vmware-bdwrapper doesn't support wildcards in version 20060304-0. A little tweak helps, here is the patch:

--- vmware-bdwrapper-20060304-0/vmware-bdwrapper.c      2006-03-04 00:06:36.000000000 +0100
+++ vmware-bdwrapper-20060304-0.smay/vmware-bdwrapper.c 2006-05-25 12:42:28.102319351 +0200
@@ -218,8 +218,15 @@
   int i;
   for (i = 0; i < devices_to_be_tweaked__size(); i++) {
-    if (strcmp(device_file_name, devices_to_be_tweaked__data_[i]) == 0)
-      return i;
+    int length = strlen(devices_to_be_tweaked__data_[i]);
+    if (devices_to_be_tweaked__data_[i][length-1] == '*') {
+      if (strncmp(device_file_name, devices_to_be_tweaked__data_[i], length - 1) == 0)
+       return i;
+    }
+    else {
+      if (strcmp(device_file_name, devices_to_be_tweaked__data_[i]) == 0)
+        return i;
+    }
   }
   return -1;

Just apply the patch and compile as described in README. After that you can specify device-names with a star * as postfix.

Links