# cd /usr # git clone https://github.com/FreeBSDonHyper-V/freebsd.git
# cd /usr/freebsd # make buildkernel KERNCONF=HYPERV_VM
# make installkernel KERNCONF=HYPERV_VM
If you built the kernel with the default HYPERV_VM makefile, the drivers will be included in the kernel image. To check if the modules are present, use the strings command and look for HyperV related symbols:
# strings /boot/kernel/kernel | grep hv_
If you built the kernel with the default makefile, the boot will fail with a ROOT MOUNT ERROR. This is due to FreeBSD using the Fast IDE driver also being integrated into the kernel image. There are two ways around this.
Reboot the system into single user mode. This can be accomplished by selecting boot menu option 4, or performing a ‘boot -s’ from the boot prompt. Alternatively, you can boot a specific kernel by specifying “boot -s”. Note the ordering of the last command.
In Single user mode, create GEOM labels for each of the IDE disk partitions listed in your fstab (both root and swap) - see also FreeBSD Labeled Filesystems. For example:
# cat /etc/fstab # Device Mountpoint FStype Options Dump Pass# /dev/ad0s1b none swap sw 0 0 /dev/ad0s1a / ufs rw 1 1 /dev/acd0 /cdrom cd9660 ro,noauto 0 0 # glabel label rootfs /dev/ad0s1a # glabel label swap /dev/ad0s1b # glabel status Name Status Components rootfs N/A ad0s1a swap N/A ad0s1b
Additional information on GEOM labels can be found at:
Reboot into multiuser mode (default). Edit your /etc/fstab to include the labels. For example:
# Device Mountpoint FStype Options Dump Pass# /dev/label/swap none swap sw 0 0 /dev/label/rootfs / ufs rw 1 1 /dev/acd0 /cdrom cd9660 ro,noauto 0 0
The steps above is to build the kernel with default configurations, however, in the real world, we need to modify the configuration file, i.e. HYPERV_VM to build a customized kernel. One of recommended changes is to comment out the line of makeoptions, which will do a full build. The default configuration file only includes the ones for Hyper-V, while most of the support modules are removed.
# $FreeBSD$ # include GENERIC ident HV_VMBUS #makeoptions MODULES_OVERRIDE="" # # Adaptive locks rely on a lock-free pointer read to determine the run state # of the thread holding a lock when under contention; under a virtualisation # system, the thread run state may not accurately reflect whether the thread # (or rather its host VCPU) is actually executing. As such, disable this # optimisation. #
Last edited by larrymelia,