Try Linux on your Mac with open source virtualization

Take Fedora out for a test run on your macOS machine using QEMU virtualization.
101 readers like this.
Woman programming

WOCinTech Chat. Modified by Opensource.com. CC BY-SA 4.0

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.

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.

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.

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.

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.

Step 4: Resize the QCOW2 image

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

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

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

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.

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

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

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

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

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

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

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.

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.

What to read next
User profile image.
Bryant Jimin Son is an Octocat, which not official title but likes to be called that way, at GitHub, a company widely known for hosting most open source projects in the world. At work, he is exploring different git technology, GitHub Actions, GitHub security, etc. Previously, he was a Senior Consultant at Red Hat, a technology company known for its Linux server and opensource contributions.

4 Comments

After executing step 5, I got these messages at the terminal window:
qemu-system-x86_64: -show-cursor: warning: The -show-cursor option is deprecated. Please add show-cursor=on to your -display options.
qemu-system-x86_64: -show-cursor: warning: When using the default display you can use -display default,show-cursor=on
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.svm [bit 2]

And the opened Qemu window displays at the end:
localhost Login:

Please advice

Hi Carlos,
I ended up replacing "-show-cursor" with "-display default,show-cursor=on" in the command, and that worked fine. As far as the "host doesn't support requested feature" message, a good deal of research led me to the conclusion that the feature in question is "SVM", which is AMD's virtualization technology in the CPU. If you're using an Intel CPU, I believe you can ignore this warning.

In reply to by Carlos Velez (not verified)

Same problem here.
How to solve?

I don't understand what the purpose of using a cloud base image is. What benefit does that provide over just creating a new qcow2 virtual disk with qemu-img create?

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.