It is easy to add new blank disk drives to XenServer and use them as new Storage Repositories (SR). See this article how to do that. Sometimes however it is required to add a disk drive and preserve the data on it:

a XenServer with one or more additional disk drives is reinstalled or upgraded.

a disk with a Storage Repository is moved to a different XenServer.

Reattach the disk drive to XenServer

Scenario: The disk drive /dev/sda contains a new XenServer installation, a second disk drive /dev/sdb from some other XenServer has been added to the server and contains a SR with some data, for example virtual machines or virtual disks.

The first step is to run the pvdisplay command. This will show what is available on the physical disks. We see that the second disk contains one physical LVM volume with 1.5 TByte of data.

The new SR will now show up in XenCenter but it is still marked as "Detached". We still have to connect the physical block device (PBD) with the SR. This is done by running the xe pbd-create command which needs the device name (so we run ls -l /dev/disk/by-id to find this out) and the host-uuid (we run xe host-list to get this). In this case, the partition on the physical block device we want to reconnect is /dev/sdb1. The corresponding disk id is scsi-SATA_SAMSUNG_HD154UIS24EJ9BZB02485-part1 which is used in the device-config parameter in the xe pbd-create command.

Finally, we need to activate the whole thing by executing xe pdb-plug.

The SR should now be usable in XenCenter control panel. However, note that all names and descriptions of the partitions as well as their associations with virtual machines are unavailable, because this meta data is stored somewhere else.

Remove a disk from XenServer

To remove a disk from XenServer, we have to reverse the actions described above: disconnect the PBD from the SR using xe pdb-unplug, then forget about the SR using xe sr-forget. Use xe pbd-list and xe sr-list to find out the respective uuids.

Anonymous

Thanks for this amazing tutorial. it helps me from a desaster loosing my vms. i got a xenserver pool with two hosts connected to a fibrechannel san. Now the lun is connected to only one server as a local reposity. what do I have to change to connect it as a pool reposity ?

Anonymous

Me again, I found a solution by myself because of lack of time It is quite a simple switch. the command has to be run on pool master and I added shared=true within the sr-introduce command and within the pbd-create command a multihomed and shared switch in the decive-config section seen as below. Hope this will help anyone having the same headace as I had