Did you know that you can navigate the posts by swiping left and right?

Bhyve/iohyve on Freenas

18 Feb 2017 . Tech
#freenas #eve

currently running Freenas 9.10.2

The main material used was this freenas doc in section 13.4 on using iohyve.

Setup!

The first step is setting up iohyve so it knows what it needs to do. The only info needed is what pool you want to store your vm’s on. In my case, I wanted them stored on the same as my jails volume.

[chip@eve ~]$ iohyve setup pool=cache kmod=1 net=em0
Setting up iohyve pool...
Loading kernel modules...
Setting up bridge0 on em0...
net.link.tap.up_onopen: 0 -> 1

[chip@eve ~]$ ln -s /mnt/iohyve /iohyve

The last line ensuring that the softlink in place is needed, though may get done automatically. This dataset (cache/iohyve) is created, but not mounted in the typical /mnt/cache/iohyve, rather in /mnt/iohyve, which leaves the cache mount rather clean.

The last step in the initial setup, lets make sure bhyve/iohyve starts up on freenas by default.

1. Log in to the web ui
2. System -> Tunables -> Add Tunable
3. Create a tunables to enable iohyve at boot
  * Variable:iohyve_enable
  * Value: YES
  * Type: rc
  * Enabled: true
4. Create a second tunable to pass two of the flags we set during setup
  * Variable:iohyve_flags
  * Value: kmod=1 net=em0
  * Type: rc
  * Enabled: true


Get some ISO’s!

Next we need to give iohyve some iso’s to use:

[chip@eve ~]$ iohyve fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/10.3/FreeBSD-10.3-RELEASE-amd64-bootonly.iso
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/10.3/FreeBSD-10.3-RELEASE-amd64-bootonly.iso...
/iohyve/ISO/FreeBSD-10.3-RELEASE-amd64-bootonly.iso 100% of 232 MB 2443 kBps 01m38s

I went ahead and download the ubuntu xenial mini iso as well: http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/current/images/netboot/mini.iso

[chip@eve ~]$ sudo iohyve isolist
Listing ISOs...
FreeBSD-10.3-RELEASE-amd64-bootonly.iso
mini.iso


Create a VM!

Next we need to create a VM!

We’ll specify the name and size of the vm then verify it got created

[chip@eve ~]$ sudo iohyve create evecraft 5G
Creating evecraft...
[chip@eve ~]$ sudo iohyve list
Guest      VMM?  Running  rcboot?  Description
evecraft  NO    NO       NO       Sun Feb  5 13:44:29 PST 2017

To get all the attributes about the vm, we have the ` iohyve getall` command.

[chip@eve ~]$ sudo iohyve getall evecraft
Getting evecraft iohyve properties...
bargs          -A_-H_-P
boot           0
con            nmdm2
cpu            1
description    Sun Feb  5 13:44:29 PST 2017
loader         bhyveload
name           evecraft
os             default
persist        1
ram            256M
size           5G
tap            tap2
template       NO
vnc            NO
vnc_h          600
vnc_ip         127.0.0.1
vnc_tablet     NO
vnc_w          800
vnc_wait       NO

You can see how the os is default, loader is bhyveload ram is 256M … These are the typical defaults. Lets change a couple for our new Linux VM.

[chip@eve ~]$ sudo iohyve set evecraft ram=512M cpu=2 boot=1 loader=grub-bhyve description="EvEs Long-term minecraft server"
Setting evecraft ram=512M...
Setting evecraft cpu=2...
Setting evecraft boot=1...
Setting evecraft loader=grub-bhyve...
Setting evecraft description=EvEs Long-term minecraft server...

Lastly, lets power up the vm with the installer attached:

[chip@eve ~]$ sudo iohyve install evecraft mini.iso
Installing evecraft...
GRUB Process does not run in background....
If your terminal appears to be hanging, check iohyve console evecraft in second terminal to complete GRUB process...

Sweet! It should be up and running, to connect to the new vm, run sudo iohyve console evecraft in a second window to pull a serial console into the vm. Leave the console by typing ~~.

Follow your OS’s install instructions and you should be set!

Well…. it seems they’ve decided to break this :( . Unfortunately the above instructions no longer get you to a working vm

Next up, doing the minecraft installation on the vm