Remove Storage Repository on Xen|XCP-ng from CLI

In this article we describe how you can remove a Storage Repository (SR) on XenServer / XCP-ng host when the Storage Repository is experiencing issues, all from the command line interface. A Storage Repository is used to store Virtual Machine (VM) Virtual Disks (VDIs) or Operating system ISO files.

The Storage Repository is connected to XenServer or XCP-ng host through a Physical Block Device (PBD) which contains the configuration for the Storage Repository. For this operation you’ll need access to the host terminal console, via SSH or serial interface.

Login to your XenServer or XCP-ng Virtualization host:

ssh root@xenserver_or_xcp-ng_ip

Once you have a terminal access list all available Storage repositories:

# xe sr-list

You can filter the output using grep command, in this example we extract ISO Library repository information:

# xe sr-list  | grep "ISO library" -B 1 -A3
uuid ( RO)                : a52e773e-a46f-6998-9029-01e8058b954b
          name-label ( RW): NFS ISO library
    name-description ( RW): NFS ISO Library [192.168.20.11:/mnt/isos]
                host ( RO): xcp-node-01
                type ( RO): iso

As seen from the output this is an NFS storage repository on 192.168.20.11:/mnt/isos.

Run the following command to find the UUID of the PBD. The SR UUID should match the results from xe sr-list for a specific SR being worked on.

xe pbd-list sr-uuid=<UUID of SR>

Example:

# xe pbd-list sr-uuid=a52e773e-a46f-6998-9029-01e8058b954b
uuid ( RO)                  : 7ea64444-a7ac-f113-da47-e47570fd17fe
             host-uuid ( RO): d58b8b54-114d-43c7-8d32-988bde2d352b
               sr-uuid ( RO): a52e773e-a46f-6998-9029-01e8058b954b
         device-config (MRO): nfsversion: 4; type: nfs_iso; location: 62.12.114.59:/mnt/isos
    currently-attached ( RO): true

This gives you UUID of the PBD.

You’ll need to disconnect the PBD before you detach or remove the Storage Repository from the XenServer host. Run the following command to unplug PBD:

# xe pbd-unplug uuid=<UUID of PBD>

# In my case this will be:
# xe pbd-unplug uuid=7ea64444-a7ac-f113-da47-e47570fd17fe

You can now remove storage repository by running the following command:

# xe sr-forget uuid=<UUID of SR>

In my setup this will be:

# xe sr-forget uuid=a52e773e-a46f-6998-9029-01e8058b954b

Executing above command is equivalent to right clicking the Storage Repository on the XenCenter Interface and selecting Forget.

The same process can be performed from XenCenter or Xen Orchestra web interface.

More articles:

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

GNS3 community is the world’s largest community of network professionals who love building better networks, sharing ideas and making connections […]

In this guide we will perform an installation of XCP-ng VM or guest tools on Ubuntu | Debian Linux system. […]

Extra Packages for Enterprise Linux (EPEL) is repository with a high quality set of additional packages for Enterprise Linux operating […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.