Managing homelab virtual machines from my phone
I think this is going to be part of a series breaking down how I use my phone as full desktop/laptop replacement. My Android phone is my best computer and rather than having a phone, laptop, and desktop, I want to merge all of them into a single device I carry with me everywhere. Then, where needed, I can use my homelab to fill in the gaps.
The more I use my phone as a laptop replacement, the more I want it to be my primary personal computing device and a replacement for any time I work on a PC. One way I am doing that is using Cockpit as a replacement for virt-manager for managing, creating, and deleting virtual machines on my homelab server running Ubuntu server 24.04. This enables me to do this from any browser, including on my phone in Dex-mode.
The purpose of virt-manager
I have a server with several virtual machines for services I make open to the public. I like to run these services in a VM to add an extra layer of security, rather than exposing them on the host. I also like to spin up new virtual machines for test projects so I can work non-destructively away from the host.
I know I can use virsh on the command line to do all the things needed for virtual machines, but I can never remember the syntax. I don’t use it often enough for it to stick and the syntax is obtuse in many ways. So, instead of trying to memorize commands, I prefer to use a GUI while managing virtual machines.
This is where virt-manager comes into play. It is so much easier to edit a VM xml file, create a snapshot, or make a new VM from a GUI. I also really like that I can double-click on a VM and open a window to start interacting with the VM directly.
I want this exact experience, only from my phone when I have it docked in desktop mode. Unfortunately, virt-manager is not available in Termux which led me to finding alternatives.
Managing VM’s with Cockpit
After installing Cockpit, all you have to do is install an add-on that enables working with virtual machines. Install on the server with:
sudo apt install cockpit cockpit-machines
Once installed, restart the service and then navigate to the Cockpit web UI. From there, you can find a virtual machine tab that includes nearly all of the options in virt-manager, plus a tab to view the console.
On new installations, before any virtual machines have been installed, it will default to vnc as a viewer and will then be availabe in the Cockpit virtual machines console tab. But, for existing machines that then has Cockpit installed after, you need to go into the VM xml file and change it from spice to vnc. It is best to do this whle the machine is off.
Doing it this way is hands-down the easiest way to manage a server and the virtual machines in a browser. After I installed Cockpit and some add-ons, I set it up to go through my reverse proxy, and configured Cockpit with MFA to be the most secure. I can now pop into Cockpit and perform various manintenance tasks, start/stop VMs, and create snapshots.
This doesn’t replace being able to ssh into any of the VM’s. Rather, this gives me a way to do some things with a GUI and to quickly pop into a VM to run one command, and then leave.
Alternative method - Linux proot desktop
There is another way to get this task done on an Android phone, but a little more complicated. I have a full Debian 12 Linux desktop configured on my Galaxy S10e, which can install virt-manager and then configure qemu+ssh to the server just like you would on any other desktop.
Doing it this way is handy and gives me a full working desktop for getting real work done. However, I don’t need to do that often and going into the proot environment is slower. I like this setup for the times I’m working at my desk on a project and want a full browser, terminal, and virt-manager open along with Obsidian for my notes.
But, most of the time I just need to run a single command or restart a VM, which is where Cockpit comes in handy.
- - - - -
Did you like this post? Give it an upvote by clicking on the arrows below! Sending me an upvote is like you and I giving each other a high five.
🙏 😎
Thank you for reading! If you would like to comment on this post you can start a conversation on the Fediverse. Message me on Mastodon at @cinimodev@masto.ctms.me. Or, you may email me at blog.discourse904@8alias.com. This is an intentionally masked email address that will be forwarded to the correct inbox.If you enjoy the random stuff I write here, post to Mastodon, or watch on YouTube, and are feeling generous, I am open to tips of Ko-fi.