Run an Ubuntu VM on Apple Silicon

santisbon - Jan 25 '23 - - Dev Community

VirtualBox does not support ARM-based architectures like the Apple silicon on these Macs yet so we'll need another option. Multipass from Canonical can launch and run virtual machines (instances) and configure them with cloud-init like a public cloud. In fact it's my preferred way to launch Ubuntu instances regardless of whether VirtualBox is available for my system.

Get it with Homebrew:

brew install multipass
Enter fullscreen mode Exit fullscreen mode

See the list of images available:

multipass find
Enter fullscreen mode Exit fullscreen mode

Useful commands when managing instances.
multipass help
multipass list
multipass start
multipass restart
multipass mount /Volumes/USB primary
multipass stop
multipass delete --all
multipass purge
Enter fullscreen mode Exit fullscreen mode

We will:

  • Create an instance from the Ubuntu 22.04 LTS (Jammy Jellyfish) image.
  • Specify the number of CPUs, disk space, and amount of memory to allocate.
  • Give it a name. If the name is primary the user's home directory is mounted inside the newly launched instance, in Home. Without any arguments, commands for managing instances will apply to the primary instance.
  • Install a desktop environment and a Remote Desktop server.

Launch the instance

You can do this with cloud-init or without it (manual configuration).

With cloud-init

Create a configuration file. It will update/upgrade the system, install the packages we need, and create a new user (cloudy) with a password for us to log in with Remote Desktop. This example uses a plain text password for simplicity but adjust it to your environment's security needs.

cat << EOF > cloud-config.yaml
package_upgrade: true
packages:
  - ubuntu-desktop
  - xrdp
  - xsel
users:
  - default
  - name: cloudy
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
    lock_passwd: false
    plain_text_passwd: 'supersecretpwd'
EOF
Enter fullscreen mode Exit fullscreen mode

Launch the instance using the configuration file we created:

multipass launch jammy --cloud-init cloud-config.yaml --name primary --cpus 4 --disk 15G --memory 8G
Enter fullscreen mode Exit fullscreen mode

Without cloud-init

You could also configure the instance manually instead. In this case we don't need to create a new user, we'll just manually set a password for the default user and use that one.

multipass launch lts --name primary --cpus 4 --disk 15G --memory 8G
Enter fullscreen mode Exit fullscreen mode

Connect to the instance to install a desktop environment and a Remote Desktop server.

multipass shell
Enter fullscreen mode Exit fullscreen mode
sudo apt update && sudo apt upgrade -y
sudo apt install ubuntu-desktop xrdp -y
Enter fullscreen mode Exit fullscreen mode

Set a password for the default ubuntu OS user.

sudo passwd ubuntu
Enter fullscreen mode Exit fullscreen mode

Access the instance's desktop

To access the newly-installed desktop we need the IP address of the instance. Find it either by running the ip addr command within the Ubuntu shell or by running multipass list on your Mac host.

Then use that IP address to connect with an RDP client like Microsoft Remote Desktop (available on the App Store). You can use the default user ubuntu if you manually set its password or the user cloud-init created with the password you specified.

. . . . . . . . . . . . . . . . . . . . .
Terabox Video Player