important tweaks for running linux virtual machines on macos mojave

Viewing the same folder and its contents under Ubuntu 18.10 and macOS 10.14.

Last post I described installing Ubuntu 18.10 as a virtual machine on my Macbook Pro under macOS Mojave using Oracle VirtualBox. This post I want to describe some quick tweaks to set up and share a folder on the macOS file system with the virtual machine.

  1. When installing VirtualBox for the first time (and every time thereafter) make sure to install the Guest Additions. The Guest Additions allow tighter, more efficient integration of the guest VM with the host OS. It also allows for additional functions, such as shared folders between the host OS and the guest VM.
  2. On the macOS host side, create a folder you want to share with the VM. In my case I created ~/Shared to share. It will have no special permissions on the macOS side, just normal default read and write permissions.
  3. When initially creating the Ubuntu VM, in the VirtualBox section called Shared Folders, find and use the shared folder under macOS. Make sure it’s enabled read/write and automount.
  4. After installation and first boot, install the Guest Additions in the VM. First make sure the Ubuntu VM has the necessary build tools installed. If you performed a minimal installation (which I highly recommend) you can install those with ‘sudo apt install build-essential’.
  5. With the VirtualBox VM in the foreground, on the top menu (not Ubuntu’s menu), select Devices | Insert Guest Additions CD Image… A dialog will appear in the Ubuntu VM to auto run a script on the image it’s trying to mount. Simple select Cancel and allow the Guest Additions to mount on Ubuntu.
  6. Open a terminal and cd to /media/ubuntu/VBox_GAs_5.2.20. The path format is /media/[account]/[VBox_GAs_[version], so this path will be dependent on the account you created in the VM and the version of VirtualBox you currently have running. In my case I always create an account that’s the name of the distribution (ubuntu) and I’m currently using VirtualBox version 5.2.20 for this example.
  7. Inside that folder execute ‘sudo ./’. This will begin the process of building and installing all the necessary kernel modules for various features and optimizations. If you installed the essential build tools (or you installed everything up front) then the script will successfully execute, everything will build, and you’ll see a folder on your desktop that matches your shared folder name, with a ‘sf_’ prefix.
  8. Reboot.
  9. You’re not done yet. You need permissions on the Ubuntu/Linux side to access the shared folder. The shared folder is under /media/sf_[shared_folder_name]. it will have a group ownership of vboxsf (VirtualBox shared folder). You can sudo into it (sudo cd …) or you can add your account to the vboxsf group and avoid the annoyance. The fastest way to add your account to the group is to edit /etc/group. Open up /etc/group (sudo vi /etc/group) and find the vboxsf entry, at the very end of the file. Append your account name to the end (i.e. vboxsf:x:997:ubuntu in my case, where I added ‘ubuntu’ after the ‘:’). Save.
  10. Log out and log back in. At this point you can either cd into the folder or you can open up the link on your desktop.

Why do this? After all, VirtualBox supports drag-and-drop onto the VM’s desktop. The issue is duplication of files. If I want to work on the same set of files on both macOS as well as Ubuntu (think of develop and cross-testing) then I don’t want a lot of duplication (or any, actually) and I don’t want to loose track of which is more current, especially during source code development. And if I have more than one VM on my host system (and I have a half dozen at the moment) sharing a common folder is a major requirement.

running ubuntu 18.10 as a virtual machine under macos 10.14 mojave

I’ve installed the latest Ubuntu, 18.10 Desktop, or “Cosmic Cuttlefish”, as a VirtualBox VM on my MBP. The MBP is currently running macOS 10.14, or Mojave. The version of VirtualBox in use is 5.2.20 r125813.

After an extremely limited test run I’ve found nothing out of the ordinary with this release of Ubuntu and I can comfortably say that it should run well under just about any environment, bare silicon or virtualized. One key feature in this installer that I appreciate and I’ve not seen in any earlier Ubuntu release is the ability to install a minimal desktop. This installs just the desktop, basic utilities, and Firefox web browser. This is great for a custom install for any reason, as I’ve grown tired of the kitchen sink installations where I have to go back in and run a script to yank everything off I didn’t want installed in the first place.

Because I run under VirtualBox I always build and deploy the Guest Additions inside the VM. That requires gcc and the kernel headers be installed. These tools aren’t installed with the minimal setting. To get those tools you need to run ‘sudo apt install build-essential’ at the command prompt. If you want the Tweak Tool, then you need to run ‘sudo apt install gnome-tweak-tool’. The only reason to install the Guest Additions is to share/mount a local host folder within Ubuntu, to allow the easy passing of files between Linux and macOS. The Tweak Tool allows you to select the dark theme (Yaru-dark).

So far I find the desktop is easy to live with and to use. It’s a lot flatter than all prior releases using a stock desktop theme, and I appreciate that more than older themes with their pronounced skeuomorphic touches.

As for dev tools, I have python3 (3.6.7), gcc 8.2, perl 5.26, and git 2.19.1. I might put Java on this instance as well as Go, but right now I have more than enough programming capability. My only quibble with the tools is that Python isn’t up to 3.7, but at this juncture it’s close enough. If I need the latest formal release then I’ll install it the same way I installed 3.7 on my Raspberry Pi under Raspbian.