Incus console only shows a login promt if executed during the bootup procedure of the vm

Pretty much the title. Anytime i try to access the console on a vm, a login prompt fails to appear.

Is there any solution to this?

image

Did you try hitting enter?

Context on this is that incus console attaches to a serial console, just like a physical console, you don’t get any scrollback/buffer upon connection, so you have to get the other party to print you a login prompt or shell which is why you’d normally hit enter.

Thanks for the quick answer!

Yes i did try to hit enter, as well as most other buttons.

I figured something else out. If i log in to the console fast, then exit the shell properly before opening a new one, then it works the next time (bit jankily, only the password field appears, but after a failed login attempt everything is fine).

However it apparently is not possible to have multiple console sessions on different tty’s in that case?

It’s an emulated serial console. However, the normal procedure is to get a root shell directly inside a container or VM using incus shell <containername> which avoids this issue.

That doesn’t require any terminal, and doesn’t require you to login (or even for a password to be set on the root account). In the case of VMs it does require the incus agent to be running though.

i know how to connect to a shell. im running a vscode server, and doing that requires me to be in an actual console instead of the shell, else i get a variety of errors. (for example, systemctl --user status gives “Failed to connect to dbus: No medium found.”)

Thats the reason im trying to figure out a way to be able to connect to the console with a smaller failure rate. currently im restarting the vm every time i have to access the log of the systemd service or anything else that has to do with it, which is a bit suboptimal.

Try running su root from within the shell, that will get you a new PAM session which should make systemctl and others happy.

Yeah i thought so too, but that doesn’t help.

image

Ah, interesting, looks like a different behavior on Arch Linux.

stgraber@dakara:~$ incus launch images:ubuntu/22.04 u1
Launching u1
stgraber@dakara:~$ incus exec u1 bash     
root@u1:~# systemctl --user status
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
root@u1:~# su root
root@u1:~# systemctl --user status
● u1
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Wed 2024-04-17 16:03:47 UTC; 4s ago
   CGroup: /user.slice/user-0.slice/user@0.service
           └─init.scope 
             ├─200 /lib/systemd/systemd --user
             └─201 (sd-pam)
root@u1:~# 

Does running login get you a different behavior? That should be identical to using the text console.

yes that worked! thank you

ill use exec – login from now on