A collection of shell scripts to run bhyve VMs on my FreeBSD 12.x desktop machine
MIT License
== bhyve-scripts
A collection of shell scripts to run bhyve VMs on my FreeBSD desktop and server machines.
== Environment
== ZFS zvols
These +disk1+ are thin-provisioned zvols.
== Prerequisites
(TODO) Install grub-bhyve etc.
== Setup
The following script loads the kernel modules for bhyve and creates tap devices for the VMs.
== Installing Linux -- Booting a VM from installer ISO Image
Edit +device.map+.
Run +grub-bhyve+ as root.
$ cd centos7 $ sudo grub-bhyve -m device.map -r cd0 -M 4096M centos7-docker1 grup> ls (hd0) (hd0,msdos2) (hd0,msdos1) (cd0) (cd0,msdos2) (host) (lvm/centos-root) (lvm/centos-swap) grub> ls (cd0)/ CentOS_BuildTag EFI/ EULA GPL images/ isolinux/ LiveOS/ Packages/ repodata/ RPM-GPG-KEY-CentOS-Testing-7 RPM-GPG-KEY-CentOS-7 TRANS.TBL grup> ls (cd0)/isolinux boot.cat boot.msg grub.conf initrd.img isolinux.bin isolinux.cfg memtest splash.png TRANS.TBL upgrade.img vesamenu.c32 vmlinuz
NOTE:
For CentOS, it's recommended to perform VNC-based graphical installation rather than console-based installation because graphical one gives you more customization options (e.g. custom disk layout) To do that, add the following options to +linux+ command.
Once the installer started, it will give tell you VNC server address and port.
Run +bhyve+ as root. Note that the VM has the installer DVD ISO attached.
When installation is completed, press the "Restart" button on the installer screen. This will shutdown the VM and drop you into a shell prompt (instead of restarting). Proceed to next chapter to boot the VM from the disk image.
== Booting a Linux VM from Disk Image
Edit +grub.in+. You might want to take a look at grub menu for kernel parameters.
Run the VM.
== Installing OpenBSD -- Booting a VM from installer ISO Image
Edit +device.map+.
Run +grub-bhyve+ as root. Ensure to boot with the OpenBSD install kernel (+bsd.rd+).
$ cd openbsd $ sudo grub-bhyve -m device.map -r cd0 -M 256M openbsd grup> ls (hd0) (cd0) (host) grub> ls (cd0)/ 5.7/ etc/ TRANS.TBL grup> ls (cd0)/5.7 amd64/ TRANS.TBL grub> ls (cd0)/5.7/amd64/ base57.tgz boot.catalog bsd bsd.mp bsd.rd cdboot cdbr comp57.tgz game57.tgz INSTALL.amd64 man57.tgz SHA256 TRANS.TBL xbase57.tgz xfont57.tgz xserv57.tgz xshare57.tgz
Run +bhyve+ as root. Note that the VM has the installer ISO attached. Also +-W+ option seems required. It forces virtio to use single-vector MSI.
=== IMPORTANT: Adjust the System Clock
Login to the VM and ensure the system clock is correct. By some
reason it's usually advance 3 days, so ntpd
won't be able to
adjust the clock. Run +ntpdate+ to fix it.2
NOTE: This might be fixed in 10.2-RELEASE (https://www.quernus.co.uk/2015/07/27/openbsd-as-freebsd-router/#comment-2163062052[Reference])
== When Linux Kernel in a VM is Upgraded
Edit +grub.in+ so that it will boot from the latest Linux Kernel.
== License
bhyve-script is open-sourced under the MIT license. See the link:LICENSE[LICENSE] file for details.