Lima
Introduction
Lima is a VM tool that’s primarily used to run containers on MacOS.
In essence, Lima just provides you a Linux virtual machine. In reality, Lima is like the WSL2 for MacOS, or an alternative for UTM.
Running VMs
First, you install Homebrew. Then do this to spawn an up-to-date ARM64 Debian VM:
1brew install lima
2limactl create --name=default template:debian-13 --vm-type=vz
The virtual machine will start and persist. You get SSH access right away with
1lima
For other programs that need SSH access to the VM, prepend
1Include ~/.lima/*/ssh.config
to
1~/.ssh/config
on the MacOS host, and you will be able to ssh into the default VM with:
1ssh lima-default
Problems
Rosetta Compatibility Issue
You could add the --rosetta flag while doing limactl create to make it possible to run x86_64 programs on the VM. But with the current Linux kernel, you won’t be able to run anything that’s x86_64 this way: Rosetta2 has an issue.
Solution
When creating the VM, use Debian 12 (or anything with an old enough Linux kernel) like so:
1limactl create --name=default template:debian-12 --vm-type=vz --rosetta
Containers and statically linked binaries will run well, as long as you don’t upgrade the Linux kernel. Dynamically linked applications will need amd64(x86_64) libraries on your VM and that’s a topic for another post.
SSH Config Parsing
This is not a bug with Lima per se. In VSCode/Codium and the forks, sometimes Lima virtual machines just won’t show up in the SSH section in the Remote Explorer.
Solution
Make sure the Include directive is at the top of your ~/.ssh/config file, like this:
1Include ~/.lima/*/ssh.config
2Host my-other-server.com
3 Port 22