Run Ubuntu Vm On Mac



In this blog post we’re going to create a Ubuntu 20.04 VM using QEMU on MacOS.

Note for users on macOS 11.0: follow this post first to get qemu to run.

Install macOS in the virtual machine. When you're done close Disk Utility, and you'll get to the macOS Utility dialog again. From this dialog choose Reinstall macOS. Click Continue a couple of times and you'll get to a screen where you must choose the HDD formatted in step 4: Next, click Install and the installation will begin: The virtual. On the Mac, the best VM tool I've used is Parallels - it manages to share CPU without hammering the battery. VirtualBox is good too, and for either of them you can install full Ubuntu Server from the ISO - 5GB disk and 1GB RAM allocation will be plenty if you're just looking around. Try out Ubuntu Appliance images in an isolated virtual machine on your PC or Mac with Multipass. Try out Ubuntu Appliance images in an isolated virtual machine on your PC or Mac with Multipass. Appliance Jump to main content. These appliances can all be run inside of a virtual machine, on your workstation, no extras required. VMware Fusion. is a great tool for developers when creating software for multiple operating systems. In this tutorial we saw, how easy it is to get a Ubuntu Desktop 20.04 VM running on a Mac. So far I’m impressed with how well Ubuntu 20.04 runs on VMware Fusion. How to Install VMWare Tools on Ubuntu 9.10 running under VMWare Fusion on Mac OS X 10.6?Helpful? Please support me on Patreon: https://www.patreon.com/roelv.

QEMU is a hardware emulator which can make use of different accelerators when running VMs. The most popular accelerator is KVM which is built into the Linux kernel and allows Linux hosts to run VMs with native performance.

Using QEMU on macOS used to be very slow as no accelerator was available. This changed 2 years ago when the project added support for the macOS native hypervisor with Hypervisor.framework (HVF) as an accelerator.

MacMac

Before we begin with the setup I assume that the Ubuntu 20.04 Desktop ISO has been downloaded in the current working directory.

QEMU Installation

We can use Homebrew to install QEMU. The version we’re using in this tutorial is 5.1.0:

It will pull in a few dependencies (the package depends on 14 other packages) and the installation can take a few minutes.

Create the disk image

Once the installation is done, we can create the disk image that we’re going to install Ubuntu on.

We’re using the QCOW2 format to create a 20GB image. This can be resized later on if needed. The Ubuntu installation took around 5GB of space when I installed it. Glassdoor crossover reviews. Free solitaire download for mac.

Boot machine with Ubuntu ISO mounted

We can now boot up the machine with the Ubuntu ISO attached as a

In this step we boot up the machine with the Ubuntu ISO mounted in the CD drive:

The options are:

  • -machine: The emulated machine and the accelerator. q35 is the newest machine type and HVF is the macOS native hypervisor.
  • -smp: Number of CPUs to use
  • -m: Amount of memory to use
  • -hda: Disk drive (the one we created earlier)
  • -cdrom: The ISO image to put into the CD drive
  • -vga: The graphic card to use. I found virtio (based on Virgil to have the best performance
  • -usb: Enable USB host controller
  • -device Adding a “usb-tablet” as an input device. I’m running this on a laptop and without this setting the mouse did not work.
  • -display: To show the mouse cursor (disabled by default)

During testing I had problems with the Linux kernel as it would panic during the boot process. The issue was the -cpu parameter. I fixed it by specifying the CPU architecture manually (see qemu-system-x86_64 -cpu help for a list of all available architectures).

My machine has an IvyBridge processor (Core i7):

And using -cpu IvyBridge would fail. However when using -cpu Nehalem (also an i7 CPU) everything worked well.

Now after the machine is booted up the Ubuntu installer will run. Follow the installation steps and don’t restart the VM at the end of the installation, instead shut it down by stopping the qemu process with CTRL-C on the host.

Boot without ISO mounted

When running the VM we don’t need the Ubuntu ISO mounted and can remove it by leaving out the -cdrom option:

Conclusion

In my experience QEMU is faster, more responsive and uses less CPU/RAM than VirtualBox. I didn’t have to configure any display scaling for HiDPI screens as it worked out of the box. The only thing I’m missing are shared clipboards and drag-and-drop of files (which are available when installing the VirtualBox Guest Additions).

At the time of writing this Blog Post, Apple Silicon’s first series of machines are out (the M1 SoC chip equipped MacBook Air, Macbook Pro 13-inch and Mac Mini). Docker is not yet fully stable (still in Tech Preview mode), there is no VMware Fusion for M1 and a lot of apps on Mac are still only targeted for x86_64 machines as of now. There is a Parallels Desktop release in Tech Preview mode which allows you to install Ubuntu but does not allow you to set the resolution of the resulting machine beyond 1024×768 pixels. There is no single blog/tutorial which guides you on how to make a Ubuntu (preferably 20.04) VM run on the M1 machines. I scoured the internet and put some pieces together to make it finally work.

Installing Ubuntu on a machine with M1 chip

There is a great article here about how to patch the Qemu source code and build it to get the binary but the link to the path which actually gets the job done is either broken or the patch has been deleted or it has been merged into the main branch of QEMU (which doesn’t seem to be the case).

Remember that if you install qemu via brew, it will not work because it does not know how to talk to the new Hypervisor Framework by Apple which is needed for virtualization on M1 machines. Also, this exercise was done on a Macbook Air with M1 processor but should work with other machines with the same chip. Let’s start:

Step 1 - Get the ACVM App

Get the ACVM app. The source code is here and you can compile it if you want but I just used the pre-built binary from this release though. So head to the release page and download the zip file and unzip it (if it doesn’t get automatically unzipped). I moved the app to /Applications but you can actually run it from anywhere you want. The commands in this post will assume that you have the ACVM app in /Applications folder.

Step 2 - Download Ubuntu for ARM

Run Ubuntu Vm On Mac

Download the Ubuntu Focal Desktop image for ARM machines. You can see the entire list of images here. Make sure you download the one named focal-desktop-arm64.iso. Note that you have to download the arm64 image, not the amd64 one.

You can also download the server image for ARM architecture from here and install the GUI later if needed.

Step 3 - Create target disk image

Create the disk image. For this you should run following commands:

Where to download free microsoft office for mac. This will create a 40 GB disk image which will be used as the primary disk for the VM that you want to create. Replace 40G with a size of your choice.

Step 4 - Launch ACVM

At this point of time, you already have everything you need:

  1. Qemu is available in the contents of the ACVM app.
  2. Your target disk is created and ready.
  3. You have the ISO file to install the VM from.

Now launch the ACVM app by double-clicking it in Finder. You should see this window:

Fill in the numbers and start the app:

  1. Enter the number of CPUs and RAM as you would like. I recommend you stick to the defaults of 4 CPUs and 4 GB RAM. They are enough to get started (you can change them later after the VM is installed).
  2. Drag and drop the Ubuntu.qcow2 file you created from Finder to the “Main Image” section.
  3. Darg and drop your ISO file you downloaded into the “CD Image (Optional)” section.
  4. Press “Start” button.

You should see a Window open up:

The window should quickly change to this:

Step 5 - Install Ubuntu

I recommend that you choose the “Install Ubuntu” option. While the “Try Ubuntu without installing” works, the window size is a little small for the install window to fit in (I could not increase the resolution in that “Trial” mode to fit the installer window).

Once your installation is over, you should get the Reboot or Continue Testing window in your Ubuntu. I recommend you press the “Continue Testing” button and then “Power Off” the VM from the menu inside your Ubuntu.

NOTE: It is possible that the machine still stays on in a hung state. Press Cmd+Q on your Mac to force close Qemu. There is no harm in it at this point.

Step 6 - Boot up installed Ubuntu

Now you need to boot the machine. Ensure that you are still in the /Applications/ACVM.app/Contents/Resources directory and enter the following command:

Mac

NOTES:

  1. Remember to replace the paths in the command above according to where your ACVM app is and where your target disk is.
  2. The line -smp 4,cores=4 asks Qemu to create a 4-core machine. Changing only one of the numbers didn’t work for me. Make sure you match the numbers.
  3. The line -m 4096 represents the amount of memory (RAM) available to the VM in Megabytes. Change according to your needs.
  4. All this hassle to using the ACVM app is to ensure that the line -accel hvf works. If you install qemu via brew, it will not recognise the hvf hypervisor (because it is still not there), which is the Apple’s Virtualisation Framework hypervisor.

This should launch your VM and you should get the following window:

Of course the username will be what you had put in.

NOTE: If you press Control+C on the terminal where you ran the launch command, the machine will die suddenly (as if power was lost). Make sure you shutdown the VM from within the VM window itself (or you can put an & at the end of the command and send it into background when launching the machine).

Ubuntu On Mac Mini

Result

Problems

Yes, there are problems that you will face even after doing all of that.

  1. Sometimes the VM’s display gets stuck. Going to fullscreen and exiting it helped.
  2. Command key might get mapped to Control inside the VM – this happened with me in the first launch after install and never happened again.
  3. In the same session (the first run after install), the VM behaved as if the Control key was pressed down all the time while the VM was running. This too never happened again.
  4. The resolutions that worked best for me (13-inch MacBook Air) were:
    • 1360×768 – in Windowed mode.
    • 1440×900 – in FullScreen mode.
  5. Running sudo apt update && sudo apt upgrade followed by a reboot solves a number of other problems (which I don’t remember as I am writing this) too.

Run Ubuntu Vm On Mac Download

Summary

Yes, the above mentioned Qemu-based solution is not flawless but it is way better than what I got with Parallel’s Desktop Technical Preview and the VM runs faster with Qemu in my observation as well. While you don’t have the fancy GUIs, Snapshotting feature and launching the VM can be a little verbose, this is the best solution you can have at this time. But then, you can always create good launch scripts to make life easier.

That’s all for now. Hope this post helped you!

PS: Apologies for any typos. I wrote this right after the experiment and staying up all night.