How to check used local storage repository disk-space on XenServer Linux

Objective

Our objective is to check a disk space usage of one or more local XenServer repositories using Linux shell command line.

Requirements

Remote SSH access to XenServer is required to complete this task.

Difficulty

EASY

Instructions

SSH Login Login

First step is to gain a privileged access to you XenServer using SSH:

$ ssh root@XENSERVER

List Storage Repositories

In this step we are going to list all available storage repositories in order to obtain relevant UUID belonging to the storage repository in question. The below command will display all storage repositories on your XenServer:

# xe sr-list
uuid ( RO)                : 132b9e6a-1798-bfcb-fb79-37be7ee8bf93
          name-label ( RW): Removable storage
    name-description ( RW): 
                host ( RO): xenserver
                type ( RO): udev
        content-type ( RO): disk


uuid ( RO)                : 970317f9-3187-b5e0-1ea5-16666fdf3348
          name-label ( RW): ISO_IMAGES_LOCAL
    name-description ( RW): 
                host ( RO): xenserver
                type ( RO): iso
        content-type ( RO): iso


uuid ( RO)                : 01533e0e-6c17-36fa-c987-2d29f355ef6e
          name-label ( RW): XenServer Tools
    name-description ( RW): XenServer Tools ISOs
                host ( RO): xenserver
                type ( RO): iso
        content-type ( RO): iso


uuid ( RO)                : bdafe018-617d-5c49-6488-c81c01d40f21
          name-label ( RW): Local storage
    name-description ( RW): 
                host ( RO): xenserver
                type ( RO): ext
        content-type ( RO): user


uuid ( RO)                : 9ea646ec-2795-a579-4668-e0f779402ca6
          name-label ( RW): DVD drives
    name-description ( RW): Physical DVD drives
                host ( RO): xenserver
                type ( RO): udev
        content-type ( RO): iso

You output will differ. First, look for a storage repository name you wish to check disk usage on. In our case it is name-label ( RW): Local storage with a corresponding uuid ( RO) : bdafe018-617d-5c49-6488-c81c01d40f21.

Check Free/Used disk-space

Now that we have obtained a relevant UUID of the local storage repository we can obtain free disk-space availability using df command:

# df -h /run/sr-mount/bdafe018-617d-5c49-6488-c81c01d40f21
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/XSLocalEXT--bXX   70G  180M   66G   1% /run/sr-mount/bdafe018-617d-5c49-6488-c81c01d40f21

Alternatively we can chek for disk-space used by executing du command:

# du -sh /run/sr-mount/bdafe018-617d-5c49-6488-c81c01d40f21
44K     /run/sr-mount/bdafe018-617d-5c49-6488-c81c01d40f21


Comments and Discussions
Linux Forum