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:

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

Recent Post

Unlock the Right Solutions with Confidence

At CloudSpinx, we don’t just offer services - we deliver clarity, direction, and results. Whether you're navigating cloud adoption, scaling infrastructure, or solving DevOps challenges, our seasoned experts help you make smart, strategic decisions with total confidence. Let us turn complexity into opportunity and bring your vision to life.

Leave a Comment

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

Related Post

In this tutorial we will cover step-by-step procedure of compiling Open vSwitch (OVS) from source code on Rocky Linux, AlmaLinux, […]

Open vSwitch (OVS) is an open source virtual switch widely adopted in network virtualization. OVS is popular in platforms like […]

Photoshop can be such a headache for both experts and beginners alike. Every time you open photoshop there’s always a […]

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.