pkg install -y grub2-bhyve
echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf
echo "bhyve1:dv=/dev/nmdm1B:br#9600:pa=none:" >> /etc/remote
sysctl net.link.tap.up_on_open=1
sysctl net.inet.ip.forwarding=1
zfs create -o mountpoint=/bhyve -o compression=lz4 checksum=fletcher4 atime=off zroot/bhyve
# runtime
kldload if_tap
kldload if_bridge
kldload vmm
kldload nmdm
ifconfig tap1 create
ifconfig bridge0 create
ifconfig bridge0 addm tap1 addm re0 up
# make a new vm
## get the iso
DL="/zfs/shared/downloads/isos_and_images"
ISO="ubuntu-13.10-server-amd64.iso"
(cd $DL; aria http://releases.ubuntu.com/13.10/ubuntu-13.10-server-amd64.iso & )
## create a new zfs backed block device in /dev/zvol
VNAME="ubuntu1310_amd64"
zfs create zroot/bhyve/${VNAME}
cd /bhyve/${VNAME}
zfs create -V 10G zroot/bhyve/${VNAME}/root.img
ZVOL=`find /dev/zvol |grep ${VNAME}/root.img`
## make a grub device map for your vm:
echo \(hd0\) ${ZVOL} > device.map
echo \(cd0\) $DL/$ISO >> device.map
## start the vm
grub-bhyve -m device.map -r cd0 -v -M 1024M ${VNAME}
bhyve -c 2 -m 1024M -H -P -A \
-l com1,stdio \
-s 0:0,hostbridge \
-s 1:0,lpc \
-s 2:0,virtio-net,tap1 \
-s 3,ahci-cd,${DL}/${ISO} \
-s 4,virtio-blk,${ZVOL} \
${VNAME}
- do your normal installation stuff and exit
ip: 2a01:4f8:200:4433::5
dns: 2a01:4f8:0:a0a1::add:1010 2a01:4f8:0:a102::add:9999 2a01:4f8:0:a111::add:9898
hostname: u1310.skunkwerks.at
user: ansible (relax)
timezone: UTC
disk: guided simple
## /etc/network/interfaces example Hetzner Virtual Server
# Loopback-Adapter
auto lo
iface lo inet loopback
#
# IPv6 LAN
auto eth0
iface eth0 inet6 static
# Main IPv6 Address of the server
address 2a01:4f8:200:4433::5
netmask 64
gateway 2a01:4f8:200:4433::1
- zfs snapshot it if you like
## restart the vm via root disk
VNAME="ubuntu1310_amd64"
ZVOL=`find /dev/zvol |grep ${VNAME}/root.img$`
bhyvectl --destroy --vm=${VNAME}
grub-bhyve -m device.map -r hd0 -M 1024M ${VNAME}
grub>
ls (hd0,msdos1)/
...
linux (hd0,msdos1)/vmlinuz
initrd (hd0,msdos1)/initrd.img
boot
echo set root=\(hd0,msdos1\) > grub.cfg
echo linux /vmlinuz root=/dev/vda1 >> grub.cfg
echo initrd /initrd.img >> grub.cfg
echo boot >> grub.cfg
grub-bhyve -m device.map -r hd0 -M 1024M ${VNAME} < grub.cfg > /dev/null
bhyve -c 2 -m 1024M -H -P -A \
-l com1,stdio \
-s 0:0,hostbridge \
-s 1:0,lpc \
-s 2:0,virtio-net,tap1 \
-s 4,virtio-blk,${ZVOL} \
${VNAME}