Try Linux on your Mac with open source virtualization | Opensource.com

Try Linux on your Mac with open source virtualization

Take Fedora out for a test run on your macOS machine using QEMU virtualization.

Woman programming
Image by : 
WOCinTech Chat. Modified by Opensource.com. CC BY-SA 4.0
x

Subscribe now

Get the highlights in your inbox every week.

Virtualization opens up a wonderland of new opportunities for anyone, including ordinary computer users who want to try out a new operating system. Are you using a Mac but want to try Microsoft Windows? You can, with a virtualization solution. What about if you are using Windows but want to try a macOS or a Linux platform? This is also possible with virtualization.

Various virtualization solutions exist. Mac users typically think of Parallels, but it is proprietary software. If you are a developer, you might know about VirtualBox. While VirtualBox is an excellent tool, there is another option: QEMU, which is an open source machine emulator and virtualizer available under the GPLv2 license.

qemu-0.jpg

QEMU home page

(Bryant Son, CC BY-SA 4.0)

This step-by-step tutorial explains how to use QEMU to run Fedora Linux on macOS. QEMU is also supported on pretty much every platform, including Windows and various Linux distributions.

If you prefer watching a video to reading, please see the YouTube version of this tutorial:

Step 1: Install QEMU with Homebrew

If you're not using macOS, visit QEMU's download page to install it for your operating system.

If you're using a Mac, you can use Homebrew to install QEMU. If you don't have Homebrew yet, Matthew Broberg's introduction to Homebrew will help you install and configure it.

To install QEMU with Homebrew, enter:

brew install qemu

This command should install all of QEMU's dependencies, utilities, and more.

qemu-1.png

Install QEMU with Homebrew

(Bryant Son, CC BY-SA 4.0)

Step 2: Download a Fedora ISO image for your workstation

Next, download a Fedora Workstation image you can use to boot a Fedora environment through QEMU. Fedora is an open source Linux distribution, and its primary license is GPLv2. One great thing about virtualization is, if you want to use a different platform, you can.

Get the Fedora Workstation ISO image by visiting the Fedora homepage and clicking the Download Now button under Fedora Workstation.

qemu-2.jpg

Download Fedora

(Bryant Son, CC BY-SA 4.0)

You want to download an ISO image, so click the Download button under x86_64. Save the file in a new directory that you can remember.

qemu-3.jpg

Click the ISO image under x86_64

(Bryant Son, CC BY-SA 4.0)

Step 3: Download a Fedora QCOW2 image for the file drive

In addition to the ISO image above (which is used for booting a Fedora Workstation), you also need a QCOW2 image, which stands for QEMU Copy On Write. QCOW2 uses a disk-storage optimization strategy that delays storage allocation until it is needed. The QCOW2 format is used by QEMU, OpenStack, and KVM.

Visit the Fedora Cloud Base images page and click the Download link next to Cloud Base Image for OpenStack. This will download the QCOW2 image; save the file in the same directory where you put your Fedora Workstation ISO image.

qemu-4.jpg

Click Download link in Cloud Base image for Openstack

(Bryant Son, CC BY-SA 4.0)

Step 4: Resize the QCOW2 image

You should have two files in this directory. You can check with the ls command.

qemu-5.png

an ISO file and a QCOW2 file

(Bryant Son, CC BY-SA 4.0)

The qemu-img command will allow you to resize the downloaded QCOW2 image to any size you want to allocate. Use this command to allocate 10GB for your drive:

qemu-img create -f qcow2 DOWNLOADED_QCOW2_FILE 10G

qemu-6.jpg

Allocating 10GB for a QCOW image

(Bryant Son, CC BY-SA 4.0)

Step 5: Run Fedora with QEMU

Run Fedora with the following qemu-system-x86_64 command:

 qemu-system-x86_64 \
-m 2048 \
-vga virtio \
-cdrom ./Fedora-Workstation-Live-x86_64-32-1.6.iso \
-accel hvf \
-show-cursor \
-usb \
-device usb-tablet \
-drive file=./Fedora-Cloud-Base-32-1.6.x86_64.qcow2,if=virtio

qemu-7.jpg

Run the qemu-system-x86_64 command

(Bryant Son, CC BY-SA 4.0)

Here is what this command does:

  1. qemu-system-x86_64 is the QEMU utility command.
  2. The -m parameter specifies how much RAM you want to allocate. This allocates 2GB, but you can increase it, if you would like.
  3. -vga specifies the graphic output in virtio-vga. This is a modern, virtio-based display device designed for virtual machines and includes VGA-compatibility mode.
  4. -cdrom specifies the file you will use to boot your workstation.
  5. -accel specifies the type of acceleration you want to use, which should be hvf for hardware-based acceleration.
  6. -show-cursor ensures that you see a mouse cursor.
  7. -usb specifies the input device.
  8. -device usb-tablet indicates you are using a touchpad as the input device.
  9. -drive file=… specifies the partition disk you want to use.

This will launch Fedora Workstation through QEMU.

Step 6: Install Fedora on QCOW2

In the QEMU window, choose the first option, Start Fedora-Workstation. This will boot Fedora in a standard way.

qemu-8.png

Choose Start Fedora-Workstation

(Bryant Son, CC BY-SA 4.0)

Booting can take little a little while, but it should go pretty smoothly.

qemu-9.png

Booting

(Bryant Son, CC BY-SA 4.0)

After it boots, you will have two options: Try Fedora and Install to Hard Drive. Choose Install to Hard Drive.

qemu-10.png

Select Install to Hard Drive

(Bryant Son, CC BY-SA 4.0)

You may see an empty screen, but things are loading.

qemu-11.png

Empty screen while Fedora is loading

(Bryant Son, CC BY-SA 4.0)

The first screen you see is the language selection menu. Choose the one you are comfortable with and click Continue.

qemu-12.png

Language options

(Bryant Son, CC BY-SA 4.0)

You will get an option to change other settings, such as time and date, but choose Installation Destination.

qemu-13.png

Choose Installation Destination

(Bryant Son, CC BY-SA 4.0)

Notice the disk with 10GB? That is the QCOW2 image you set up earlier. Choose that, and click Done.

qemu-14.png

Click Done

(Bryant Son, CC BY-SA 4.0)

Finally, click Begin Installation. It will take a while to install everything, but once everything finishes, you will get a welcome screen instead of an installation option.

qemu-15.png

Welcome screen

(Bryant Son, CC BY-SA 4.0)

That's it! As you can see, QEMU is a nice option for trying out a virtual environment without too much complexity and with open source.

I hope this helps you get started with Fedora through QEMU. Please try it out and share a comment about your experience.

Gift box opens with colors coming out

The Homebrew package manager makes it easy to install and update applications and utilities on a Mac.
Coffee and laptop

Elementary OS's latest release, Hera, is an impressive platform for resurrecting an outdated MacBook.
Hands programming

Thanks to a lot of open source developers, it's a lot easier to use Linux as your daily driver than ever before.
What is virtualization

Run, customize, and manage your VMs with open source Virt Tools. Plus get a glossary of key virtualization terms.

About the author

Bryant Son - Bryant Jimin Son is a Senior Consultant at Red Hat, a technology company known for its Linux server and opensource contributions. At work, he is working on building the technology for clients leveraging the Red Hat technology stacks like BPM, PAM, Openshift, Ansible, and full stack development using Java, Spring Framework, AngularJS, Material design. Prior to joining Red Hat, Bryant was at Citi Group's Citi Cloud team, building the private Infrastructure as a Service (IaaS) cloud platform...