Over the years, I’ve struggled with various operating systems and hardware. I’ve installed Ubuntu on old Mac laptops, only to have them fail due to motherboard issues. Fortunately, I managed to recover another laptop and reinstall Mac OS on it. I also tried Ubuntu on an HP laptop but eventually went back to Windows. I even bought a Framework laptop, but after struggling to get Ubuntu working properly, I decided to return it. I’ve experimented with Parallels, but it often crashes on my old Macs. Only thing that worked was using xfce on EC2 instances. But I wanted it to be fast - as if it was a local machine.

As a developer, finding a stable and efficient setup with Ubuntu has been a challenge. Virtual Box will not install on any of my Macs. Even VS Code crashes when connected to EC2 instances. Despite my best efforts, every approach I’ve tried so far has failed.

Lima Linux Machine

Lima is a tool that allows you to run Linux virtual machines (VMs) on macOS for development purposes. It provides a lightweight and efficient way to set up and manage Linux environments on your Mac.

In this article, we will create a Ubuntu virtual machine on M1 Mac mini (2020) Sonoma 14.1.1. It only has 8 GB memory. For quick experimentation purposes, this will work. Install Lima by following the instructions on its home page.


Install qemu on your Mac. I have:

Version of qemu
 qemu-system-x86_64 --version
QEMU emulator version 8.2.1
Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers

Using Lima

Here’s how you can use Lima for developing on a Mac:

Create a Ubuntu VM
limactl create ubuntu
Open the Shell
limactl shell ubuntu

You can now run commands from your machine that is executed on the VM:

Run Ubuntu Command
bparanj@lima-ubuntu:/Users/bparanj/work$ lsb_release -a
Ubuntu Version
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 23.10
Release:	23.10
Codename:	mantic
Check Default Timezone
bparanj@lima-ubuntu:/Users/bparanj/work$ timedatectl
Ubuntu 23 Default Timezone
               Local time: Tue 2024-03-19 10:14:47 EDT
           Universal time: Tue 2024-03-19 14:14:47 UTC
                 RTC time: Tue 2024-03-19 14:14:48
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Sharing Folders

On my laptop, I am in this folder:

Local Folder
bparanj@lima-ubuntu:/Users/bparanj/work$ pwd

You cannot create any folder from your anywhere on your machine:

Create Directory
bparanj@lima-ubuntu:/Users/bparanj$ mkdir ubuntu
mkdir: cannot create directory ‘ubuntu’: Read-only file system

You have to be inside the .lima folder that Lima created:

Lima Created Folder
$ pwd
$ cd ..
$ cd .lima
Lima Created Directories
$ ll
total 0
drwxr-xr-x   5 bparanj  staff  160 Feb 24 11:51 _config
drwx------  22 bparanj  staff  704 Feb 24 11:52 default
drwx------  22 bparanj  staff  704 Mar 19 10:13 ubuntu

Let’s see file sharing in action between the Mac and Ubuntu VM:

Create a File on Mac
$ cd ubuntu
$ pwd
$ echo 'this is a test' > test.txt

You can access the shared directory on the host macOS at: /Users/your-username/.lima/vm-name/

View this file on VM:

View Shared File on VM
bparanj@lima-ubuntu:/Users/bparanj/.lima/ubuntu$ ll
total 1975156
drwx------ 1 bparanj dialout        736 Mar 19 10:16 ./
drwx------ 1 bparanj dialout        160 Mar 19 10:12 ../
-rw-r--r-- 1 bparanj dialout  715849728 Feb 24 11:51 basedisk
-rw-r--r-- 1 bparanj dialout  257271808 Mar 19 10:12 cidata.iso
-rw-r--r-- 1 bparanj dialout 1049231360 Mar 19 10:17 diffdisk
srw------- 1 bparanj dialout          0 Mar 19 10:13 ga.sock=
-rw-r--r-- 1 bparanj dialout          6 Mar 19 10:12
srwxr-xr-x 1 bparanj dialout          0 Mar 19 10:12 ha.sock=
-rw-r--r-- 1 bparanj dialout      23726 Mar 19 10:13 ha.stderr.log
-rw-r--r-- 1 bparanj dialout        167 Mar 19 10:13 ha.stdout.log
-r--r--r-- 1 bparanj dialout          6 Mar 19 10:12 lima-version
-rw-r--r-- 1 bparanj dialout      23088 Mar 19 10:12 lima.yaml
-rw------- 1 bparanj dialout          6 Mar 19 10:12
srwxr-xr-x 1 bparanj dialout          0 Mar 19 10:12 qmp.sock=
-rw-r--r-- 1 bparanj dialout     115024 Mar 19 10:13 serial.log
srwxr-xr-x 1 bparanj dialout          0 Mar 19 10:12 serial.sock=
-rw-r--r-- 1 bparanj dialout          0 Mar 19 10:12 serialp.log
srwxr-xr-x 1 bparanj dialout          0 Mar 19 10:12 serialp.sock=
-rw-r--r-- 1 bparanj dialout        543 Mar 19 10:13 serialv.log
srwxr-xr-x 1 bparanj dialout          0 Mar 19 10:12 serialv.sock=
-rw------- 1 bparanj dialout        725 Mar 19 10:12 ssh.config
srw------- 1 bparanj dialout          0 Mar 19 10:13 ssh.sock=
-rw-r--r-- 1 bparanj dialout         15 Mar 19 10:16 test.txt
View File Contents on VM
bparanj@lima-ubuntu:/Users/bparanj/.lima/ubuntu$ cat test.txt
this is a test

I have two terminals open, the terminal with prompt bparanj@lima-ubuntu is the VM shell prompt and all commands are executed inside the VM. Another terminal has my Mac prompt. From this prompt I can run:

Open the Directory in Mac Finder
open .

to view the files in Mac finder.

You will get an error if you execute that command inside the VM:

Cannot Execute Mac Commands inside VM
bparanj@lima-ubuntu:/Users/bparanj/.lima/ubuntu$ open .
Command 'open' not found, but can be installed with:
apt install mailcap    # version 3.70+nmu1ubuntu1, or
apt install xdg-utils  # version 1.1.3-4.1ubuntu3
Ask your administrator to install one of them.

To stop the VM instance:

Stop the Ubuntu VM
$ limactl stop ubuntu
INFO[0000] Sending SIGINT to hostagent process 84926    
INFO[0000] Waiting for the host agent and the driver processes to shut down 
INFO[0000] [hostagent] Received SIGINT, shutting down the host agent 
INFO[0000] [hostagent] Shutting down the host agent     
INFO[0000] [hostagent] Stopping forwarding "/run/lima-guestagent.sock" (guest) to "/Users/bparanj/.lima/ubuntu/ga.sock" (host) 
INFO[0000] [hostagent] Unmounting "/Users/bparanj"      
INFO[0000] [hostagent] Unmounting "/tmp/lima"           
INFO[0000] [hostagent] Shutting down QEMU with ACPI     
INFO[0000] [hostagent] Sending QMP system_powerdown command 
INFO[0004] [hostagent] QEMU has exited