 |
|
| |
| BVM(8) |
FreeBSD System Manager's Manual |
BVM(8) |
bvm —
Bhyve Virtual machines Management
tool
bvm |
--create name
[from template-name
[-s |
-U=N |
-m=SIZE |
-d=SIZE |
-n=MODE |
-i=NIC]] |
bvm |
--log [name
[-e |
-n=N |
-a]] |
bvm |
--ls [byname |
byos | bystatus |
online] |
bvm |
--ll [byname |
byip | byos |
bystatus | online] |
bvm |
--clone name new-name |
bvm |
--rename name
new-name |
bvm |
--setsw Switch
ip/mask |
The bvm is a
bhyve(8) virtual machine management tool based on FreeBSD
that allows you to easily manage virtual machines.
The virtual machine's network is handled by one or more virtual
switches. Each switch has a simple name, which is stored in the
corresponding configuration file and can be modified by the
bvm create one or more
bridge(4) devices for each virtual switch and dynamically
assign them to the virtual machine
tap(4) interface. When the virtual machine is shut down
normally, the bvm will automatically clean up the
useless network devices.
The bvm supports multiple network cards
and multiple hard disks. Each virtual machine can have multiple network
cards or multiple hard disks, and can easily add, delete, and modify network
cards or hard disks.
Once bvm is installed, the first thing you
have to do is set up the virtual machine's storage directory.
Edit the value of vmdir in
/usr/local/etc/bvm/bvm.conf
If you want to automatically boot the specified list of virtual
machines in order while the host is booting, add the following lines to
/etc/rc.conf to enable:
--abinfo
- Show information for all auto-bootstrap virtual machines.
--addisk
name
- Add a hard disk to the virtual machine.
--autoboot
- Start the automatic booting virtual machine in order. Boot option, which
is usually not required in administrator manual maintenance mode.
Sometimes the host is powered on again after shutdown or unexpected
downtime. At this time, the administrator-set virtual machine can be
automatically started by the rc script. The method is to use
bvm --config to modify the
default value of the auto boot menu to yes.
In self-start mode, bvm will refer to
the boot level and delay options of vm. The boot level is the boot
priority. When there are multiple self-starting virtual machines, the
lower the startup priority, the more the virtual machine starts. Back to
front. Boot time (boot time) After starting the current virtual machine,
it can also be said that the number of seconds is tentative before
starting the next virtual machine. The reason for designing these two
parameters is because some services may need to be activated first to
ensure normal business.
For example, the relationship between the database and the web
service, if the data virtual machine library is not prioritized, it may
cause the web service to be abnormal!
The correct way to use this option is to add the startup
script:
--clone
name new-name
- Clone a new virtual machine from an existing virtual machine.
--config
name
- Edit the configuration of the virtual machine. This option needs to be
used in the case of a virtual machine. Options that allow users to
configure independently are: cpus, ram, iso path, boot from, hostbridge,
uefi, TPM, VNC settings, shared folder, audio, auto boot, disk config, and
network config.
- cpus
- The total number of virtual CPUs used by the current virtual
machine.
- ram
- The size of the memory requested by the current virtual machine, the
unit of which can be M/G, etc.
- iso path
- The directory where the iso disc image is located (is the directory,
non-iso absolute address). When the directory is specified,
bvm will automatically list the iso files
contained in the current directory. The user can select the menu
number.
- boot from
- This is an important option. When the system is first installed,
bvm will automatically adjust this option to
hd0 for system startup. When you need to use iso disc for system
maintenance, you can change this option to cd0.
- CD
- Enable or disable CD-ROM support (on/off).
- cd numbers
- Number of CD-ROM drives (1-4). Multiple CDs are useful for scenarios
like Windows driver installation.
- cd(N) iso
- ISO path for CD N. Enter '-' or 'none' to clear the ISO path for
cd1-cd3. The cd(0) is required and cannot be cleared when CD is
enabled.
- boot type
- Select the boot method. Options are:
- grub
- Standard Bhyve loader (bhyveload/grub-bhyve). Recommended for most
BSD and Linux VMs.
- uefi
- UEFI boot mode. Required for Windows and some modern Linux
distributions. Often used with VNC for GUI.
- uefi_csm
- UEFI Compatibility Support Module (Provides Legacy BIOS
compatibility).
Note: UEFI modes might have limited console support with
--login depending on the guest OS
configuration.
- TPM (UEFI)
- Enable TPM 2.0 (Trusted Platform Module) support. This is required for
Windows 11 installation and needs UEFI boot mode. The swtpm package
must be installed on the host.
- VNC settings
- VNC configuration includes bind address (default 0.0.0.0), port
number, display resolution (width/height), optional password
protection, and wait option (wait for VNC connection before
boot).
- audio
- Enable HDA audio device support for the virtual machine. Requires
/dev/dsp0 on the host.
- auto boot
- See
--autoboot for details.
- hostbridge
- This is a schema attribute whose attribute value should be hostbridge
when using the Intel system CPU; its attribute value should be
amd_hostbridge when using the AMD series CPU.
- disk config
- The option can add or delete the hard disk of the current virtual
machine. Supports multiple storage interfaces: ahci-hd (AHCI),
virtio-blk (VirtIO Block), and nvme (NVM Express). If you only want to
add the hard disk, it is recommended to use
bvm --addisk shortcut
command.
- shared folder
- VirtIO-9P file sharing. This option allows sharing host directories
with the virtual machine. When enabled, you can set the share name
(used in guest to identify the share), share path (host directory to
share), and read-only mode. Linux guests can mount the share using:
mount -t 9p -o trans=virtio sharename /mnt/point
Note: FreeBSD 14 guests lack virtio_p9fs support; FreeBSD 15+ has full
support.
- passthru
- PCI passthrough. This option allows passing physical PCI devices
directly to the virtual machine for exclusive use (e.g., GPU, network
cards). Prerequisites: CPU must support Intel VT-d or AMD-Vi. Device
must support MSI/MSI-x interrupts and be reserved in /boot/loader.conf
(pptdevs="bus/slot/func"). When enabled, BVM automatically
detects available passthrough devices and displays them in a selection
list. Only devices bound to the ppt driver and not allocated to other
VMs will appear. Configuration options: passthru (on/off), ppt devices
(1-8), ppt(N) device (select from list). When enabled, bhyve uses -S
flag to wire guest memory. Use 'bvm --pci' to find device
addresses.
- network config
- This option allows you to configure the networking of virtual
machines. Supports Bridge, NAT, and Switch network modes with built-in
DHCP server.
--create
name [from
template-name [options]]
- Create a new virtual machine.
# bvm --create vm1
# bvm --create vm2 from vm1
# bvm --create vm3 from Linux -s -U=4 -m=512m -d=10g -n=bridge -i=em0
Standard templates available:
- freebsd
- FreeBSD standard configuration.
- linux
- Linux standard configuration.
- windows
- Windows standard configuration.
You can also use any existing VM name as a template.
When using from to create from a
template, optional parameters can override template settings:
-s
- Set boot type to grub.
-U=N
- Set CPU count (e.g. -U=4).
-m=SIZE
- Set memory size (e.g. -m=512m, -m=2g).
-d=SIZE
- Set first disk size (e.g. -d=10g, -d=1t).
-n=MODE
- Set network mode (bridge or nat).
-i=NIC
- Set bind NIC (e.g. -i=em0).
--deldisk
name
- Delete the disks in the virtual machine.
--decrypt
name
- Decrypt the virtual machine.
--encrypt
name
- Encrypt the virtual machine.
--help
- Show all options and descriptions.
--login
name
- Login to a running virtual machine from the console. For UEFI mode,
console support depends on the guest OS configuration; if it fails, please
use the VNC client or SSH.
To enable serial console output in guest OS:
- Debian/Ubuntu
- Edit /etc/default/grub, set GRUB_CMDLINE_LINUX="console=tty0
console=ttyS0,115200", then run update-grub and reboot.
- RHEL/CentOS/AlmaLinux
- Edit /etc/default/grub, add "console=tty0
console=ttyS0,115200" to GRUB_CMDLINE_LINUX. Remove "rhgb
quiet" for full boot messages. Run grub2-mkconfig -o
/boot/efi/EFI/centos/grub.cfg (adjust path for distro) and
reboot.
- Fedora
- Same as RHEL, but use path /boot/grub2/grub.cfg.
- openSUSE
- Edit /etc/default/grub, add "console=tty0
console=ttyS0,115200" to GRUB_CMDLINE_LINUX_DEFAULT. Remove
"splash=silent quiet" for full boot messages. Run
grub2-mkconfig -o /boot/grub2/grub.cfg and reboot.
- OpenBSD
- Modify /etc/boot.conf:
echo "set tty com0" >> /etc/boot.conf
echo "stty com0 115200" >> /etc/boot.conf
Enable login in /etc/ttys: Find 'tty00' line, change
'std.9600' to 'std.115200', 'unknown' to 'vt100', and 'off' to 'on
secure'.
--ls
[byname | byos |
bystatus | online]
- Show a list and status of all virtual machines. By default, the output is
sorted in ascending order by name, or one of the following options is
specified.
- byname
- Output list in ascending order by name.
- byos
- Output list in ascending order by OS.
- bystatus
- Output list in ascending order by virtual machine status.
- online
- Only show running virtual machines.
# bvm --ls byos
NAME GUEST CPU MEMORY DISK STATE
c Debian 1 512M [2]5.5G off
d Debian 1 512M [1]5G off *
abc Debian 1 512M [1]10G on
b FreeBSD 1 1G [1]10G off
bb FreeBSD 1 1G [1]10G off
# bvm --ls
NAME GUEST CPU MEMORY DISK STATE
abc Debian 1 512M [1]10G on
b FreeBSD 1 1G [1]10G off
bb FreeBSD 1 1G [1]10G off
c Debian 1 512M [2]5.5G off
d Debian 1 512M [1]5G off *
The meaning of the list items is as follows:
- NAME
- The name of the virtual machine.
- GUEST
- Virtual machine operating system.
- CPU
- Number of CPUs.
- MEMORY
- Size of memory.
- DISK
- Disk capacity, the number in square brackets represents the number of
disks, and the capacity is the sum of all disk capacities.
- STATE
- The state of the virtual machine, off or on, if the virtual machine is
locked, a yellow symbol '*' is also displayed, if the virtual machine
is encrypted, a red symbol '*' is also displayed.
--ll
[byname | byip |
byos | bystatus |
online]
- Show a list and status of all virtual machines in long format. By default,
the output is sorted in ascending order by name, or one of the following
options is specified.
- byname
- Output list in ascending order by name.
- byip
- Output list in ascending order by IP-addr.
- byos
- Output list in ascending order by OS.
- bystatus
- Output list in ascending order by virtual machine status.
- online
- Only show running virtual machines.
The added list items have the following meanings:
- IP
- The IP address of the virtual machine.
- LOADER
- The boot loader for the virtual machine.
- AUTOSTART
- The state in which the virtual machine is automatically started,
"Yes" is automatically started, and the number next to it is
the startup sequence.
--lock
name
- Locks the specified virtual machine, and can't
--config , --remove ,
--start , and so on. Only simple read operations
can be performed, such as --vminfo ,
--ls , this option also prevents the risk of
virtual machine files being accidentally deleted.
--lockall
- Lock all virtual machines, behaving the same as
--lock.
--netstat
- Show all network configuration information of virtual machines, including
NIC, mode, IP address, gateway, port forwarding, bridge, and TAP device,
etc.
--os
- Show a list of operating systems supported by
bvm.
--log
[name [-e |
-n=N |
-a]]
- Show VM log entries.
-e
- Show error logs only.
-n=N
- Show last N lines (default: 50).
-a
- Show all logs (no line limit).
--passthru
- Show PCI passthrough device list. Displays all PCI devices that are bound
to the ppt driver and ready for passthrough to virtual machines. Devices
shown as "Passthru Ready" can be assigned to VMs, while
"Allocated" devices are currently in use by a running VM.
--pci
- Show all host PCI devices. Displays a complete list of PCI devices on the
host system, including their bus/slot/function addresses, driver, vendor,
device name, and class information.
--poweroff
name
- Force the virtual machine to power off. When there are some special
reasons that prevent the virtual machine from shutting down properly, you
need to use this option to force the virtual machine to power off.
--reload-nat
- Reload the NAT port redirect. In general, you do not need to use this
option,
bvm will automatically handle port
redirection, this option is manual mode.
--remove
name ...
- Destroy one or more virtual machines and they cannot be recovered. Note
that the virtual machines cannot be running when you run this
command.
--rename
name new-name
- Rename the virtual machine.
--restart
name
- Restart a virtual machine.
--reboot
name
- Restart a virtual machine (alias for --restart).
--rollback
name
- Roll back to the snapshot point.
--set-hd-boot
name
- Set the virtual machine to boot from the hard disk.
--setnat
nat ip/mask
- Set the IP address and mask of the NAT.
# bvm --setnat nat0 172.16.1.1/24
--setpr
ip
- Port redirection is set dynamically with immediate effect. In general, the
virtual machine must be turned off to set the virtual machine parameters,
but this option can set the port redirection at any time in the virtual
machine on state, and take effect immediately.
# bvm --setpr 10.10.30.10
--showpr
- Show all list of port redirect.
# bvm --showpr
PROTO VM IP:PORT HOST PORT VM NAME
tcp 172.16.1.10:22 2224 freebsd-14
tcp 172.16.1.10:80 8080 freebsd-14
udp 192.168.1.254:53 9953 abc
tcp 10.10.30.10:22 3322 ob
--setsw
switch ip/mask
- Set the ip address and mask of the virtual switch. The same method as
--setnat.
--showdev
- Select a network device and show its relationship to the virtual machine
NIC.
--showdevall
- Show a relationship table for all network devices.
--showdevuse
- Show a relational table of all network devices in use.
--showdhcp
- Show all DHCP clients.
--showsnap
name
- Show snapshots list of the virtual machine.
--showsnapall
- Show snapshots list of the all virtual machines.
--showstats
name
- Show the statistics of the virtual machine, including CPU/Memory usage,
Disk I/O, Network traffic, and Service status.
--snapshot
name
- Generating snapshots for the virtual machine.
--start
name
- Start a virtual machine.
--stop
name
- Shut down a virtual machine.
--unlock
name
- Unlock a virtual machine.
--unlockall
- Unlock all virtual machines.
--unsetsw
switch
- Delete the IP address of the virtual switch.
--version
- Show the version number of
bvm installed.
--vminfo
name
- Shows the configuration of the virtual machine.
/usr/local/etc/bvm/bvm.conf
This file records the virtual machine's directory and a list of all supported
operating systems.
/usr/local/etc/bvm/nat.conf
This file records the configuration information for all NAT.
nat0=172.16.1.1/24
nat1=10.10.30.1/24
nat2=192.168.1.1/24
/usr/local/etc/bvm/switch.conf
This file records the configuration information of all virtual switches.
The default 0-2 sets the IP address, and 3-7 is not set.
switch0=10.0.1.0/24
switch1=10.0.2.0/24
switch2=10.0.3.0/24
switch3=
switch4=
switch5=
switch6=
switch7=
/usr/local/etc/bvm/dhcp.conf
This file records DHCP configuration information, including lease time,
DNS, IP address pool, etc.
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc.
|