Lima – Linux Machines

🗓 Previously on Mac2net – I showed how to add packages with Brew

Lima – Linux Machines on a Mac (Intel or Apple M[x])

Virtual machines have been around for a long time. Over thirty years ago, I installed DOS on an early Power Macs to enable a corporate accounting department to run legacy software. Indeed, the virtual DOS ran much quicker than the previous x86 machines that were scrapped.


You may have heard about popular VM apps that run on MacOS, some free and some commercial, such as Parallels UTM, VMware Fusion, Virtual Box, but I am not going to demo any of those. Instead I am going to show you how to use Lima – on GitHub – and if you had used my Brew package installer script from a previous post, Lima is already installed and ready to go!


==> Fetching downloads for: lima
==> Downloading https://ghcr.io/v2/homebrew/core/lima/manifests/1.2.1
###########################################100.0%
==> Fetching lima
==> Downloading https://ghcr.io/v2/homebrew/core/lima/blobs/sha256:987df34a6ffc46d752c0c146f6a1130dd91d7299cb3ff175b8edfe3d
###########################################100.0%
==> Pouring lima--1.2.1.sonoma.bottle.tar.gz
==> Caveats
The guest agents for non-native architectures are now provided in a separate formula:
  brew install lima-additional-guestagents
==> Summary
🍺  /usr/local/Cellar/lima/1.2.1: 104 files, 42.9MB
==> Running `brew cleanup lima`...
Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
Removing: /Users/andrew/Library/Caches/Homebrew/lima--1.0.6.tar.gz... (7MB)
==> Caveats
zsh completions have been installed to:
  /usr/local/share/zsh/site-functions

Why run Lima on the Mac?

Unlike the other corporate sponsored VM technologies, Lima is open source package developed primarily for MacOS to run lightweight Linux virtual machines, with the corporates behind the Cloud Native Foundation, Lima’s technology sponsors.


lima


cncf


Lima is not opinionated – it offers templates for, as of this moment, 33 varieties of Linux and containers (more on containers later) as well as 12 experimental options and the ability for these templates to be modified according to one’s needs.


Run limactl start template://fedora to create a Lima instance named "fedora".
To open a shell, run limactl shell fedora bash or LIMA_INSTANCE=fedora lima bash.
⭐ = "Tier 1"
☆ = "Tier 2"

Default: default (⭐Ubuntu, with containerd/nerdctl)

Distro:
almalinux-8: AlmaLinux 8
almalinux-9: AlmaLinux 9
almalinux-10, almalinux.yaml: AlmaLinux 10
almalinux-kitten-10, almalinux-kitten.yaml: AlmaLinux Kitten 10
alpine: ☆Alpine Linux
alpine-iso: ☆Alpine Linux (ISO9660 image). Compatible with the alpine template used in Lima prior to v1.0.
archlinux: ☆Arch Linux
centos-stream-9, centos-stream.yaml: CentOS Stream 9
centos-stream-10: CentOS Stream 10
debian-12: Debian GNU/Linux 12(bookworm)
debian-13, debian.yaml: ⭐Debian GNU/Linux 13(trixie)
fedora-41: Fedora 41
fedora-42, fedora.yaml: ⭐Fedora 42
opensuse-leap, opensuse.yaml: ⭐openSUSE Leap
oraclelinux-8: Oracle Linux 8
oraclelinux-9, oraclelinux.yaml: Oracle Linux 9
rocky-8: Rocky Linux 8
rocky-9: Rocky Linux 9
rocky-10, rocky.yaml: Rocky Linux 10
ubuntu: Ubuntu (same as default.yaml but without extra YAML lines)
ubuntu-lts: Ubuntu LTS (same as ubuntu.yaml but pinned to an LTS version)
experimental/ubuntu-next: Ubuntu vNext
experimental/gentoo: [experimental] Gentoo
experimental/opensuse-tumbleweed: [experimental] openSUSE Tumbleweed
experimental/debian-sid: [experimental] Debian Sid
experimental/debian-13, experimental/debian-testing: [experimental] Debian GNU/Linux 13 (Trixie)
Alternative package managers:

linuxbrew.yaml: Homebrew on Linux (Ubuntu)
Container engines:

apptainer: Apptainer
apptainer-rootful: Apptainer (rootful)
docker: ⭐Docker
docker-rootful: Docker (rootful)
podman: Podman
podman-rootful: Podman (rootful)
LXD is installed in the default Ubuntu template, so there is no lxd.yaml
Container image builders:

buildkit: BuildKit
Container orchestration:

faasd: Faasd
k0s: k0s Zero Friction Kubernetes
k3s: Kubernetes via k3s
k8s: Kubernetes via kubeadm
experimental/u7s: Usernetes: Rootless Kubernetes
Optional feature enablers:

experimental/vnc: [experimental] use vnc display and xorg server
experimental/alsa: [experimental] use alsa and default audio device

Tier
"Tier 1" (marked with ⭐): Good stability. Regularly tested on the CI.
"Tier 2" (marked with ☆): Moderate stability. Regularly tested on the CI.
Other templates are tested only occasionally and manually.

Getting started with Lima

In the next post I am going demonstrate running Fedora server on both an Intel and Apple M[x] cpu. I figure there are still plenty of people out there with Intel machines that they would be happy to put to productive use – which this is – while going forward Lima is now becoming more optimised for Apple Silicon cpus.

I usually run Lima on an Intel Mac Mini rather than my personal MacBook Air, although it is installed on this machine as well, in order to avoid it swallowing up precious heavily Apple-taxed Apple Silicon RAM – although through testing I learned that the actual RAM used when running in the background is relatively small. My Mac Mini has a bare minimum 128GB SSD and 64GB RAM, so there are a few more steps required in order to prevent Lima from clogging up my internal SSD which I will explain.

What about Apple Containers?

Maybe you heard, maybe you didn’t – Apple is also developing virtualization technology for MacOS. And of course you can download it with guess what?


[user-machine]~$ brew install container 


I have it installed but I am not going to use this to install Fedora Linux. Why? Well I checked. The first release of Lima was on 14 May 2021. Right now Lima is much more mature than Apple’s Container technology. Like I said, self-hosting is not a religion. It is great to test technologies, but installing Fedora Linux on a Mac has substantial benefits for a person new to self-hosting – if it works. The goal is simple – getting comfortable with the mechanics of self-hosting including understanding the various key tasks and how the important mechanisms function.


IMO, Apple has put out Container to assist AI developers with big bucks and their powerful and expensive Mac Studios filled with 512GB RAM and 4TB SSDs. Apple Container is designed to help AI developers build, test and run clusters of AI VMs. Still, Container is easy to play with, if you have the time.


[user-machine]~$ container --help   
OVERVIEW: A container platform for macOS

USAGE: container [--debug] <subcommand>

OPTIONS:
  --debug                 Enable debug output [environment: CONTAINER_DEBUG]
  --version               Show the version.
  -h, --help              Show help information.

CONTAINER SUBCOMMANDS:
  create                  Create a new container
  delete, rm              Delete one or more containers
  exec                    Run a new command in a running container
  inspect                 Display information about one or more containers
  kill                    Kill or signal one or more running containers
  list, ls                List containers
  logs                    Fetch container logs
  run                     Run a container
  start                   Start a container
  stop                    Stop one or more running containers

IMAGE SUBCOMMANDS:
  build                   Build an image from a Dockerfile
  image, i                Manage images
  registry, r             Manage registry logins

VOLUME SUBCOMMANDS:
  volume, v               Manage container volumes

OTHER SUBCOMMANDS:
  builder                 Manage an image builder instance
  system, s               Manage system components