Run an Ubuntu VM on an Apple M1 Mac

The simplest way to run an Ubuntu Linux virtual machine on a new Apple M1 chip macOS machine is to use Multipass.

First, install Multipass:

$ brew install --cask multipass

There should be a primary VM instance available already.

To start the primary Ubuntu instance:

$ multipass start

It should show:

Starting primary

Show running instances:

$ multipass list

The output should be similar to:

Name    State   IPv4         Image
primary Running 192.168.64.2 Ubuntu 20.04 LTS

Now we can SSH into the VM using:

$ multipass shell

You should see a prompt for the shell inside the Ubuntu VM:

ubuntu@primary:~$

Your Ubuntu VM is now ready to use!

Additionally, to mount a directory to access files from the host machine inside the VM, see this post:

Mount a Host Machine Directory Inside a Multipass VM

Mount a Host Machine Directory Inside a Multipass VM

To be able to access files on a host machine from a Multipass Ubuntu VM, we can mount the local directory into the virtual machine.

Assuming we have a host system directory my-stuff, we can mount it into the VM with:

$ multipass mount my-stuff primary:/home/ubuntu/my-stuff

Note the required name primary which refers to the VM instance name.

Check that the mount shows up correctly in Multipass:

$ multipass info primary

This should show your local and VM directory, with a line similar to:

Mounts: /Users/abc/Documents/my-stuff => /home/ubuntu/my-stuff

SSH into the VM to see the directory:

$ multipass shell
ubuntu@primary:~$ ls my-stuff
file1
file2
...

The directory should now be accessible inside the VM and we can share files between the host machine and VM.

Related Posts

Run an Ubuntu VM on an Apple M1 Mac

Rename a Branch in Git

Sometimes we need to rename an existing Git branch without creating a new branch or removing the old branch.

First, make sure you have the existing branch to rename checked out:

$ git branch

Output:

main
* old-name

To rename the branch use:

$ git branch -m old-name new-name

The command ‘m’ is short for “move”, similar to moving a file to rename it in Unix systems.

Confirm the new name:

$ git branch

Output:

main
* new-name