UTM - Run Ubuntu Virtual Machine on Mac

This blog is a step by step guide on how to run a Ubuntu (Linux) Virtual Machine on MacOS using UTM (Open Source Virtual Machine Tool). Also the settings needed to share Clipboard and Directory between Ubuntu and MacOS.

Youtube video:

The video shows the step by step description of this blog

https://youtu.be/W8bAuhZSdIE



Download UTM

Download and Install UTM application on MacOS from

Download Ubuntu ISO file

Download Intel or AMD 64-bit architecture Ubuntu LTS iso file from

Create Ubuntu Virtual Machine

  1. Open UTM
  2. File Menu -> New
  3. Select Virtualize
  4. Select Linux
  5. Set Memory as 12288 MiB
  6. Set CPU Cores as 3 or higher
  7. Check Enable display output
  8. Uncheck Enable hardware OpenGL acceleration
  9. Click Continue
  10. Uncheck Use Apple Virtualization
  11. Select Boot Image Type as Boot from ISO image
  12. Click Browse and select the download Ubuntu LTS iso image
  13. Click Continue
  14. Set size of the drive as 64 GiB or higher
  15. Click Continue
  16. Do not set any shared directory at this point, we will setup the shared directory once Ubuntu installation is completed. Skip this step for now and click Continue
  17. In Summary, set Name as Ubuntu-Linux

Install Ubuntu

  1. Click the Play button next to Ubuntu-Linux to begin installation
  2. Using Keyboard, select Try or Install Ubuntu option and press Enter key
  3. Choose Language as English and click Next
  4. Skip Accessibility and click Next
  5. Select keyboard layout as English (UK) or English (US) or Indian and click Next
  6. For Internet, select Use wired connection
  7. Skip Update and click Next
  8. Select Install Ubuntu and click Next
  9. Select Interactive Install and click Next
  10. Select Extended selection and click Next
  11. Check Install third party software
  12. Check Install support for additional media formats
  13. Click Next
  14. Select Erase disk and install Ubuntu
  15. Click Next
  16. Set Your Name as ubuntu
  17. Set Computer Name as ubuntu-utm
  18. Set Your username as ubuntu
  19. Type password and confirm password
  20. Check Require my password to log in
  21. Uncheck use active directory
  22. Click Next
  23. Select your timezone and Click Next
  24. Click Install
  25. Once installation is complete, click Restart now
  26. When you see the message 'Please remove the installation medium', click 'Drive image options' icon on the top right corner, then hover on 'CD/DVD' and select 'Eject'. And then press Enter key
  27. Now the installation is complete and wait for the restart

Clipboard and Directory Sharing

The following settings or changes are very important to enable clipboard and directory sharing between Ubuntu and MacOS
  1. Show Apps -> Terminal and execute sudo apt install spice-vdagent spice-webdavd
  2. After installing the packages Power Off Ubuntu Machine
  3. In the UTM app, right click Ubuntu-Linux and select Edit
  4. Go to sharing secting
  5. Tick Enable clipboard sharing
  6. Set Directory Share Mode as 'SPICE WebDAV'
  7. Click Browse and choose any directory (eg Downloads) on MacOS
  8. Untick Read Only
  9. Click Save
  10. Start Ubuntu-Linux
Access the shared directory in browser at http://127.0.0.1:9843/
Or by executing the command in terminal
firefox http://127.0.0.1:9843/

Connect the shared directory in Files explorer
  1. Files -> + Other Locations -> Click Spice client folder
  2. Wait for another Spice client folder to appear in the Files under Networks.
  3. Double click the Spice client folder to open the shared directory
  4. To open the directory in Terminal go to the Address bar and Click Current folder Menu and select Open in Terminal
Note: The following command can be used to open the + Other Locations in Files application if it is not visible in Files due to screen resolution

nautilus other-locations:///

Manually mounting MacOS host directory

Follow the steps below to manually mount MacOS host directory to a different location

Install/Upgrade davfs2 package:
sudo apt-get install -y davfs2

Create a directory under user's home directory to mount:
mkdir $HOME/webdav_mount

Mount the MacOS host directory:
sudo mount -t davfs http://127.0.0.1:9843/ $HOME/webdav_mount
Leave username as empty and press Enter key
Leave password as empty and press Enter key

Access the host directory using Terminal:
cd $HOME/webdav_mount

Access the host directory using Files Explorer:
nautilus $HOME/webdav_mount

Adding multiple displays

Perform the following steps to add additional displays (monitor) for Ubuntu
  1. In the UTM app, right click Ubuntu-Linux and select Edit
  2. Click + New option and select Display
  3. Click the newly created Display section
  4. Select Emulated Display Card as virtio-gpu-pci
  5. Tick Resize display to window size automatically
  6. Click Save
  7. Restart the Ubuntu-Linux vm to see the addtional display (monitor)

Changing mouse scroll speed

Since this Ubuntu is a virtual machine, it doesn't have the ability to control the mouse scroll speed. To control the scroll speed in Ubuntu, adjust the scroll speed in host operation system (MacOS) using the following options for built-in touchpad or external mouse

MacOS -> System Settings -> Accessibility -> Pointer Control -> Trackpad Options -> Scroll Speed


MacOS -> System Settings -> Accessibility -> Pointer Control -> Mouse Options -> Scroll Speed

Change Ubuntu Settings

The following settings or changes are optional, but doing it makes the experience with Ubuntu smoother
  1. Show Apps -> Settings -> Mouse & Touchpad:
  2. Uncheck Mouse Acceleration
  3. Set Scroll Direction as Natural
  4. Show Apps -> Settings -> System -> Date & Time -> Clock & Calendar:
  5. Check Seconds
  6. Show Apps -> Settings -> Ubuntu Desktop
  7. Uncheck Show Home Folder
  8. In Dock -> Show on, select All displays
  9. Show Apps -> Settings -> Privacy & Security -> Screen Lock
  10. Blank Screen Delay: Never
  11. Automatic Screen Lock: Off
  12. Automatic Screen Lock Delay: Never
  13. Lock Screen on Suspend: Off
  14. Show Apps -> Settings -> System -> Users
  15. Click Unlock button to unlock administrator settings
  16. Automatic Login: On
  17. Change username or password if required

Comments

Popular posts from this blog

Export/Backup Ollama Model

Import self signed in Linux for Chrome / Chromium headless testing

JSON with curl and jq