Home > Linux, Server > Xenserver detach and re-attach a local storage repository separate disk

Xenserver detach and re-attach a local storage repository separate disk

Googling I found that would be useful to add instructions on how to detach and re-attach a local storage ( separate disk ) to XenServer.  It is necessary to use command line interface (CLI).

We can see Storage Repository using xe sr-list:

# xe sr-list
uuid ( RO)                : 37239476-c08f-ad02-c776-77830c73d6c6
          name-label ( RW): Local storage
    name-description ( RW): 
                host ( RO): xs-602
                type ( RO): lvm
        content-type ( RO): user

uuid ( RO)                : 38faf3c9-f7ab-a8b6-4fb9-80a4745c2b05
          name-label ( RW): sr xenserver 5
    name-description ( RW): 
                host ( RO): xs-602
                type ( RO): lvm
        content-type ( RO): user

uuid ( RO)                : c425f5fb-1e60-685c-0a1c-6cc11a0087b7
          name-label ( RW): DVD drives
    name-description ( RW): Physical DVD drives
                host ( RO): xs-602
                type ( RO): udev
        content-type ( RO): iso
...
...

Add a Local Storage Repository ( SR )

To add a Local Storage Repository check the SR available in the host using pv display. We can see the default XenServer Local SR and if there are others disks attached others SR. Disks  maybe temporary attached and with full XenServer installation,too.

# pvdisplay

  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               VG_XenStorage-37239476-c08f-ad02-c776-77830c73d6c6
  PV Size               290.09 GB / not usable 7.81 MB
  Allocatable           yes 
  PE Size (KByte)       4096
  Total PE              74260
  Free PE               17919
  Allocated PE          56341
  PV UUID               fOijAs-Dyb0-IUvH-5UzC-ivnj-Jx4u-c51TzT

  --- Physical volume ---
  PV Name               /dev/sdb3
  VG Name               VG_XenStorage-4f9d6505-0f10-5e08-9629-4a4813ec57a7
  PV Size               1.81 TB / not usable 8.06 MB
  Allocatable           yes 
  PE Size (KByte)       4096
  Total PE              474881
  Free PE               414464
  Allocated PE          60417
  PV UUID               JI2nT4-Aaj3-XIns-jpPy-YSJ6-isSV-9wkTsm

We can see two LVM volumes. The first, in sda disk, is the main XenServer  local SR, the second is 1.8 TB LVM volume in sdb disk. To attach SR is necessary :

  • recognize the Storage Repository in XenServer 
  • create the SR physical block device (PBD)
  • then plug the PBD to XenServer

Let the Storage Repository recognizable using xe sr-introduce

[root@xs61 ~]# xe sr-introduce uuid=4f9d6505-0f10-5e08-9629-4a4813ec57a7 type=lvm name-label="sr-l-T18" content-type=user
4f9d6505-0f10-5e08-9629-4a4813ec57a7

Now we can see  SR  in XenCenter and it will be marked as Detached.

We have to create the  PBD ( physical block device)  using xe pdb-create command. To use the command, you need the host uuid  and  device name of the partition.

xe host-list
uuid ( RO)                : 6acdd0f6-cad4-4d46-b852-16c645e6c8b5
          name-label ( RW): xs-602
    name-description ( RW): Default install of XenServer

To know the  /dev/sdb3 devicename we can use  ls -l /dev/disk/by-id

[root@xs61 ~]# ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Jan 13 13:57 scsi-SATA_WDC_WD20EARX-00_WD-WCAZAJ973153 -> ../../sdb
lrwxrwxrwx 1 root root 10 Jan 13 13:57 scsi-SATA_WDC_WD20EARX-00_WD-WCAZAJ973153-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Jan 13 13:57 scsi-SATA_WDC_WD20EARX-00_WD-WCAZAJ973153-part2 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Jan 13 13:57 scsi-SATA_WDC_WD20EARX-00_WD-WCAZAJ973153-part3 -> ../../sdb3
lrwxrwxrwx 1 root root 10 Jan 13 13:57 scsi-SATA_WDC_WD20EARX-00_WD-WCAZAJ973153-part4 -> ../../sdb4
lrwxrwxrwx 1 root root  9 Jan 13 13:57 scsi-SATA_WDC_WD3201ABYS-_WD-WCARW3003070 -> ../../sda
lrwxrwxrwx 1 root root 10 Jan 13 13:57 scsi-SATA_WDC_WD3201ABYS-_WD-WCARW3003070-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jan 13 13:57 scsi-SATA_WDC_WD3201ABYS-_WD-WCARW3003070-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jan 13 13:57 scsi-SATA_WDC_WD3201ABYS-_WD-WCARW3003070-part3 -> ../../sda3
lrwxrwxrwx 1 root root  9 Jan 13 13:57 usb-Generic_USB_CF_Reader_058F312D81B -> ../../sdd
lrwxrwxrwx 1 root root  9 Jan 13 13:57 usb-Generic_USB_MS_Reader_058F312D81B -> ../../sdf
...

The PBD  is created using  xe pbd-create

#  xe pbd-create host-uuid=6acdd0f6-cad4-4d46-b852-16c645e6c8b5 sr-uuid=4f9d6505-0f10-5e08-9629-4a4813ec57a7 device-config:device=/dev/disk/by-id/scsi-SATA_WDC_WD20EARX-00_WD-WCAZAJ973153-part3
7c37bb56-ee51-19b1-3df0-a5a4df9b385a

Then we can connect with  xe pbd-plug

# xe pbd-plug uuid=7c37bb56-ee51-19b1-3df0-a5a4df9b385a

Remove a  Storage Repository

To remove the Storage Repository added SR-uuid= 4f9d6505-0f10-5e08-9629-4a4813ec57a7  we have to reverse  the actions previosuly made.

  • unplung the Storage Repository PBD ( physical block device ) using pbd-unplug
  • then remove SR with  sr-forget

We can list PBD using xe pbd-list

[root@localhost ~]# xe pbd-list
uuid ( RO)                  : 2513bd51-bce5-18a5-040f-64ccf6822aec
             host-uuid ( RO): 6acdd0f6-cad4-4d46-b852-16c645e6c8b5
               sr-uuid ( RO): 66c01d4b-911d-8cfd-d5a0-d78a5ad2f732
         device-config (MRO): location: /dev/xapi/block
    currently-attached ( RO): true

uuid ( RO)                  : 8bb8f425-59ff-e8b2-edf2-627708adcfb2
             host-uuid ( RO): 6acdd0f6-cad4-4d46-b852-16c645e6c8b5
               sr-uuid ( RO): c425f5fb-1e60-685c-0a1c-6cc11a0087b7
         device-config (MRO): location: /dev/xapi/cd
    currently-attached ( RO): true

uuid ( RO)                  : 7c37bb56-ee51-19b1-3df0-a5a4df9b385a
             host-uuid ( RO): 6acdd0f6-cad4-4d46-b852-16c645e6c8b5
               sr-uuid ( RO): 4f9d6505-0f10-5e08-9629-4a4813ec57a7
         device-config (MRO): device: /dev/disk/by-id/scsi-SATA_WDC_WD20EARX-00_WD-WCAZAJ973153-part3
    currently-attached ( RO): true

uuid ( RO)                  : 52449e07-4f89-bc68-1a8e-3887b74cb875
             host-uuid ( RO): 6acdd0f6-cad4-4d46-b852-16c645e6c8b5
               sr-uuid ( RO): 37239476-c08f-ad02-c776-77830c73d6c6
         device-config (MRO): device: /dev/disk/by-id/scsi-SATA_WDC_WD3201ABYS-_WD-WCARW3003070-part3
    currently-attached ( RO): true
...
..

Unplug  PBD with

xe pbd-unplug uuid=7c37bb56-ee51-19b1-3df0-a5a4df9b385a

Remove Storage Repository using

xe sr-forget uuid=4f9d6505-0f10-5e08-9629-4a4813ec57a7

Create  a new Storage Repository

To create a new Storage Repository when you add a new disk you have to use the command xe sr-create. The command in question is an extremely dangerous command because it deletes the data on the partition or disk ( So beware).

The command syntax is:

xe sr-create name-label=<name> physical-size=<size> type=<type> content-type=<content_type> device-config:<config_name>=<value> [host-uuid=<Xen Cloud Platform host UUID>] [shared=<true | false>]

To check the disks accessible from XenServer use fdisk -l


[root@localhost ~]# fdisk -l

Disk /dev/sda: 320.0 GB, 320072933376 bytes
...  boot drive  ...

Disk /dev/sdb: 2000.3 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
...

To get the UUID of the host refer to xe host-list

[root@localhost ~]# xe host-list
uuid ( RO)                : 6acdd0f6-cad4-4d46-b852-16c645e6c8b5
          name-label ( RW): xs-602
    name-description ( RW): Default install of XenServer
Qualora si aggiunga un nuovo disco a XenServer per utilizzarlo come un nuovo Storage Repository (SR ) .

Create a new Storage Repository using a command like

xe sr-create name-label="xenloc2-2TBWD" type=lvm content-type=user device-config:device=/dev/sdb host-uuid=6acdd0f6-cad4-4d46-b852-16c645e6c8b5

Glossario

dom0  =  privileged domain. It ‘s the Virtual Machine (VM) created by the hypervisor XenServe at boot. The privileged domain is the one that has direct access to the hardware and is responsible for launching other VM.
domU = unprivileged domU domain. All other instances of the virtual machine (VM) running other than dom0 are dominioU: it’is created a separate domain for each instance.
Host:  the machine running XenServer
Guest: a Virtual Machine  running in XenServer.
VM : Virtual Machine in XenServer is identified by a specific uuid and hosted on a Virtual Disk Image with its own vdi-uuid and is connected to dom0 via a VBD with his vdb-uuid.
VDI:   Virtual Disk Image, the image or file is a virtual hard disk.
VDB: Virtual Block Device, a way to connect a VDI to a virtual machine
UUID: Universally unique identifier. A string of characters that XenServer, in this case, use to uniquely identify an object. You can read more at http://en.wikipedia.org/wiki/UUID

Altre risorse nle blog:


		
  1. Non c'è ancora nessun commento.
  1. No trackbacks yet.

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: