go back to main page

Virtual Machines on linux

Here we supposed we are running Ubuntu 18.04 LTS and we simply install VirtualBox using apt :

sudo apt install virtualbox
sudo apt install virtualbox-ext-pack

Mac OS X

We will now install a macOS virtual machine. Virtual machine will be called VM in the following. The important thing before starting is to get the vmdk file for the version macOS version we want to run on the VM. The vmdk file is a Virtual Machine Disk define in an open format provided by VMware. For macOS 10.13 High Sierra you can get this file here. After downloading simply decompress to get the vmdk file:

unzip ../MacOS\ High\ Sierra\ 10.13\ \(Virtualbox\).zip 

For macOS 10.15 Catalina the vmdk file can be obtained here. Then you will need to have unrar to decompress it :

sudo apt install unrar unrar-free  # skip this if unrar is already installed
unrar e Catalina\ Virtual\ Disk\ Image\ by\ Intoguide.rar

Sometimes unrar files are coded with password, if it is the case try typing : intoguide.com

Start VirtualBox using command line or desktop icon. When the window appears click on New icon and fill the 3 values required, for Catalina, it is:

For High Siera, version is a little different :

Click next and set the memory to at least 4096 MB (5120 or 6144 MB will be nice if you have enough RAM on you computer)

Click next, select use an existing virtual hard disk file and click on the icon on the right to choose the vmdk file. For Catalina, it is macOS Catalina Virtual Disk Image.vmdk and for High Sierra MacOS High Sierra 10.13.vmdk.

Click create. After that a VM called macOS-Catalina should appear.

We will now modify some settings.

Click on settings icon.

Click on System. In the Motherboard tab, deselect Floppy. In the Processor tab, select 4 CPUs.

Click on Display. In Screen put display memory to the maximum 128 MB.

Click on Network. Set attached to: Bridged Adapter, the name: of the adapter should be ok, change it if not.

Click on USB and select USB 3.0

Then change directory to the folder where the VM has been created. If you do not know, clic File menu on VirtualBox window and the click Preferences…. Default Machine Folder: will give the path to the folder where the VM has been created:

cd /path/to/vm/folder
cd  macOS-Catalina

In this folder, a file called macOS-Catalina.vbox containing all the settings of the VM should exist. To have your VM working you need to manually patch this file with the following commands :

vmname=macOS-Catalina
VBoxManage modifyvm "${vmname}" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "${vmname}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

Very important setting for non Intel host CPU, e.g. AMD rizen5, must be defined :

VBoxManage modifyvm "${vmname}" --cpu-profile "Intel Core i7-6700K"

Now we can start the VM by clicking the Start icon. The press ESC key within 5 seconds to interrupt the boot process. A command line prompt will appear, type install.nsh :

Shell> install.nsh

Note : for High Sierra , you do not need to interrupt the boot with ESC, it should proceed directly to the install.

The installation will start and last for about 20 minutes. After that, you should have a working Mac OS Catalina VM … enjoy !!

go to top.


Additional Commands

To access the VM via SSH, add sharing in MacOS by clicking System Preferences icon and the Sharing. Allow remote login for the macos user, then you can access the MacOS VM from linux simply with ssh.

ssh bob@bobs-imac   # bob is the macos user name and bobs-imac is the macos hostname

You can get the hostname by typing hostname in a macos terminal.

To get the IP address of the VM, on a Mac OS terminal type :

ifconfig  # this list all the network devices , our is en0
ipconfig getifaddr en0

You also can access th VM in SSH with the IP address (IPADDR):

ssh bob@IPADDR

To mount on linux a shared macos folder, on mac VM select File Sharing (after clicking on System Preferences and *Sharing icons), select the Windows password for the user. The mount command on the linux side is :

sudo mount.cifs //IPADDR/SharedFolder /mnt/macos/ -o user=bob,nounix,sec=ntlmssp,noperm,rw

The IP address IPADDR can be replaced by the hostname, SharedFolder is the name of the macos shared folder and bob is the user name.

go to top.


Troublshouting

If you cannot drag windows inside the VM or if you cannot highlight a text area, it is probably due to a wrong mouse setting. No clear solution on the web, but a workaround is to add a second physical mouse that only operates in the VM, (see here how to do it).

go to top.