Run Ubuntu Vm On Mac



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.

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. 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. Run Ubuntu On Mac With Virtualbox (The Complete Guide) Virtual machine vs dual boot. There are two ways that we can run Ubuntu on the Mac. We can either setup a dual boot. In this tutorial we will learn how to install Ubuntu Desktop on a Mac OS X host using Virtualbox, a.

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

Run Ubuntu Vm On Mac Os

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

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.

Mac

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

Run

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

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:

Run ubuntu vm on mac
  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:

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).

Result

Problems

Mac

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

Run Mac Os In Vm

  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.

Summary

Run Ubuntu Virtual Machine On Mac

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!

Run Ubuntu Vm On Mac M1

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