Mapping internal (SATA, SAS, RAID, etc) disks from XenServer host to VM

In my post here, I have explained (actually – created a shell script) to map USB disks to VMs directly. While this is easy and simple, it becomes more challenging when you want to map internal SATA disks. They are not attached to the “Removable Storage” SR, and thus, behave differently.

The solution is to make them part of the “Removable Storage” group. This can be performed by adding the following two lines at the bottom of the XenServer’s /etc/udev/rules.d/50-udev.rules


ACTION=="add", KERNEL=="sdb", SYMLINK+="xapi/block/%k", RUN+="/bin/sh -c '/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&'"
ACTION=="remove", KERNEL=="sdb", RUN+="/bin/sh -c '/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&'"

Replace sdb with the device, as can be found using `cat /proc/partitions` (that way you can get the exact size, and compare it to what you expect to see). In this particular case, the device ‘sdb’ will be added to the “Removable Storage” group and then it’s all easy – just like I have described in my previous post.

I have had a great reference from here

Tags: , , ,

3 Responses to “Mapping internal (SATA, SAS, RAID, etc) disks from XenServer host to VM”

  1. John Says:

    This is working fine for me as well in Xenserver 6.5 with one exception. I am not able to install Xentools, and am stuck at the 3 drive max.

    I tried to attach another to the VM through CLI and and am getting this message “Error: Empty VBDs can only be made for type=CD”. I hunted around a bit and found what I think is the xencode here which shows the message where I am getting with what I think is the parameters. I’m not 100% sure why they are showing up “empty”.

    Any ideas on how to get past this?


  2. ez-aton Says:

    I did not try, however, I will. I wonder why you can’t install XenTools. If I were you, I would have focused on that.


  3. olivier Says:

    i could attach my sata drive adding them in local storage with the following command:
    xe sr-create content-type=user device-config:device=/dev/sdb host-uuid=”my-host-uuid” name-label=”my disk name” shared=false type=ext

    and then i created a virtualdisk in my VM.

    in fact 2 virtual disk because xen could not create a virtual disk bigger than 2.2To

Leave a Reply