Lima VM - Linux Virtual Machines On macOS
Table of Contents
This article examines the Lima virtualization tool’s features. Earthly enables Lima users to streamline and parallelize their build processes on macOS. Learn more about Earthly.
WSL2 for macOS
I like my mac book pro. It’s not an M1, just a 2019 X86 MacBook. But it’s Unix based and POSIX compliant. One thing though, it’s certainly not Linux. If I want a Linux environment on my laptop, I need a VM.
Lima (LInux MAchine) is the simplest way I know of to get that virtual machine. Once it’s setup you just type lima in a terminal window to be placed in a Linux VM but with all your files and ports available. It’s like WSL2 but for macOS.
How It Works
Lima is powered by QEMU and is frequently used (via colima) to run containers on macOS. That is, it can be used as an alternative to docker desktop.
Ubuntu Setup
Let’s install it.
> brew install limaCheck your version:
> limactl --versionI’m going to install an ubuntu-lts. LTS stands for long term support meaning that there is a longer term commitment to update, patch, and maintain the software.
To see all the possible lima VM templates use `--list-templates:
> limactl start --list-templatesalmalinux
alpine
archlinux
buildkit
centos-stream
debian
default
deprecated/centos-7
docker-rootful
docker
experimental/9p
experimental/almalinux-9
experimental/apptainer
experimental/centos-stream-9
experimental/opensuse-tumbleweed
experimental/oraclelinux-9
experimental/riscv64
experimental/rocky-9
faasd
fedora
k3s
k8s
nomad
opensuse
oraclelinux
podman
rocky
singularity
ubuntu-lts
ubuntu
vmnetTo setup my first VM I use start:
> limactl start --name=default template://ubuntu-ltsWhich installs lts with name default.
After that I can jump into my linux shell by typing lima:
> uname
Darwin
> lima
> uname
LinuxAnd much like WSL2 on Windows, I have access to all my macOS files within Lima. One difference, however, is that I can not write to these files.
> lima
> touch file.txt
touch: cannot touch 'file.txt': Read-only file systemBut by default at least, I can write to files under /tmp/lima:
> lima
> cd /tmp/lima/
> touch lima.txtAll of this is configured in the VM template. The Ubuntu-lts templates specifies these like this:
mounts:
- location: "~"
- location: "/tmp/lima"
writable: trueWritable Ubuntu Setup
It’s possible to set a folder writeable, and it looks like Rancher (which uses lima under the covers on macOS) uses this configuration so let me try it.
First I stop lima:
> limactl stop defaultThen I edit it:
> limactl edit defaultI only need access to my sandbox folder, where I keep all git repos, so I’ll edit things to only mount that, but mount it as writable.
mounts:
- location: "~/sandbox"
writable: true Then I can start the VM back up( limactl start default) and lima into it and write and edit files all I want.
> lima
> echo "hello" > file.txt
> cat file.txt
helloIt should be noted that lima itself suggests a writable mount like this could be dangerous, but everyone is doing it.:
# CAUTION: `writable` SHOULD be false for the home directory.
# Setting `writable` to true is possible, but untested and dangerous.Conclusion
Lima seems to be a solid choice for a Linux terminal environment on MacOS. Some users have reported slow file system performance, but in my experience, using it in a limited capacity, I haven’t encountered such issues. And if you’re loving your new Linux set-up on macOS with Lima, consider leveling it up with Earthly for a smooth, efficient build process. It’s definitely worth checking out!
Earthly Lunar: Monitoring for your SDLC
Achieve Engineering Excellence with universal SDLC monitoring that works with every tech stack, microservice, and CI pipeline.



