rc.d script for running bhyve in tmux

Michael Gmelin freebsd at grem.de
Sat Nov 2 03:49:00 UTC 2013


Hi,

I hacked together a small rc.d script for starting bhyve(4) in tmux,
maybe it's useful to others too. Place it in /usr/local/etc/rc.d and
install sysutils/tmux. Might need some love to fit your needs.

Minimal configuration example:
pkg install tmux

echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf

cat >> /boot/loader.conf << EOF
if_tap_load="YES"
if_bridge_load="YES"
vmm_load="YES"
EOF

kldload tap; kldload bridge; kldload vmm

cat >> /etc/rc.conf << EOF
cloned_interfaces="tap0 bridge0"
bhyve_enable="YES"
bhyve_diskdev="/dev/zvol/tank/bhyve/virt"
EOF

ifconfig tap0 create
ifconfig bridge0 create

service bhyve start
tmux list-sessions
tmux attach -t bhyve
service bhyve status
service bhyve stop

Multi profile configuration example:
cat >> /etc/rc.conf << EOF
cloned_interfaces="tap0 tap1 bridge0"
bhyve_enable="YES"
bhyve_profiles="virt1 virt2"
bhyve_virt1_diskdev="/dev/zvol/tank/bhyve/virt1"

bhyve_virt2_tapdev="tap1"
bhyve_virt2_diskdev="/dev/zvol/tank/bhyve/virt2"
bhyve_virt2_memsize="8192"
bhyve_virt2_ncpu="4"
EOF

ifconfig tap0 create
ifconfig tap1 create
ifconfig bridge0 create

service bhyve start # start all
service bhyve start virt2 # start individual
tmux attach -t bhyve_virt1
tmux attach -t bhyve_virt1
service bhyve stop virt2 # stop individual
service bhyve stop # stop all

(by default ctrl-b d detaches from tmux).

Cheers,
Michael

-- 
Michael Gmelin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bhyve
URL: <http://lists.freebsd.org/pipermail/freebsd-virtualization/attachments/20131102/ffba3f0f/attachment.ksh>


More information about the freebsd-virtualization mailing list