Verwaltung von virtuellen Maschinen und Jails für FreeBSD

Achtung! Der deutschsprachige Inhalt ist wegen fehlenden Betreuerinnen und Betreuern veraltet. Verwenden Sie bitte die englischsprachige Version!

Attention! I apologize for the automatic translation of this text. You can improve it by sending me a more correct version of the text or fix html pages via GITHUB repository.

Attention! Current pages describe CBSD version 13.0.x. If you are using an older version, please update first.

Attention! Currently, BSD hypervisor is really an experimental feature. Use it is recommended only in test environments.

work with bhyve

Here we describe the differences between bhyve-related scripts in relation to jail-related. Naming of commands to operate on bhyve in most cases coincides with the jail-related command, but starting with b instead of j.

Creating a Virtual Machine

		% cbsd bconstruct-tui
	

  • vm_os_type - Freebsd or Linux (other OSes while under suspicion)
  • vm_os_profile - if Linux, select distribution profile.
  • freesize -volume of VHD. If guest is Linux, it will be the total size of the entire disk. If this is FreeBSD, it is the amount of free space available after creation (created out of jail). For example: 10g for Linux or 1g for FreeBSD
  • jname - name of VMs. For example: freebsd, ubuntu, centos, debian
  • fqdn - Full name with domain. For example: blabla_foo.my.domain

The remaining parameters are optional. For FreeBSD virtual can immediately fill ip4_addr (for example: 192.168.0.5/24) and gw4 (for example: 192.168.0.1) - by design, it will apply to the newly created VM. If Linux, leave ip4_addr by zero with empty gw4

A further change is made through the VM configuration scripts cbsd bconfig and cbsd bhyvedsk-tui.

Running a virtual machine

After working out bconstruct-tui can try to run VMs through cbsd bstart $jname. By default, run from the hard disk image. Boot device priority can be changed via cbsd bconfig. In case the first device is hdd and the hard disk drive does not contain data, scripts suggest to start from CD/ISO.

Running, as befits now bhyve, takes place in two stages - booting the kernel through bhyveload (for foreigner, not FreeBSD-guests, this operation goes through grub2-bhyve) and the launch of virtuality via bhyve. Both operations in the case of cbsd tested with the creation and output of the console tmux session. If after working cbsd bstart you returned to the terminal and the command cbsd bls show status On for VMs, likely kernel booted successfully and you can connect to the console via cbsd blogin $jname.

Stop the virtual machine

Stop of VMs (as well as the completion bhyveload, as if it is stuck on the execution of cbsd bstart and you are not released back into the terminal) via a command cbsd bstop $jname

Connecting to the terminal VM

To connect to the session, use the command cbsd blogin. Since the session starts in tmux, when connecting inherited his navigation. If you are not familiar with tmux - the main thing that you need in the case of CBSD know about tmux, that the operation of the terminal shutdown occurs through a combination of Ctrl + B и D (by holding Ctrl, press B. let them push and press D).

Operation with Hard Disk of VM

When VM created, in the ${workdir}/jails-data/$jname-data/ creates an image of the first hard disk with the name dsk1.vhd. In this case, the type of controller used that specified in the profile of the virtual machine ($workdir/etc/defaults/bhyve-*.conf files).

By cbsd bhyvedsk-tui you can change the type of controller and add or remove new images

At the moment, you can choose emulation virtio-blk driver or ahci-hd. One virtual machine may be up to 16 devices with different controllers. Through cbsd bhyvedsk command you can display a list of all hard disks of virtual machines, or drives for only specific VM.

VM configuration

Change some settings for the virtual machine, you can click through cbsd bconfig.

A couple of other comments

  • If you have not changed passwords file in ${workdir}/share/jail-skel/etc/ and applytpl=1, the root password have created of freebsd VMs via cbsd bconstruct/jail2iso: cbsd
  • bhyve-vms removed from the jls output, as by command cbsd bls you will not see jail-based environment.
  • Since all hard drives are created in $workdir/jails-data/$jname-data, bhyve virtual machine can be exported, moved with all discs and imported to other hosts through the cbsd jexport and cbsd jimport commands.
  • By analogy with jrename and jclone work scripts brename and bclone with the only exception that only appear when working parameters old= and new=.

  • FreeBSD guest created through the script jail2iso of jail, so it does not offer starts with ISO
  • Network for VMs created through tap-interfaces that are attached to in your uplink interface via bridge
  • For disk control (adding, removing, modify of controller type) use cbsd bhyvedsk-tui $jname command
  • In the old grub-bhyve version when "rubber" of the data on the screen on a widescreen monitor, if the amount is more than 255 familiarity, grub goes into a stupor and leads to the same bhyveload. Accordingly, if cbsd bstart XXX process is locked, follow cbsd bstop XXX and reducing the window geometry, try to run again. Patch: https://github.com/grehan-freebsd/grub2-bhyve/commit/70ace4fd43f5017d4aacc920017b5641c9d45431