DEV Community

Cover image for How to install (Ubuntu 22.10 VM) vagrant on Mac M1 ship using QEMU
mouhssine nabil
mouhssine nabil

Posted on

How to install (Ubuntu 22.10 VM) vagrant on Mac M1 ship using QEMU

How to Ubuntu 22.10 (Kinetic Kudu) arm64 (Tested on macbook pro 2020 M1)

In this blog post, I will show you how to install and run vagrant on an M1 Mac using QEMU as the virtualization provider. Vagrant is a tool that simplifies the creation and management of virtual machines for development and testing purposes. QEMU is an open source emulator that can run various architectures, including arm64, which is the native architecture of the M1 chip.

Before we begin, make sure you have Homebrew installed on your Mac. Homebrew is a package manager that makes it easy to install software and dependencies. You can install Homebrew by following the instructions on their website: https://brew.sh/

Install QEMU

QEMU is the software that will emulate the arm64 architecture and run the virtual machine. To install QEMU, open a terminal and run the following command:

brew install qemu
Enter fullscreen mode Exit fullscreen mode

Find info about image here https://app.vagrantup.com/perk/boxes/ubuntu-22.10-arm64

Install vagrant-qemu plugin

vagrant plugin install vagrant-qemu
Enter fullscreen mode Exit fullscreen mode

Init Vagrantfile

vagrant init -m perk/ubuntu-22.10-arm64
Enter fullscreen mode Exit fullscreen mode

This will generate a minimal Vagrantfile that uses the perk/ubuntu-22.10-arm64 box as the base image. A box is a pre-packaged virtual machine image that contains an operating system and some software. The perk/ubuntu-22.10-arm64 box is an arm64 version of Ubuntu 22.10 (Kinetic Kudu), which is compatible with the M1 chip.

Alternatively, you can write your own Vagrantfile with more options and customizations. For example, you can add a line to forward a port from the guest to the host machine, like this:

Or edit vagrant file like the following

Vagrant.configure("2") do |config|  config.vm.network :forwarded_port, guest: 86, host: 1990  config.vm.box = "perk/ubuntu-22.10-arm64"end
Enter fullscreen mode Exit fullscreen mode

Run vagrant

This will download the box image if it is not already cached, create a new virtual machine based on the Vagrantfile, and boot it up using QEMU as the provider. You should see something like this:

vagrant up --provider qemu# orvagrant up
Enter fullscreen mode Exit fullscreen mode

SSH your OS

Once the virtual machine is up and running, you can access it via SSH by running:

vagrant ssh
Enter fullscreen mode Exit fullscreen mode

This will log you in as the vagrant user, which has sudo privileges and can run commands as root. You should see something like this:

Welcome to Ubuntu 22.10 (GNU/Linux 5.13.0-20-generic aarch64)

* Documentation: <https://help.ubuntu.com>
* Management: <https://landscape.canonical.com>
* Support: <https://ubuntu.com/advantage>

System information as of Fri Jun 9 20:54:10 UTC 2023

System load: 0.0 Processes: 103
Usage of /: 3.6% of 38.71GB Users logged in: 0
Memory usage: 7% IPv4 address for eth0: 10.0.2.15
Swap usage: 0%

* Super-optimized for your M1 Mac!

* Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
<https://ubuntu.com/livepatch>

0 updates can be installed immediately.
0 of these updates are security updates.

The list of available updates is more than a week old.
To check for new updates run: sudo apt update

*** System restart required ***
Last login: Fri Jun 9 20:54:10 2023 from 10.0.2.2
vagrant@ubuntu-22-10-arm64:~$

Enter fullscreen mode Exit fullscreen mode

👍 Now you can run any commands or install any software you want on the virtual machine, just like you would on a regular Ubuntu system.

Top comments (0)