bhyve bhyve HDD passthrough

Howdy! I'm new to FreeBSD (just installed yesterday). I have a Windows background and have never used a hypervisor before so please be patient with me. I also apologize if this has been asked many times before but I just can't get it to work.

I have a total of six HDDs I'm trying to pass through to a Linux guest. I edited the default.conf file located under /zroot/bhyve/.templates/ to look like this:
Code:
loader="grub"
cpu=1
memory=512M
ahci_device_limit="8"
network0_type="virtio-net"
network0_switch="public"
disk0_type="ahci-hd"
disk0_name="disk0.img"
disk1_dev="custom"
disk1_opts="sectorsize=512"
disk1_type="ahci-hd"
disk1_name="/dev/ada0"
disk2_dev="custom"
disk2_opts="sectorsize=512"
disk2_type="ahci-hd"
disk2_name="/dev/ada1"
disk3_dev="custom"
disk3_opts="sectorsize=512"
disk3_type="ahci-hd"
disk3_name="/dev/ada2"
disk4_dev="custom"
disk4_opts="sectorsize=512"
disk4_type="ahci-hd"
disk4_name="/dev/ada3"
disk5_dev="custom"
disk5_opts="sectorsize=512"
disk5_type="ahci-hd"
disk5_name="/dev/ada5"
disk6_dev="custom"
disk6_opts="sectorsize=512"
disk6_type="ahci-hd"
disk6_name="/dev/ada6"
grub_run_partition="1"
grub_run_dir="/boot/grub"

As you can probably tell, I have no idea what I'm doing. Am I even editing the right config file? Do I have to call any commands to update the VM after any changes are made to this config file? Am I even doing it right? Any help/article would be appreciated. Thanks in advance.
 
I edited the default.conf file located under /zroot/bhyve/.templates/ to look like this
Looking at the configuration file you seem to be using sysutils/vm-bhyve.
Am I even editing the right config file?
No, you're editing a template that's used when you create a new VM. Templates allow you to create a basic configuration you can use when creating new VMs. You can, for example, create a template for Windows VMs, or Debian, or FreeBSD, or some other. The default.conf template is used if you do not explicitly tell vm create .. to use a specific template.

Code:
     create [-d datastore] [-t template] [-s size] name
             Create a new virtual machine.

             Unless specified, the default.conf template will be used and a
             20GB virtual disk image is created.  This command will create the
             virtual machine directory $vm_dir/$name, and create the
             configuration file and empty disk image within.

             -d datastore  Specify the datastore to create this virtual
                           machine under.  If not specified, the default
                           dataset will be used, which is the location
                           specified in /etc/rc.conf.

             -t template   Specifies the template to use from within the
                           $vm_dir/.templates directory.  The .conf suffix
                           should not be included.

             -s size       The size of disk image to create in bytes.  Unless
                           specified, the guest image will be a sparse file
                           20GB in size.
See vm(8)

I have several templates for different purposes:
Code:
dice@hosaka:~ % ll /vm/.templates/
total 37
-rw-r--r--  1 root wheel 487 Jan  6  2018 centos7.conf
-rw-r--r--  1 root wheel 160 Mar 26  2022 centos8.conf
-rw-r--r--  1 root wheel 160 Oct 21  2023 centos9.conf
-rw-r--r--  1 root wheel 172 Jan  7  2018 debian.conf
lrwxr-xr-x  1 root wheel  17 Jan  6  2018 default.conf@ -> freebsd-zvol.conf
-rw-r--r--  1 root wheel 177 Jan  7  2018 freebsd-uefi-zvol.conf
-rw-r--r--  1 root wheel 247 Oct  3  2021 freebsd-zvol.conf
-rw-r--r--  1 root wheel 131 Mar 21  2022 ubuntu.conf
-rw-r--r--  1 root wheel 123 Jan  6  2018 windows.conf

If you want to edit the configuration of an existing VM you simply use the vm config <name> command. That will open the configuration file specific for that VM.

 
WOW! I am astonished. It worked! Your response was in depth but still to-the-point. All I needed to do was vm config <name> and make the changes there. I'm also thankful for the vm manual page. Thank you!!
 
I'm also thankful for the vm manual page.
As you're new to FreeBSD, and probably UNIX(-like) systems in general, manual pages are how you get a lot of information. Nobody remembers all the possible switches and their uses from every command. Manual pages are awesome references. If there's one thing you should learn quickly it'll be how to look stuff up. Open a command prompt (or terminal) and type man man. That will get the manual page for the man(1) command.
 
Do you have a specific reason for wanting to "pass through" harddisks? (putting this in quotes because it works on top of FreeBSD's blocks device anyways, the guest will not directly control the drives)

Because if not, I'd argue the normal approach to create virtual volumes for the guest (backed by whatever your host's storage solution provides, could be just an image file, could be a "zvol") is much more flexible and powerful. With a FreeBSD host, you could create a ZFS pool on these drives and your guests would transparently benefit from some of the features like consistency/redundancy ...
 
Do you have a specific reason for wanting to "pass through" harddisks?
Yes. Or at least, I think so.

I have a set of six hard disk drives consisting of a Linux MD RAID 6. This volume consists of over 14 terabytes of data. I've been experimenting with Linux on and off for the past couple of years but finally got fed-up with it. In my opinion, GNU/Linux can be very unstable at times. It feels like a cluster of software stitched together. In my quest to find something even more stable, I decided to give FreeBSD a try. I'm liking it, but one of the first problems I faced was accessing the data on my Linux RAID volume. After some research, I found out that it can't be done in FreeBSD's current state. I would have liked to re-create the array from scratch using a FreeBSD supported file system, such as ZFS, but since this data is over 14TiBs, I do not have the resources to purchase the required data storage right now. So for now, I'll just access that data through a Linux VM running on my FreeBSD host. And it is working. I just have to figure out an easy way to share files between my guest (Debian) and my host (FreeBSD).
 
I would have liked to re-create the array from scratch using a FreeBSD supported file system, such as ZFS, but since this data is over 14TiBs, I do not have the resources to purchase the required data storage right now.
Please don't get that wrong but think about it for a while; I have a question for you 😎

Is the data stored on that RAID "important" to you?

If it is important: Go get something you can use for a backup. You always, really always want to have backups of important data. RAID or any other kind of live redundancy is NOT a backup. All it protects against is failure of individual hardware components. It doesn't protect against "catastrophic" damage (fire, water, whatever), it doesn't protect against fat-fingering admins, lots of other things. Go fix that. A simple (and typically not TOO expensive) solution is some "archive"-style large harddisk, you can e.g. get them as external drives with USB3. Once you have that, you can e.g. create a zpool with "ZFS on Linux" there and use a tool like rsync to get your data on it. (This will in general always give you an opportunity to move to an entirely different live storage solution)

If it is not important, just screw it (obviously) :D
 
Please don't get that wrong but think about it for a while; I have a question for you 😎

Is the data stored on that RAID "important" to you?

If it is important: Go get something you can use for a backup. You always, really always want to have backups of important data. RAID or any other kind of live redundancy is NOT a backup. All it protects against is failure of individual hardware components. It doesn't protect against "catastrophic" damage (fire, water, whatever), it doesn't protect against fat-fingering admins, lots of other things. Go fix that. A simple (and typically not TOO expensive) solution is some "archive"-style large harddisk, you can e.g. get them as external drives with USB3. Once you have that, you can e.g. create a zpool with "ZFS on Linux" there and use a tool like rsync to get your data on it. (This will in general always give you an opportunity to move to an entirely different live storage solution)

If it is not important, just screw it (obviously) :D

I'll take your warning seriously. I've heard that saying: "RAID is NOT a backup", many times now, and have been stubbornly ignoring it. Yes, the data is important to me and it would be devastating if it were to undergo catastrophic damage/failure. I'll get to purchasing the required backup media ASAP. Thanks again!
 
Back
Top