Overview
To kill a Byve process
Find the Process ID (PID) of the bhyve process:
Use pgrep or ps to find the process ID associated with your specific VM.
pgrep -l bhyve
7790 bhyve
Or
ps aux | grep bhyve
root 7929 0.0 0.0 14164 2668 1 S+ 09:08 0:00.00 grep bhyve
Send a termination signal:
Graceful shutdown (SIGTERM):
This is the preferred method for manual termination as it allows the bhyve process to perform an orderly shutdown, similar to a power button press. kill(1) sends SIGTERM by default, so the -s TERM is optional.
kill
or
kill -s TERM
Forceful shutdown (SIGKILL):
If the bhyve process is unresponsive to SIGTERM, you can use SIGKILL to terminate it immediately. This is equivalent to "pulling the power cord" and may risk data corruption in the guest OS, so use it only as a last resort.
kill -s KILL
or¶
kill -9
Alternative Methods
Using bhyvectl:
You can also use the bhyvectl command to destroy the VM instance, which hard powers it off and removes the associated bhyve(8) process.
bhyvectl --vm=<vm_name> --destroy
Dealing with "locked" VMs:
After a forceful shutdown, the VM might appear as "running" or "locked" (due to a remaining run.lock file in the VM's directory). If this happens, you may need to manually remove the lock file to restart the VM.