Running a Ubuntu VM on a Mac M1

If you’re brand-new to Python and Ansible, you might be a bit reluctant to install a bunch of packages and Ansible collections on your production laptop to start building your automation skills. The usual recommendation I make to get past that hurdle is to create a Ubuntu virtual machine that can be destroyed every time to mess it up.

Creating a virtual machine is trivial on Linux and MacOS with Intel CPU (install VirtualBox and Vagrant). The same toolset no longer works on newer Macs with M1 CPU (VMware Fusion is in tech preview, so we’re getting there), but there’s an amazingly simple alternative: Multipass by Canonical.

lima is another option (more details by Julia Evans), and it seems to be able to run x86 VM on an ARM CPU. I never tested it though so YMMV.

Here’a three-step process to getting a running Ubuntu VM on your Mac:

  • Install Multipass with brew install --cask multipass
  • Start the primary Ubuntu VM instance with multipass start. Once the VM is started, your home directory is mapped into the Home folder of the home directory of ubuntu user.
  • Connect to the VM with multipass shell
  • Enjoy ;)

Notes:

  • multipass is just a nice wrapper around the built-in MacOS hypervisor.
  • You’ll get an ARM version of Ubuntu. It looks like nobody solved the problem of running x86 virtual machines on M1 silicon yet.
ubuntu@primary:~$ uname -a
Linux primary 5.4.0-99-generic #112-Ubuntu SMP Wed Feb 2 17:13:12 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

4 comments:

  1. Or.... just use https://mac.getutm.app and voila, a little UI around Hypervisor.Framework.

    brew install utm
    

    three are many videos and many other sources: eg installing windows: https://www.youtube.com/watch?v=FWT5RGt26Ag

    UTM uses qemu, and qemu has Hypervisor.Framework support, done

    Replies
    1. Interesting... it looks like I could run x86 network devices (VMs) on Apple silicon. Have to check that out ;)

      Thanks a million for the pointer!

    2. i'm running (or trying to) Ubuntu 20.04 x86 in a Macbook pro M1 using UTM... It works but performance is horrible I'm not able to use it like that :(

  2. Performance might not be that good though. Not like native speed for sure.

  3. Get Parallels Desktop VM. Every flavor of Linux runs like a charm on the ARM64 architecture. And Windows 11 too.

  4. Note that multipass doesn't support USB pass-through.

Add comment
Sidebar