Xenserver Hard Drive / Whole Disk Passthrough with XCP-NG

Log into the XCP-NG host and use lsblk to find disks available

On the XCP-NG host create a directory under /srv/ where you will be linking the drives

mkdir /srv/pass_drives

Create symbolic links to the drives within the created directory, this example uses sda and sdb. Be careful not to use a drive in use either XCP-NG or any other local storage setup.

ln -s /dev/sda /srv/pass_drives/sda
ln -s /dev/sdb /srv/pass_drives/sdb

Create the storage repository

xe sr-create name-label=Pass_Drives type=udev content-type=disk device-config:location=/srv/pass_drives

The drives should show up inside of XenOrchestra, if not choose “Rescan All Disks” option at the top of the storage page for the new SR.

4 Likes

How would I do this with an optical drive? Tried with the same procedure but having some trouble. Thanks!

The best way to load ISO files is not through the optical drive but via adding an ISO SR ( ISO image storage repository)

Absolutely, I agree. However, I am beginning to rip my movie collect for Plex and it would be nice to use a VM on a more powerful server rather than my laptop. So I am trying to pass through DVDs to be ripped by software on a VM. Is this something that’s even possible? Appreciate your help Tom!

I am sure it’s possible, but I have never tested it.

Most hypervisors support hardware pass-through such as a DVD natively. I usually console to a VM and from their I can mount a host DVD drive to a VM. If that is not an option, PCI pass-through might be your answer. https://github.com/xcp-ng/xcp/wiki/PCI-Passtrough

Is there any way to use /dev/disk/by-id instead of /dev/sdX? /dev/sd can change the disks and then it won’t pass through the right disk. When I tried this, it just gave me an error in xen-orchestra that it’s not not the right bus type, even though it’s the same as /dev/sdX. Does XCP-NG not follow links?

Thanks, FredFerrell! This is what I needed to do. However, I had to purchase a separate SATA PCI card, connect the Blu-ray drive to that card and pass that PCI slot through to the VM. It worked perfectly. Thanks again!

2 Likes

is there a way to remove a certain drive from the pass-through list, a drive got degraded in freenas and i had to remove it physically so i could boot up, but freenas can’t see my hds in the right order now :frowning:

Edit: solution is to remove the link that was made in the pass-through folder

I have followed the instructions but not able to see the drives in the storage repository “Pass_Drives” in xen orchestra or xcp-nc center.
I see the drives in the console when i type “lsblk”.
I can use cfdisk and see the drives sizes there.
The simbolic links are made and checked in the console.
The storage repository “Pass_Drives” is made and visible in xen orchestra and xcp-nc center.
Also the rescan is not working.
Has somebody a clue what i am missing?

xcp-ng version 8.1
xpc-ng center version 20.40.00

am I going through the right way?
I connected a second disk in EXT everything is ok it is visible in the storage list

if I would like to add a local iso library on the installation disk by any problem I create a directory /opt/isoslib (for example) and I give the path in xoa

the problem is that my directory is on the first disk, I would prefer to have it on the second disk

my system
XCP-ng 8.2.0 with xoa

xcp-ng is installed on a first 240GB disk

I would like to use the second disk (2TB) to store the iso’s, to share data storage disk space from the VMs (the VMs will be deployed on the first disk)

information on both discs
first ssd disk (2xssd 250Go RAID1)
second HDD drive
(2xhdd 2TB Raid1)

I thought about creating the directory /opt/isoslib and mounted it on the second disk but the problem is that I have this error mount: unknown filesystem type ‘LVM2_member’
I suspected that it would not pass since disk two is already in use via xe sr-create host-uuid …

Thanks for your help

Tom, love your videos! Thanks for producing them.

I have a question regarding whole disk Passthrough, but not sure you can answer it. As a bit of a lark, I’ve been trying to set up a TrueNAS system under XCP-ng as in your video. I followed your instructions to the letter, but ended up with something I cannot figure out.

My system has 4 hard drives installed; 1 4TB IronWolf and 3 3TB IronWolfs. Using lsblk, they show up as sda, sdb, sdc and sdd. I want to pass through the sdb, sdc and sdd drives (3TBs) so did the mkdir, then the symbolic links and finally xe sr-create command. All this worked as expected. The three drives showed up in XOA and I connected them to the TrueNAS vm.

TrueNAS then installed, so after a few housekeeping things, I then went into Storage and created a new pool and telling TrueNAS to make a zfs1 pool using the 3 3TB drives. However, instead of the the drives being named sdb, sdc and sdd, they were named sdb, sdc and xbd! The zpool was created successfully and I was able to populate it, but just couldn’t understand why the third drive was labeled xdb instead of sdb.

Also, after rebooting the TrueNAS system, if I went into Storage then Disks, no drives were displayed. The pool still existed and was accessible, but no drives were shown?

I realize that you said running FreeNAS in a VM with Disk Passthrough wasn’t something you would do in production, but I was curious none the less.

Any suggestions?

I did this as a demo but it’s not something I have ever or would ever run outside of a lab so I have only this system that I tested. Might want to post in their forums to get more insight Home | XCP-ng and XO forum

Long time viewer of the youtube channel,
first time poster.

So first up, i know to not use this for production, i just want to try something for fun and learning.

i work in industrial automation, and in this space we just yet started to put ethernet ports on the logic programmable controllers for comms and programming.

That’s where i come in, i am setting up a dell R720 SFF 16bay with an H310 flashed to it mode,
on the internal USB i have XCP-NG running, and on Sata ssd disk 0 i have XOA-from source running, and on Sata SSD 0 i have windows running with a Scada software called Ignition maker edition.

this al to learn how to log data to databases and read them back and such.

this al works, now the part that doesn’t work,
on disk slot 1 i have installed Truenas V12
slot 7 i have a free Sata SSD to use as a cache disk for truenas, passed through to Truenas
slot 8-15 i have SAS 1tb Drives to use as storage for truenas, also passed through.

All drives report their exact size in XOA, but when i login truenas, i get no data about these drives, and al the sizes except the boot drive are the size of the ssd’s eg 240gb.

what am i doing wrong ?
i have a feeling i know whats up, but i want to hear from more knowledgeable people

Thanks, exactly what i needed

I saw that the link for PCI passthrough changed so here is the new one.

Yesterday my proxmox SSD had an unfortunately problem due to a system lockup and my server setup was ruined… I thought let’s reinstall xcp-ng again… All went fine…

Now I get a wrong vga mode on boot and can’t see anything. But that is not the main problem.

In proxmox you could easily passthough a physical disk almost the same way like with xcp-ng… I tried Tom’s way by watching the video (I believe from 2020)… That methos seems to work for whole disks but not for partitions…

In proxmox I could easily passthrough a partition and use them in truenas for a slog or cache disk…

Anyone know how to do this in xcp-ng… Passing through the /dev/disk/by-id/ links doen’t work… Only for full disks.

Also I think it would be better to pasthrough them not by /dev/xxx but with their long unique identifier

but in any case it doesn’'t work… Not sure if there is a direct way (like with proxmox) to edit each VM’s config file? In proxmox you simply edit the xxx.conf file.

update >>> nvm. I got it to work… It was a booboo on my end… sorry about that…

zfs pool back online in truenas via xcp-ng