Attach to a running VM after closing the tmux session

If you start a vm by doing doas vm start -f myvm and close that tmux window with ctrl-b &, how would you attach a new tmux window to that running vm?
 
so you are running vm(8) from within a tmux session and want to reconnect?
from tmux(1):
Code:
     Each session is persistent and will survive accidental disconnection
     (such as ssh(1) connection timeout) or intentional detaching (with the
     ‘C-b d’ key strokes).  tmux may be reattached using:

           $ tmux attach

To connect to the console of a vm managed by sysutils/vm-bhyve:
vm conosle <name>
 
Thank you for your reply.
If you close that session, how would you create a new session into that vm?

Code:
user@localhost > doas vm console myvm
/usr/local/sbin/vm: ERROR: unable to locate console device for this virtual machine
 
Try using vm without sudo - this bloated thing nowadays has too many opaque implications e.g. about the environment and access rights. You could try sysutils/doas, this seems to work:
Code:
% doas vm console rtr1
Connected


OpenBSD/amd64 (rtr1.mydomain.tld) (tty00)

But personally, I just become root to do root stuff and then drop back to my regular user instead of typing dozens of commands with doas/sudo prefixed...


IIRC vm creates a virtio console by default, but I'm not sure what happens if the guest OS doesn't support it at all (windows) - so what OS is running in that VM? This might also indicate that there was no console created for that VM.
 
tmux attach-session -t myvm

or short
Code:
tmux attach -t myvm
tmux at -t myvm
tmux a -t myvm

list sessions tmux ls
Thank you, but it's not what I'm looking for. You assumed the session is still there.

You closed the tmux session, and now you want to create a new session into that running vm.
 
Try using vm without sudo
I think you misread my initial thread. I didn't mention sudo at all.

But what you're mentioning here is also not correct:
Code:
/usr/local/sbin/vm: ERROR: virtual machines can only be managed by root
 
You closed the tmux session, and now you want to create a new session into that running vm.
Why not start a new-session into the closed tmux session to VM??

 
When you create a tmux session and start bhyve VM and then close tmux session I am assuming the process started is orphaned.
Check ps -ax to see if it is in fact still running. If so you are going to have to use ssh or nmdm to get back inside.
That or pkill the process and restart.
 
Maybe look at daemon instead of tmux. It is a different approach.

 
Thank you for your suggestions. I came up with powering my vm off and starting with -f option for now.
 
Back
Top