How to create a local ISO repository in XCP-ng

Even if the best practice is to create an ISO "store" on a network share, sometimes you don't have the choice: you need a local SR ISO.

Context

Obviously, if you can use an NFS or SMB share to store your ISO, this is the way to go. But if you have a single host, or no external network access, you might need to create a local ISO storage repository. This way, you can create your VMs with an ISO stored locally.

However, before doing that, please read very carefully the following message:

⚠️
Dropping ISOs on your Dom0 will eat your local system space. Please be VERY careful on the space left, otherwise if you fill the root partition, you will break multiple things: no more logs, no more API calls possible, and so on.

You have two options:

  • create it via Xen Orchestra (easiest way)
  • on the command line

Let's see both options!

Via Xen Orchestra

Xen Orchestra is the de facto standard client to manage your XCP-ng hosts. If you do not have it yet, go deploy your XOA now!

Quick'n dirty

Here is the easiest way to achieve it. In Xen Orchestra, left main menu, go into "+ New", then "Storage". Select your host, then fill the form:

  • Host: the host you want to create the local ISO SR
  • Name/description: the name label and description of your ISO SR (you can change it anytime later)
  • Storage type: ISO SR/Local
  • Path: /media

So why /media ? The folder already exists, and nothing else should be added in there.

Click on "Create" and you are done:

Note: the space left is the real space left on your root partition. Take care to NEVER fill it!

Upload your ISO

Now you can import your favorite distro ISO via Xen Orchestra directly: in the left menu, go in "Import", then "Disk", select your freshly created ISOs SR and then drag & drop your ISO:

Upload your ISO directly inside Xen Orchestra
ℹ️
If you want to "refresh" when you uploaded an ISO, go in the SR view and click on "Rescan all disks" button (top-right in the action bar).

Want a specific folder?

If you want to put your ISOs in a specific folder, you need to SSH to your host. Then, create your ISO directory, for example:

mkdir -p /var/opt/xen/ISO_Store

After that, when you create it with Xen Orchestra, just use this path.

Via the command line

So it starts by creating the folder you want, or directly creating the SR via xe CLI.

If you want to create a specific dedicated folder, go with this for example:

mkdir -p /var/opt/xen/ISO_Store

Then, you can create the ISO SR:

xe sr-create name-label=LocalISO type=iso device-config:location=/var/opt/xen/ISO_Store device-config:legacy_mode=true content-type=iso
💡
For uploading your ISOs, you can use Xen Orchestra (see the previous section) or do a manual scp/SSH copy on your XCP-ng host. But remember to keep an eye on disk usage. Rescan the SR to refresh after the transfer/upload is done in order to see it.

Network share: a better place for your ISOs

Ideally, you should really use a network share for deploying your ISOs. As soon you have more than one host, it's more efficient to have one place to put them all.

Also, it won't use any bit of space on your local installation, and you can keep a centralize source of content regardless how big is your infrastructure.

And it's also very simple to create: in Xen Orchestra, that's almost the same operation, but insteadon "Local", select "NFS ISO" or "SMB", put the share name and… that's it! Same thing to upload, so it's really trivial and more secure than using ISO locally.