Using Linux on Your M1-based Mac

Learn how to install Linux natively on M1 hardware, eliminating the need for macOS entirely.

Using Linux  on Your  M1-based Mac

Whether you're learning the Linux operating system, using Linux to manage your server fleet in the cloud, performing a cybersecurity penetration test using Linux tools or testing the web apps you’ve created on a Linux server, you can do it at near-native speed without costly software on an M1-based Mac system.

One of the biggest worries that IT pros have regarding Apple’s new ARM-based M1 platform is the ability to run virtual machines (VMs) of other operating systems using hypervisor software. And while it’s possible to run virtual machines of both Windows and Linux operating systems made for the Intel platform on the M1, the performance cost of translating Intel instructions to ARM is high (even with the optimizations Apple has within their M1 CPU). Luckily, the most common VM that an IT systems administrator or developer will install is Linux, and ARM versions of Linux have been common for well over a decade now.

Instead of buying an expensive Parallels or VMWare Fusion license to run a VM of Linux (slowly) on the M1, you can use the free Universal Turing Machine (UTM) app. UTM leverages the native hypervisor framework in macOS alongside the open source quick emulator (QEMU) framework that is used for virtualizing operating systems on Linux.

If you run an Intel version of Linux in UTM, QEMU will translate the Intel instructions to run on the M1, and there will be a noticeable performance cost. However, if you run an ARM version of Linux in UTM, QEMU will run it directly on the M1 at near native speed.

Better yet, the VirtIO storage bus used by QEMU and the Linux kernel can access the underlying storage in the Mac at near native speed. In short, UTM allows you to run ARM-based Linux VMs very fast on the M1 platform for free.

How to Create a Linux Server VM Using UTM

To get started, you should first download an ARM-based Linux distribution.

  • If you need a graphical desktop, I recommend the latest version of Fedora Workstation (shown below in UTM).
  • If you just want to host a server (no graphical desktop), I recommend Ubuntu Server as it will likely be the same one hosting your services and web apps in the cloud.

Download the DVD ISO image for the latest Fedora Workstation (aarch64) or download the DVD ISO image for the latest Ubuntu Server (ARM).

ARM-based Linux distribution in UTM

Figure 1: ARM-based Linux distribution in UTM

Next, you can perform the following steps to create a Linux server VM using UTM:

  1. Download the free version of UTM and copy it to your Applications folder.
  2. Open UTM and click + to create a new VM and click Start from Scratch.
  3. On the Information tab, supply an appropriate name and select Operating System from the Style drop-down box.
  4. On the System tab, select ARM64 (aarch64) from the Architecture drop-down box and specify the amount of memory you’d like to give your VM in the Memory dialog box.

    • For Linux with a graphical desktop (e.g., Fedora Workstation), specify 4096 to give your VM 4 GB (4096 MB) of memory.
    • For a Linux server without a graphical desktop (e.g., Ubuntu Server), specify 1024 to give your VM 1GB (1024 MB) of memory.
  5. On the Drives tab, click New Drive. Ensure that VirtIO is displayed in the Interface drop-down box, and type 127 in the Size dialog box (for a dynamically expanding virtual hard drive that uses up to 127 GB of storage). Then click Create.
  6. Click New Drive again, select the Removeable checkbox to create a USB drive (that we’ll later attach to the Linux DVD ISO you downloaded earlier). Click Create. At this point, your screen should look like this:
    Screenshot of Linux
  7. On the Network tab, select Bridged (Advanced) from the Network Mode drop-down box to ensure that your VM appears as a separate system on your network alongside macOS and then click Save.
  8. In the UTM window for your VM, select Browse from the CD/DVD drop-down box, select the Linux DVD ISO from your Downloads folder to insert it into the removable drive, and then click the large Play icon to start your VM. Some distributions validate the checksum of the DVD first. If you see a black window with the UTM logo in it for a few minutes, be patient - your Linux installer will start after the checksum is verified.
  9. Install your Linux distribution as you normally would. The 127 GB virtual disk will show up as /dev/vda instead of /dev/sda because we’re using the very fast VirtIO interface instead of emulating a SCSI, SATA or NVMe interface.

During the Linux installation, you’ll be prompted to create a regular user account (e.g., Jason). While this first user account is automatically added to the wheel or sudo group on your Linux distribution to allow it to run administrative commands as the root user, you should set the root user password following installation using the sudo passwd root command.

If you are a developer that needs a local Linux server for testing your web apps, you’ll need to install additional software packages. For example, to install the Apache web server, Very Secure FTP Daemon (for uploading files), MySQL/MariaDB database server and PHP (including the most useful plugins) on an Ubuntu Server, you could switch to the root user (su -) and run the following commands:

apt update

apt upgrade

apt install apache2 vsftpd mysql-server

mysql_secure_installation    #Configure your MySQL settings and password

apt install php libapache2-mod-php php-mysql phpmyadmin php-mbstring php-zip php-gd php-json php-curl

vi /etc/apache2/mods-enabled/dir.conf    #Add index.php to the DirectoryIndex line

systemctl restart apache2

While UTM can run ARM Linux at near native speed on macOS, you’ll soon be able to install Linux natively on M1 hardware, eliminating the need for macOS entirely. Most of this development is already done by those working on the Asahi Linux project. .

CompTIA Linux+ validates the skills employers need for Linux administrator jobs. Download the exam objectives to see what other Linux skills they look for.

Jason W. Eckert has been a UNIX (and later Linux) user/developer/sysadmin for more than 30 years, He has taught UNIX and Linux topics, including the vi text editor, in the college space for more than 20 years.

Email us at blogeditor@comptia.org for inquiries related to contributed articles, link building and other web content needs.

Read More from the CompTIA Blog

Leave a Comment