大网数据广告活动
Hyper-V与虚拟化

Best practices for running FreeBSD on Hyper-V

· 52CE 我爱测

Provides recommendations for running FreeBSD on virtual machines

This topic contains a list of recommendations for running FreeBSD as a guest operating system on a Hyper-V virtual machine.

Enable CARP in FreeBSD 10.2 on Hyper-V

The Common Address Redundancy Protocol (CARP) allows multiple hosts to share the same IP address and Virtual Host ID (VHID) to help provide high availability for one or more services. If one or more hosts fail, the other hosts transparently take over so users won't notice a service failure.To use CARP in FreeBSD 10.2, follow the instructions in the FreeBSD handbook and do the following in Hyper-V Manager.

  • Verify the virtual machine has a Network Adapter and it's assigned a virtual switch. Select the virtual machine and select Actions > Settings.

Screenshot of virtual machine settings with network adapter selected

  • Enable MAC address spoofing. To do this,

    1. Select the virtual machine and select Actions > Settings.

    2. Expand Network Adapter and select Advanced Features.

    3. Select Enable MAC Address spoofing.

Create labels for disk devices

During startup, device nodes are created as new devices are discovered. This can mean that device names can change when new devices are added. If you get a ROOT MOUNT ERROR during startup, you should create labels for each IDE partition to avoid conflicts and changes. To learn how, see Labeling Disk Devices. Below are examples.

Important: Make a backup copy of your fstab before making any changes.

  1. Reboot the system into single user mode. This can be accomplished by selecting boot menu option 2 for FreeBSD 10.3+ (option 4 for FreeBSD 8.x), or performing a 'boot -s' from the boot prompt.

  2. In Single user mode, create GEOM labels for each of the IDE disk partitions listed in your fstab (both root and swap). Below is an example of FreeBSD 10.3.

    # cat  /etc/fstab
    # Device           Mountpoint      FStype  Options   Dump   Pass#
    /dev/da0p2         /               ufs     rw        1       1
    /dev/da0p3         none            swap    sw        0       0
    
    # glabel  label rootfs  /dev/da0p2
    # glabel  label swap   /dev/da0p3
    # exit
    

    Additional information on GEOM labels can be found at: Labeling Disk Devices.

  3. The system will continue with multi-user boot. After the boot completes, edit /etc/fstab and replace the conventional device names, with their respective labels. The final /etc/fstab will look like this:

    # Device                Mountpoint      FStype  Options         Dump    Pass#
    /dev/label/rootfs       /               ufs     rw              1       1
    /dev/label/swap         none            swap    sw              0       0
    
  4. The system can now be rebooted. If everything went well, it will come up normally and mount will show:

    # mount
    /dev/label/rootfs on / (ufs, local, journaled soft-updates)
    devfs on /dev (devfs, local, mutilabel)
    

Use a wireless network adapter as the virtual switch

If the virtual switch on the host is based on wireless network adapter, reduce the ARP expiration time to 60 seconds by the following command. Otherwise the networking of the VM may stop working after a while.

   # sysctl net.link.ether.inet.max_age=60

See also

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 01/08/2021
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。