On a Mac, you must open Virtual Machine - Settings. And choose Sharing to bring up a dialog where you can add the folders you want to be visible in Ubuntu. Just choose your home folder. Then turn on the file sharing button (or turn off and on again). Go to Ubuntu and check if you can see all your host system's files in /mnt/hgfs/.
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
- Download VirtualBox. Visit www.virtualbox.org/wiki/Downloads. Under VirtualBox binaries.
- 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.
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
Mac change icon for file. 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.
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:
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:
- Qemu is available in the contents of the ACVM app.
- Your target disk is created and ready.
- 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:
- 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).
- Drag and drop the Ubuntu.qcow2 file you created from Finder to the “Main Image” section.
- Darg and drop your ISO file you downloaded into the “CD Image (Optional)” section.
- Press “Start” button.
You should see a Window open up:
The window should quickly change to this:
Step 5 - Install Ubuntu
Run Ubuntu Vm On Mac Os
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:
- Remember to replace the paths in the command above according to where your ACVM app is and where your target disk is.
- 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. - The line
-m 4096
represents the amount of memory (RAM) available to the VM in Megabytes. Change according to your needs. - 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
Yes, there are problems that you will face even after doing all of that.
- Sometimes the VM’s display gets stuck. Going to fullscreen and exiting it helped.
- Command key might get mapped to Control inside the VM – this happened with me in the first launch after install and never happened again.
- 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.
- The resolutions that worked best for me (13-inch MacBook Air) were:
- 1360×768 – in Windowed mode.
- 1440×900 – in FullScreen mode.
- 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 Osx On Vm
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.
Run Mac Os In Vm
That’s all for now. Hope this post helped you!
Run Ubuntu Vm On Mac Free
PS: Apologies for any typos. I wrote this right after the experiment and staying up all night.