How to add and remove local storage repository in xenserver

To add and remove local storage repository in xenserver

A XenServer Storage Repository is used to Store ISOs or Virtual Machine (VM) Virtual Disks (VDIs). The Storage Repository is connected to a XenServer through a Physical Block Device (PBD) which contains the configuration for the Storage Repository. Steps to add and remove local storage repository in xenserver is explained in this article.


To Create storage repository

First create storage directory by using “ mkdir” command.

[root@xenSR-linuxhelp ~]# mkdir local
[root@xenSR-linuxhelp ~]# mkdir local/ISO

Then list the all storage repositories using “ xe sr-list” command like below.

[root@xenSR-linuxhelp ~]# xe sr-list
uuid ( RO)                : e6d251f9-365b-6d46-5d64-deb236540298
          name-label ( RW): DVD drives
    name-description ( RW): Physical DVD drives
                host ( RO): xenSR-linuxhelp
                type ( RO): udev
        content-type ( RO): iso

uuid ( RO)                : 0c7778a7-4c08-87d5-72bd-1020fdf445f4
          name-label ( RW): Local storage
    name-description ( RW):
                host ( RO): xenSR-linuxhelp
                type ( RO): ext
        content-type ( RO): user
uuid ( RO)                : efb3a8d3-b553-305d-b3aa-048147e895dc
          name-label ( RW): Removable storage
    name-description ( RW):
                host ( RO): xenSR-linuxhelp
                type ( RO): udev
        content-type ( RO): disk

uuid ( RO)                : 645fc1db-7400-03e6-c33c-0d16f325a229
          name-label ( RW): XenServer Tools
    name-description ( RW): XenServer Tools ISOs
                host ( RO): xenSR-linuxhelp
                type ( RO): iso
        content-type ( RO): iso

Create storage repository by using following command..

[root@xenSR-linuxhelp ~]# xe sr-create name-label=repo-local type=iso device-config:legacy_mode=true device-config:location=/root/local/ISO content-type=iso
7ac13a79-e5ef-eb9f-d7f8-326d1bb228de

It creates a UUID for new storage repository.

Next list storage repository using “ xe sr-list ” command.

[root@xenSR-linuxhelp ~]# xe sr-list
uuid ( RO)                : e6d251f9-365b-6d46-5d64-deb236540298
          name-label ( RW): DVD drives
    name-description ( RW): Physical DVD drives
                host ( RO): xenSR-linuxhelp
                type ( RO): udev
        content-type ( RO): iso

uuid ( RO)                : 0c7778a7-4c08-87d5-72bd-1020fdf445f4
          name-label ( RW): Local storage
    name-description ( RW):
                host ( RO): xenSR-linuxhelp
                type ( RO): ext
        content-type ( RO): user

uuid ( RO)                : efb3a8d3-b553-305d-b3aa-048147e895dc
          name-label ( RW): Removable storage
    name-description ( RW):
                host ( RO): xenSR-linuxhelp
                type ( RO): udev
        content-type ( RO): disk

uuid ( RO)                : 645fc1db-7400-03e6-c33c-0d16f325a229
          name-label ( RW): XenServer Tools
    name-description ( RW): XenServer Tools ISOs
                host ( RO): xenSR-linuxhelp
                type ( RO): iso
        content-type ( RO): iso

uuid ( RO)                : 7ac13a79-e5ef-eb9f-d7f8-326d1bb228de
          name-label ( RW): repo-local
    name-description ( RW):
                host ( RO): xenSR-linuxhelp
                type ( RO): iso
        content-type ( RO): iso

Check UUID for which storage repository you want to remove. By using “ xe sr-list name-label=” command.

[root@xenSR-linuxhelp ~]# xe sr-list name-label=repo-local
uuid ( RO)                : 7ac13a79-e5ef-eb9f-d7f8-326d1bb228de
          name-label ( RW): repo-local
    name-description ( RW):
                host ( RO): xenSR-linuxhelp
                type ( RO): iso
        content-type ( RO): iso

Check UUID for pbd of that selected storage repository. By using UUID of that local storage repo.

root@xenSR-linuxhelp ~]# xe pbd-list sr-uuid=7ac13a79-e5ef-eb9f-d7f8-326d1bb228de
uuid ( RO)                  : 59679f4b-a66b-c621-3297-1990f2e467a9
             host-uuid ( RO): 1b2265f8-06fb-4980-8415-371e627efefb
               sr-uuid ( RO): 7ac13a79-e5ef-eb9f-d7f8-326d1bb228de
         device-config (MRO): legacy_mode: true  location: /root/local/ISO
    currently-attached ( RO): true

This command shows UUID of “ repo-local” storage pbd. Pbd means physical block device. Storage repository directly connect to xensever with the help of pbd. Unplug the pbd of storage repo from xenserver. “ Xe pbd-unplug” command can help to unplug it.

[root@xenSR-linuxhelp ~]# xe pbd-unplug uuid=59679f4b-a66b-c621-3297-1990f2e467a9


Then run the following command to remove that storage repo.

[root@xenSR-linuxhelp ~]# xe sr-forget uuid=7ac13a79-e5ef-eb9f-d7f8-326d1bb228de


Here the uuid is the storage repository uuid.

FAQ
Q
It is advisable to make the changes in UUID for the particular virtual Disk in xen-server?
A
Duplicated UUID's can be a big problem on your machine. The most notable being your /etc/fstab file, which manages the mounting of partitions at boot time.
Q
What is mean by the "sr-list" that had mentioned in a document for xen-server?
A
It is nothing but server list in xen-server.
Q
Is it possible for able to suspend for the virtual disk in temporarily on xen-server?
A
You can't make the suspend functionality but still you can only to make the process of creating and delete the disk.
Q
What is mean by the Virtual?
A
It's about the thing that not existing in physically and made by the application to do the same functionality as real.
Q
How can I create the storage repository in xen-server?
A
Run following command to create the storage repository as "xe sr-create name-label=repo-local type=iso device-config:legacy_mode=true device-config:location=/root/local/ISO content-type=iso