# bhyve virtual machine boot script



## amr (May 30, 2020)

Hello FreeBSD community!
The following boot script is working with no errors & my virtual machine boots up but once I reboot the machine it shutdown completely and I have to run the script again, is there is a way to keep the machine running in a loop?


```
#!/bin/sh
bhyve -AHP -c 2 -m 16G \
-s 0:0,hostbridge \
-s 1:0,lpc \
-s 2:0,virtio-net,tap0 \
-s 3:0,virtio-blk,/dev/zvol/zroot/VMs/IPFW/IPFW \
-s 29,fbuf,tcp=0.0.0.0:5900,w=1024,h=768 \
-s 30,xhci,tablet \
-l bootrom,../efi.fd \
IPFW > /dev/null 2>&1 &
```

Thanks,
Amr


----------



## Phishfry (May 30, 2020)

No way to reboot that I know of.
But to restart a VM you can run `bhyectl --vm=IPFW --destroy` then restart your bhyve VM.


----------



## SKull (May 30, 2020)

I think bhyve comes with a bunch of rc.conf parameters to handle booting vms on system start.


----------



## Geezer (May 31, 2020)

Look at the exit status from bhyve. 

0 is reboot, so put your bhyve statement in a loop and check the exit status.

reference:
`man bhyve`
     0       rebooted
     1       powered off
     2       halted
     3       triple fault
     4       exited due to an error


----------



## Phishfry (May 31, 2020)

Solved - How reboot FreeBSD 10.1 as guest on bhyve?
					

When I try to reboot FreeBSD 10.1 as guest on bhyve, OS shutting down. How get state of guest OS on host to use it for cycle in start script for implement reboot function?




					forums.freebsd.org


----------

