Quick Introduction into Using Tart for Virtualizing a Linux Machine on a MacOS System with Apple Silicon
The open-source Tart project (https://tart.run/) employs the Apple’s native Virtualization.Framework on M1/M2 chips to virtualize MacOS and Linux machines (VMs) at near native speed. And they do have the benchmarks to prove that claim.
However, the project lacks a graphical interface and relies on a command line utility to create and manage VMs. Luckily, the utility (also named tart) is capable and easy-to-use despite the lack of documentation (type tart help
to see all available commands).
Here is a quick step-by-step overview of how to install Tart and use it to setup your first Linux VM (ubuntu in this case).
Install tart
In a terminal (and assuming you have Homebrew installed), type
brew install cirruslabs/cli/tart
Setup and configure your VM
We will use the tart clone
command to download and install a pre-configured an ubuntu server VM
tart clone ghcr.io/cirruslabs/ubuntu:latest myvm
The command takes as its first argument a url referring to the preconfigured VM files (see here for a list of available VMs) and a string (I chose myvm) that we can use to refer to our VM in subsequent commands.
This will download a compressed VM image of under 1 GB in size and save it in your local configuration folder.
The image we installed has a reasonable configuration except for a very small disk. (You could inspect the current configuration using the tart get
command). Let us fix that using another tart command tart set
tart set myvm --disk-size 40
Run your VM
We can then use the tart run
command to start our newly installed VM using the VM name that we specified above.
tart run myvm
An ubuntu server will start in a separate window. That’s all there is to it.
From this point on, it’s like any other new Linux installation. You could log in at the prompt shown in the tart window using the username admin and the password admin. You could also ssh into the VM by running tart ip myvm
to get the VM’s IP address and then ssh as usual ssh admin@ip-address-from-the-previous-command
(of course, the password is still admin). You could also combine these two commands into one like this:
ssh admin@$(tart ip myvm)
Type sudo shutdown now
to shutdown the server and close the window.
Sharing folders between your MacOS and your VM
Let us say you have a folder on your MacOS machine that you would like to access from inside your VM. First, you will need to indicate the path to that folder when you start the VM:
tart run --dir=project:path_to_macos_folder myvm
project
here is the name that will be given to your folder within the VM and it can be anything you like. path_to_macos_folder
must be a valid path on your Mac.
Second, you need to run the following command from within your VM
sudo mount -t virtiofs com.apple.virtio-fs.automount /mnt
Your folder will be now accessible as /mnt/project