Add a second disk as Local Disk Storage to an existing XenServer

On each of the XenServers in the pool I created,  I have at least 2 partitions that I wanted to be available to my VMs.

For a little while I was just running individual commands to figure it out each time and finally I decided to come up with a single command that I could copy and paste

I have it below so I can always come to this blog post and find it

First I find out which partition I want to add

#cat /proc/partitions

I just have to replace the /dev/sdb in the command below with the actual partition I want to add,  And I might need to change the “name-label” in the case that I already have a Local storage 2,  but otherwise,  the system figures out what the current hostname is and gets the uuid and names the storage appropriately.  This works in a pool where host-list returns more than one..

CAUTION:  when cutting and pasting from below,  be careful to make sure that the quotes match exactly,   I have run into situations where the Double Quotes(“) around the name-label parameter and the single quotes (‘) around the awk parameter,  show as question marks (?) when pasted into the XenCenter console.

#xe sr-create content-type=user device-config:device=/dev/sdb  host-uuid=`grep -B1 -f /etc/hostname <(xe host-list)|head -n1|awk ‘{print $NF}’` name-label=”Local storage 2 on `cat /etc/hostname`” shared=false type=lvm