Attaching disk to XenServer Guest
It is possible to attach a hard disk directly to a XenServer guest.
I use this so I can always read these disks with another Windows Server, whenever the XenServer host would fail completely.
By changing the udev rules, it is possible to make XenServer attach a local disk as if it was a Removable Disk. With a USB device, XenServer does this automaticly.
First, let’s write those udev rules needed for our local disk.
A udev rule has several parts. One part is to define the device for which the rule is applicable, another part is to run a script.
When you define the device, it is necessary to be as precise as possible, so let’s see what criteria you can use with that particular device:
“udevinfo -a -p /sys/block/sda” Change sda with your drive.
With this info, you can write your rules.
The base rules are these ones:
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&’”
They will only validate the device by their name the kernel gives them “KERNEL==”sdb”".
This can be good enough, but I prefer to put some more information in it. Here are my rules:
ACTION==”add”, ID==”1:0:0:0″, SYSFS{model}==”SAMSUNG HD103UJ “, SYMLINK+=”xapi/block/%k”, RUN+=”/bin/sh -c ‘/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&’”
ACTION==”remove”, ID==”1:0:0:0″, SYSFS{model}==”SAMSUNG HD103UJ “, RUN+=”/bin/sh -c ‘/opt/xensource/libexec/local-device-change %k 2>&1 >/dev/null&’”
Now, edit the file /etc/udev/rules.d/50-udev.rules and add those lines to the bottom.
Now you can test those rules by running: “udevtest /block/sda”. And if everything seems ok, reboot the server and your disks should appear in the “Removable storage” library.
For more information please go to the following urls:
Red Hat Magazine – Writing Custom udev Rules
Writing udev rules by Daniel Drake
Thanks to http://www.ezgr.net/
Thanks .
It was very helpful information
Does this olso work the same way in Xenserver 6??
I am trying to add an raid array to a windows VM (/dev/cciss/c0d2), but all i got is “Unrecognised bus type”.
@ctdekoe1990
Didn’t try this in Xenserver 6 as I’m not using this anymore.
Is your array appearing in the “Removable Storage” library in XenServer?
Are you getting the “Unrecognised bus type” in windows or xenserver?