INSTALL OSX VENTURA (13.x) ON QEMU/KVM (Linux)

NOTE: for educational purposes only

GUIDE: Used OSX-KVM with modifications: https://github.com/kholia/OSX-KVM

  • I installed the latest QEMU (compiled from source):
    root@itamint:~/# apt install -y gcc make ninja-build libglib2.0-dev libpixman-1-dev ncurses-dev libusb-dev libusb-1.0-0-dev libusbredirparser1 libusbredirhost1 usbutils
    root@itamint:~# git clone https://github.com/qemu/qemu.git
    root@itamint:~#cd qemu
    root@itamint:~/qemu# ./configure –enable-vde –enable-libusb –prefix=/usr/local –target-list=”i386-softmmu x86_64-softmmu”
    root@itamint:~/qemu# make
    root@itamint:~/qemu# make install
    root@itamint:~/qemu# qemu-system-x86_64 –version
    QEMU emulator version 7.2.50 (v7.2.0-2313-g9832009d9d)

  • Install libvirtd/QEMU
    root@itamint:~# apt update -y
    root@itamint:~# apt install qemu-kvm qemu-system qemu-utils python3 python3-pip libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager cpu-checker -y
    root@itamint:~# usermod -aG root
    root@itamint:~# newgrp kvm
    root@itamint:~# systemctl enable libvirtd
    root@itamint:~# systemctl start libvirtd
    root@itamint:~# virsh net-start default
    root@itamint:~# virsh net-autostart default

    NOTE: this is to make networking config easy. We won’t use the qemu version 6.x installed above. We will use the much newer version we compiled earlier which we installed in /usr/local/bin/ whereas the one installed by the apt command puts qemu in /usr/bin/. To confirm you are using the right qemu, run “which qemu-system-x86_64”

  • Setup networking so that the VM has network access:
    I have put all the networking and firewall rules in a script which can then be executed with a command such as “sudo /home/itababa/setup_firewall.sh”

    itababa@itamint:~/OSX-KVM$ cat /home/itababa/setup_firewall.sh
    #!/usr/bin/bash

    # create a VDE switch and add a subnet range to it. also add an IP address to the switch as it will be the gateway for connected VMs:
    vde_switch -tap vde0 -daemon
    ip link set dev vde0 up
    ip addr add 10.0.2.1/24 dev vde0
    ip route add 10.0.2.0/24 dev vde0
    echo 1 > /proc/sys/net/ipv4/conf/vde0/proxy_arp

    # NOTE: it is possible to setup DHCP on the switch but I will be using static IPs in this guide

    # Internet access to the VMs (execute on the QEMU hypervisor host) where wlp5s0 is the WAN NIC on the Ubuntu QEMU host:
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -o wlp5s0 -j MASQUERADE
    iptables -I FORWARD 1 -i vde0 -j ACCEPT
    iptables -I FORWARD 1 -o vde0 -m state –state RELATED,ESTABLISHED -j ACCEPT

    # On the QEMU hypervisor (Linux) host, configure the rules for the ports to be forwarded to the OSX VM:
    iptables -A INPUT -p tcp –dport 2222 -j ACCEPT
    iptables -t nat -A PREROUTING -p tcp –dport 2222 -j DNAT –to-destination 10.0.2.100:22
    iptables -A INPUT -p tcp –dport 5905 -j ACCEPT
    iptables -t nat -A PREROUTING -p tcp –dport 5905 -j DNAT –to-destination 10.0.2.100:5900
    # end of networking script

  • “Install” OSX in the VM using OSX-KVM:

itababa@itamint:~/$ sudo echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs
itababa@itamint:~/$ sudo cp kvm.conf /etc/modprobe.d/kvm.conf

itababa@itamint:~/$ sudo groupadd kvm
itababa@itamint:~/$ sudo groupadd libvirt
itababa@itamint:~/$ sudo groupadd input

itababa@itamint:~/$ sudo usermod -aG kvm $(whoami)
itababa@itamint:~/$ sudo usermod -aG libvirt $(whoami)
itababa@itamint:~/$ sudo usermod -aG input $(whoami)

itababa@itamint:~/$ cd ~
itababa@itamint:~/$ git clone –depth 1 –recursive https://github.com/kholia/OSX-KVM.git
itababa@itamint:~/$ cd OSX-KVM
itababa@itamint:~/OSX-KVM$ pwd
/home/itababa/OSX-KVM

  • Fetch the Ventura Installer (option 6):
    itababa@itamint:~/OSX-KVM$ ./fetch-macOS-v2.py

  • Convert the downloaded BaseSystem.dmg file into the BaseSystem.img file.
    itababa@itamint:~/OSX-KVM$ dmg2img -i BaseSystem.dmg BaseSystem.img

  • Create a virtual HDD image where macOS will be installed.
    itababa@itamint:~/OSX-KVM$ qemu-img create -f qcow2 mac_hdd_ng.img 128G

  • Edit the OpenCore-Boot.sh script and make the following changes:
    – increase the RAM from 4096MB to 8192MB (ALLOCATED_RAM variable)
    – add avx2 to the CPU flags list (MY_OPTIONS variable)
    – change the CPU from Penryn to Cascadelake-Server-noTSX (only one that didn’t cause random freezing after installation and reboot loop during installation from the several I tested. Unfortunately the VM still freezes/hangs consistently between 10 and 12 minutes after startup.)
    – since we are VDE, comment out the default NIC entry starting with “-netdev user” and replace with our VDE line (see below).
    – Below is how the relevant lines looked in my modified OpenCore-Boot.sh file:
    root@itamint:/home/itababa/OSX-KVM# diff OpenCore-Boot.sh OpenCore-Boot.sh.org
    MY_OPTIONS=”+ssse3,+sse4.2,+popcnt,+avx,+avx2,+aes,+xsave,+xsaveopt,check”
    ALLOCATED_RAM=”8192″ # MiB
    -enable-kvm -m “$ALLOCATED_RAM” -cpu Cascadelake-Server-noTSX,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,”$MY_OPTIONS”
    -device virtio-net-pci,netdev=net0,mac=52:54:00:e6:5d:16 -netdev vde,id=net0
  • Run the OpenCore-Boot.sh script (with admin rights as root or using sudo) to create the VM and start the installation (this starts a VNC session listening on localhost:5901 for example. Use Mobaxterm/VNC or putty tunnel+VNC client to access the VNC session)
    itababa@itamint:~/OSX-KVM$ sudo ./OpenCore-Boot.sh
    VNC server running on 127.0.0.1:5901 (output of executing the OpenCore-Boot.sh script)
    NOTE: without “sudo” or “root” user, you will get an error similar to “Could not open vde: No such file or directory”

  • Connnect to the VNC session (using a VNC client):

  • Go through the installation steps (use Disk Utility to erase the target disk, then install Ventura)

  • Optional: Login into the OSX and enabled “remote management” (VNC) and “remote login” (SSH) (from “System Settings …” – it is no longer called “System Preferences”)

  • Optional: if you enabled “remote management” (VNC) and/or “remote login” (SSH), you can connect directly to the OSX VM via a VNC client (using the IP address of the Linux host and port 5901) and/or via SSH (using the IP address of the Linux host and port 2222). The connections work because we included the relevant forwarding rules in the firewall script (above).

  • Naviate to “System Settings” > Network > Ethernet > “Details…”. Assign a static IP address such as 10.0.2.100 (see the setup_firewall.sh script above) to the OSX with subnet mask 255.255.255.0 and Router 10.0.2.1 (IP address of the VDE switch). Also assign the VDE switch IP address as the DNS Server.

  • Optional: Update OpenCore-Boot.sh and comment out the 2 lines that attaches the installer disk to the VM i.e.,
    # -device ide-hd,bus=sata.3,drive=InstallMedia
    # -drive id=InstallMedia,if=none,file=”$REPO_PATH/BaseSystem.img”,format=raw
  • Optional: shutdown OSX. Modify OpenCore-Boot.sh so that it starts the VM “headless” (i.e., running as a background process):
    Comment out the line “-monitor stdio” and add a line below it with “-daemonize” without the double-quotes.

  • Start the VM in the (OSX-KVM directory) with the command: sudo ./OpenCore-Boot.sh

  • Configure the VM to auto-boots from the OSX disk, run the command at the UEFI shell:
    bcfg boot add 0 FS0:\EFI\boot\BOOT_X64.efi “my_boot”

  • Boot to OSX from the UEFI shell with the command sequence (ENTER key after each one): FS0: > cd EFI > cd BOOT > BOOTx64.efi

  • You can now connect to the OSX VM with VNC (Linux host IP and port 5905 in this example) or SSH (Linux host IP and port 2222 in this example).

NOTE: Several methods to attach a USB stick/device (e.g., one containing TimeMachine backups) to a QEMU VM

Option 1: In Linux Mint (Debian/Ubuntu), attached USB storage gets the group “disk”. So add your normal user to that group.
$ sudo usermod -aG disk itababa
$ newgrp disk

– Then add the device nodename of the USB device to the “args” list for QEMU in the OpenBoot-core.sh file (get the device file from the output of “blkid” or “lsblk” (e.g., /dev/sdb)
-hdc /dev/sdb

– you can also use the following 2x lines (equivalent to the single “-hdc /dev/sdb” line above)
-drive id=USBstick,if=none,file=”/dev/sdb”
-device ide-hd,bus=sata.5,drive=USBstick

Note: in OSX, since the USB is “direct-attached”, it is treated as a HDD. To make the volume appear on the desktop, go to “Finder” (menu) > “Settings”. Check/select/enable the “Hard disks” option.

Option 2: Add the USB device’s “location” to the args list for QEMU in the OpenBoot-core.sh file (get the hostbus and hostaddr from the output of the “lsusb” commmand). You must also change the permission on the device files (e.g., “sudo chmod o+rw /dev/bus/usb/002/*”). This operation does not survive a reboot of the physical host or re-insertion of the USB, so if you want it permanent consider UDEV rules):
-device qemu-xhci,id=usbxhci
-usb -device usb-host,hostbus=2,hostaddr=6

For example, in the “lsusb” output below, “Bus” is “hostbus” and “Device” is “hostaddr”
root@itamint:/home/itababa/OSX-KVM# lsusb

Bus 002 Device 006: ID 05dc:a838 Lexar Media, Inc. JumpDrive Tough

IMPORTANT NOTE: to prevent the OSX on QEMU from freezing/hanging (after about 10 mins uptime):
– Go to “System Settings …” > Energy Saver > Conserve battery > “Put hard disks to sleep when possible” disabled.
– Go to “System Settings …” > “Lock Screen” > “Turn display off when inactive” to “Never”
– Also, you MUST login to an account, if you leave the system on the login screen, it will freeze/hang.

* If you restore a time machine back along with “System & Networking”, check afterwards that the two settings above have not reverted to their defaults.

  • NOTE: Take snapshots often (e.g., before using “Migration Assistant” to restore TimeMachine backups from another OSX)
    – take an internal snapshot: qemu-img snapshot -c mac_hdd_ng.ss.030823.img mac_hdd_ng.img
    – list internal snapshots: qemu-img snapshot -l mac_hdd_ng.img
    – revert/restore to a snapshot: qemu-img snapshot -a mac_hdd_ng.ss.030823.img mac_hdd_ng.img
  • NOTE: IF “managed device attestation” is configured on your source OSX from which you restored a Time Machine backup, you may notice ACME (or a similar policy enforcement) app is installed and running.
    IF your source OSX is part of a corporate network, unless you decide to connect to the corporate VPN (unlikely for the purpose of this procedure), ACME won’t be able to validate your OSX VM config and may isolate your restored OSX VM (no networking access). To fix this, temporarily stop the ACME app, or permanently remove it:
    – Use the Utilities > “Activity Monitor” > to stop the ACME process
    – Go to Applications folder and delete (“move to trash”) the ACME app shortcut
    – Go to folder ~/Library/ and delete (“move to trash”) the ACME folder

References:
https://wiki.qemu.org/Documentation/Networking
https://documentation.suse.com/sles/15-SP2/html/SLES-all/cha-qemu-running.html
https://qemu-project.gitlab.io/qemu/system/qemu-cpu-models.html
https://kb.nmsu.edu/page.php?id=99123 (enable remote management i.e., VNC)
https://setapp.com/how-to/how-to-access-your-mac-remotely
https://www.qemu.org/2017/11/22/haxm-usage-windows/
https://qemu-project.gitlab.io/qemu/system/devices/usb.html
https://askubuntu.com/questions/15570/configure-udev-to-change-permissions-on-usb-hid-device/15643
https://unix.stackexchange.com/questions/141255/give-a-specific-user-permissions-to-a-device-without-giving-access-to-other-user
https://blog.programster.org/qemu-img-cheatsheet
https://www.linux-kvm.org/images/6/65/02x08B-Max_Reitz-Backups_with_QEMU.pdf
https://unix.stackexchange.com/questions/530674/qemu-doesnt-respect-the-boot-order-when-booting-with-uefi-ovmf
https://github.com/sickcodes/Docker-OSX
https://www.cyberciti.biz/faq/kvm-forward-ports-to-guests-vm-with-ufw-on-linux/
https://support.apple.com/guide/deployment/managed-device-attestation-dep28afbde6a/web

PALO ALTO VM on VirtualBox

NOTE: for educational purposes only.
NOTE: this procedure places a Oracle Enterprise Linux system "behind" a Palo Alto NGFW (firewall) and registers the OEL system with the ULN (Unbreakable Linux Network). It is part of investigation into an issue noticed with OEL 8.x in combination with Palo Alto v10.1.x/10.2.x where once a certain profile is applied on the Palo Alto, the OEL system is no longer able to communicate with the ULN (initial registration fails for new systems, and retrieving packages via yum fails for already registered systems). In one scenario, editing the file /etc/sysconfig/rhn/up2date and setting the useNoSSLForPackages=1 (default is 0) appeared to resolve the issue.

NOTE: For some reason, the Palo Alto qcow2 image does not boot up completely by default in VirtualBox. It boots up to the PA-HDF login prompt instead of the PA VM login prompt. The PA-HDF prompt implies the system has not booted up completely.

-----------------------------------------------------

Setup Palo Alto VM on VirtualBox:  https://nfv.dev/blog/2022/03/how-to-run-a-palo-alto-vm-series-firewall-in-virtualbox/

1. Convert the qcow2 disk image o hyper-v VHDX, setup Hyoer-V on your Windows 10 host, create a VM with the PA disk in Hyper-V, launch the VM, login ( be patient as it takes a while to get the "PA VM" prompt. The initial "PA-HDF" should be ignored. You might need to press ENTER key a few times for the prompt to change). Shut down the Hyper-V VM ("request shutdown system" command in PA). Then convert the VHDX disk to VMDK/VDI. Now use the new VMDK/VDI disk to create a VirtualBox VM. 

2. Convert PA qcow2 disk to VHDX:
C:\PaloAlto1010>c:\qemu\qemu-img.exe convert -f qcow2 PA-VM-KVM-10.1.0.qcow2 -O vhdx PA-VM-1010.vhdx   (qemu makes a sparse copy of the disk which is not supported by Hyper-V which will complain that the file must not be sparse: https://www.mail-archive.com/qemu-discuss@nongnu.org/msg04963.html)

3. Make a non-sparse copy of the VHDX disk using "copy" command or even the Windows Explorer copy. 
C:\PaloAlto1010>copy PA-VM-1010.vhdx PA-VM-1010a.vhdx

4. Create Hyper-V VM from PA-VM-10102a.vhdx, power it on, login, change password if prompted, shutdown the VM

Note that since the PA VM boots up properly on Hyper-V, you can use Hyper-V instead of VirtualBox. 

5. Convert VHDX to VDI after shutting down the Hyper-V VM:
C:\PaloAlto1010>c:\qemu\qemu-img.exe convert PA-VM-10102a.vhdx -O vdi PA-VM-1010.vdi


NOTE: default PA credential is admin/admin (it takes some time after boot-up for the credentials to be accepted i.e., the true login prompt when the system is fully up should be something like "PA VM" but you may initially be presented with the "PA-HDF" prompt)

-----------------------------------------------------


INITIAL BASIC CONFIG OF PALO ALTO VM TO SERVE AS INTERNET GATEWAY:  https://rowelldionicio.com/setting-up-palo-alto-networks-firewall-first-time/

My test config (all on a Windows 10 host system):
- OEL8.6 VM (VBox) <-----> PA 10.1.0 VM (VBox) <------> Windows 10 laptop (Host) <------> Home Internet Router
- IMPORTANT: all 4x NICs on the PA VM was enabled in VBox. First NIC is mgmt, second NIC is Ethernet1/1, third NIC is Ethernet1/2
- First and second NIC are bridged to the WiFi adapter in Windows 10 host so they can get DHCP IPs from my home router
- Third NIC (Ethernet1/2) is connected to the default "Internal Network" named "intnet" in VBox
- The single NIC attached to the OEL8.6 VM is also connected to the default "Internal Network" named "intnet" in VBox so that it can communicate with the PA VM which will serve as the DHCP server and gateway for the OEL8.6 VM
- NOTE: the PA 10.1.0 did NOT come with the "rule1" ACL (mentioned in the referenced URL above)that allows traffic between trusted and untrusted zone. You NEED to create the ACL rule.
- NOTE: you need to add a "Static Route"  (default route) to the default "Virtual Router" that sends all traffic to the Internet Router IP. For example, I created a "Static Route" nanmed "Default Route" with Destination 0.0.0.0/0 ; Interface ethernet1/1 ; Next Hop "IP Address" 192.168.10.1 (the LAN IP address of my home internet router)
- NOTE: you can add a second NIC to the OEL8.6 VM in Vbox and attach the NIC to the "Host-Only Adapter". This allows you to connect via SSH from the Windows 10 host to the OEL 8.6 for troubleshooting purposes.


- Other NOTES:
- install the UEK kernel on the OEL 8.6 VM:
[root@oel86vb ~]# yum install -y kernel-uek.x86_64

------------------------------------------------------


References:
How to run a Palo Alto VM Series Firewall in VirtualBox
https://docs.cloudstack.apache.org/en/4.11.2.0/adminguide/networking/palo_alto_config.html https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000CltrCAC https://docs.paloaltonetworks.com/pan-os/9-1/pan-os-admin/firewall-administration/use-the-web-interface\ https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000ClN7CAK https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000CloQCAS https://www.wiresandwi.fi/blog/palo-alto-basic-setup Oracle Linux: How to De-Register a System from ULN (Doc ID 2133228.1) ------------------- Register a system with ULN: [root@oel86 ~]# wget https://linux-update.oracle.com/rpms/uln_register_ol8.tgz [root@oel86 ~]# wget https://linux-update.oracle.com/rpms/uln_register-gnome_ol8.tgz [root@oel86 ~]# tar xf uln_register-gnome_ol8.tgz [root@oel86 ~]# tar xf uln_register_ol8.tgz [root@oel86 ~]# yum install -y *rpm [root@oel86 ~]# uln_register - use uln_register command for the interactive option or ulnreg_ks for the CLI option. The profilename is optional. Without it, the entry in ULN for the system will be named the system's hostname e.g., # ulnreg_ks --profilename=OEL86vbox --username=<my-registered-uln-email> --password=<my-oracle-support-password> --csi=<my-oracle-support-csi-#> De-register a system from ULN: - Login to the ULN registration page (http://linux.oracle.com ) and delete the registered system from ULN. You must login as the user that registered the system with ULN. - Select the System tab > Select the system to be removed and select the Delete button - Remove the system registration information from the local system. This can be done by removing the systemid file: # rm /etc/sysconfig/rhn/systemid - Setup the public yum repository files in /etc/yum.repos.d/ . Instructions for setting up public yum can be found at the following URL: http://yum.oracle.com/ --------------------------------- - Some commands: - Get details of the IP received via DHCP over the bridge to the host WNIC from the home router admin@PA-VM> show dhcp client mgmt-interface-state - Assign same IP permanently: configure set deviceconfig system type static set deviceconfig system ip-address 192.168.10.60 netmask 255.255.255.0 default-gateway 192.168.10.1 commit - Enable HTTPS web mgmt on the mgmt interface: set deviceconfig system service disable-https no set deviceconfig system service disable-ssh no set deviceconfig system service disable-icmp no commit - Retreive mgmt interface IP details: admin@PA-VM> show interface management - Graceful shutdown: admin@PA-VM> request shutdown system - Ping a host from the PA: admin@PA-VM> ping host 8.8.8.8 ---------------------------------

Building Microsoft CBL-Mariner (Linux) ISO

NOTE: I was able to build the ISO on Ubuntu 20.04 as the work platform (I got lots of errors with Ubuntu 18.04)

The only guide that worked for me is: https://www.techrepublic.com/article/microsoft-linux-is-not-what-you-think-or-hoped-it-would-be/ but I made some changes to the procedure (i.e., I built CBL-Mariner instead of CBL-MarinerDemo)

root@ub2004:/wip# add-apt-repository ppa:longsleep/golang-backports
root@ub2004:/wip# apt-get update
root@ub2004:/wip# apt -y install -y make tar wget curl rpm qemu-utils golang-1.15-go genisoimage python-minimal bison gawk
root@ub2004:/wip# apt -y install pigz
root@ub2004:/wip# ln -vsf /usr/lib/go-1.15/bin/go /usr/bin/go
root@ub2004:/wip# curl -fsSL https://get.docker.com -o get-docker.sh
root@ub2004:/wip# sh get-docker.sh
root@ub2004:/wip# usermod -aG docker $USER

root@ub2004:/wip# git clone https://github.com/microsoft/CBL-Mariner.git
root@ub2004:/wip# pushd CBL-Mariner/toolkit
root@ub2004:/wip/CBL-Mariner/toolkit# git checkout 1.0-stable
root@ub2004:/wip/CBL-Mariner/toolkit# make package-toolkit REBUILD_TOOLS=y
root@ub2004:/wip/CBL-Mariner/toolkit# cd ..
root@ub2004:/wip/CBL-Mariner# cp out/toolkit-1.0.20210722.0141-x86_64.tar.gz .
root@ub2004:/wip/CBL-Mariner# tar -xzvf toolkit-*.tar.gz
root@ub2004:/wip/CBL-Mariner# cd toolkit/
root@ub2004:/wip/CBL-Mariner/toolkit# make iso REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/full.json

root@ub2004:/wip/CBL-Mariner/toolkit# du -sh /wip/CBL-Mariner/out/images/full/full-1.0.20210722.0200.iso

678M /wip/CBL-Mariner/out/images/full/full-1.0.20210722.0200.iso

I was able to install the ISO on VirtualBox.

You can follow the steps on this page to install the output ISO on VirtualBox: https://linuxiac.com/microsoft-cbl-mariner-linux-1/

VMWare OVFTools required to build OVA CBL-mariner images (VHDX, OVA/VMDK)

– download 64-bit Linux VMWare-tools from https://my.vmware.com/group/vmware/downloads/details?downloadGroup=OVFTOOL441&productId=646
# chmod a+x VMware-ovftool-4.4.1-16812187-lin.x86_64.bundle
# ./VMware-ovftool-4.4.1-16812187-lin.x86_64.bundle
(NOTE: “./VMware-ovftool-4.4.1-16812187-lin.x86_64.bundle –uninstall-product vmware-ovftool” to uninstall)

– # make image REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/core-ova.json
(builds OVA, VMDK, and VMX files in CBL-Mariner/out/images/ )


– # make image REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/core-efi.json
(builds a 381MB VHDX file in CBL-Mariner/out/images/core-efi/ )

NOTE: in the VMDK file, the password field for the root user in the /etc/shadow file is set to <NULL>. Which meant that after creating a VM with the VMDK, I couldn’t login after I booted up the CBL-Mariner. I had to slave the VMDK to another VM, in order to manually change the <NULL> to the encrypted value of a known password. Alternatively, you can use the VMware disk tool to mount the VMDK after generating it on the Ubuntu instance, and edited the /etc/shadow file. On the other hand, the username and password for the CBLMarinerDemo is mariner_user  and p@ssw0rd

Installing Mac OSX 10.15 Catalina on HP EliteBook Folio 9740m

Installing Mac OSX 10.15 Catalina on HP EliteBook Folio 9740m


You need to create the Installation USB on a Mac (real or a VM).
You can find VM images for Mac OSX suitable for use with Oracle VirtualBox or VMWare Workstation on the Internet. In this research, I used the Mac OSX 10.13 High Sierra VM deployed on VirtualBox to create the Installation USB for Mac OSX Catalina (I had instability issues when I tried to use the Mojave/Catalina VMs). Please remember to follow the instructions associated with deploying the VM on VirtualBox/Workstation – e.g., there are “vboxmanage” commands you need to run otherwise the VM will be stuck in a continuous reboot loop.
Also I found out the hard way that the latest VirtualBox (6.1.4-136177) crashed my Windows laptop on which I deployed the Mac OSX VM consistently once I started the VM. I then tried the older VirtualBox version 6.0.18-136238 and that worked with no issues. Also note that on Linux, you must register the VM (“vboxmanage registervm “) before running the other vboxmanage commands specified in the procedure for deploying the VM. You also need to add the Linux user you are running VirtualBox as to the Linux group vboxusers otherwise you will not be able to attach a USB drive to the VM. Remmeber to install the VirtualBox extension pack as well.


  • Login to the mac OSX VM
  • Download “macoS Catalina Patcher” utility abd use it to download the macOS catalina installation files from Apple
  • Download https://github.com/chris1111/HP-Probook-EliteBook-Package-Creator
  • The instructions for running it to create the boot installation USB are on the same page. There is also an English walk-through video at https://www.hackintosh-montreal.com/t7559-hp-probook-elitebook-macos#111778
  • Summary:
    – run the “Gatekeeper” app (it is in the HP-ProBook-EliteBook-Package-Creator directory after you decompress the downloaded zip file);
    – run the Packager (needs Internet access) to create the “Create Install Media HP Laptop” app; attach a (minimum size 16GB) USB drive to the MAC oSX VM;
    – run the “Create Install Media HP Laptop” app which launches disk utility app where you need to erase the whole USB drive with “Format” set to “Mac OSX Extended (Journaled)”, “Scheme” set to “GUID Partition Map”.
    – once erase is completed, exit the disk utility and you will get a drive list from which you select the drive you just erased/formatted;
    – you then get a dialog box asking you to select the location of your “Install macOS Catalina.app” (either “10.9 to 10.12” OR “10.13.to 10.15”), then browse to where you downloaded the installation files and select the “Install macOS Catalina” installer; the HP Probook/EliteBook creator app will then copy files to the USB;
    – once completed, it will automatically launch the “Clover EFI” installation app, click the “continue” button, change the installation location to the USB drive that was just created (likely named “Install macOS Catalina”), click on the “Customize” button, the relevant selections for my laptop are below, then click “Install” button:

-> Install Clover in the ESP
-> Drivers off
-> Boot Sectors -> Install boot0af in MBR
-> Clover for BIOS (legacy) booting -> Clover EFI 64-bits SATA
-> BIOS Drivers, 64 bit -> Recommended drivers (all)
                                     -> File System drivers (all)
-> UEFI Drivers -> Recommended drivers (all)
                          -> File System drivers -> apfs, Fat, HFSPlus
                          -> Memory fix drivers -> OsxAptioFixDrv
                          -> Additional drivers -> OsxFatBinaryDrv, PartitionDxe
-> Themes (select all)
-> Drivers Kext -> FakeSMC, VoodooPS2Controller


  • Once done, copy the Gatekeeeper application and the HP-ProBook-EliteBook-macOS.pkg post-installation package to the USB drive volume “Install macOS Catalina”
  • Eject the USB drive and plug it to your target HP laptop
  • Power on your target laptop, press ESC key to interrupt the boot process, press F10 to enter BIOS setup – make the changes recommended on the “HP ProBook EliteBook Package Creator” web page then save and exit. For my laptop, the BIOS settings are: Deactivate Fast Boot, deactivate “SecureBoot”, set “Boot Mode” to “UEFI Hybrid (With CSM)”, deactivate LAN switching, deactivate Wake On LAN and Wake on USB, “SATA Device Mode” to “AHCI”, disable firewire/IEEE1394, disable “Trusted Execution Technology (TXT)”
  • Boot the target HP laptop with the USB drive, use disk utility to erase the laptop’s disk – if you only see volumes and not the disk devices, select “View -> Show All Devices” from the Disk Utility menu (if planning to multiboot, use disk utility to create all the partitions you need – in my example I erased the HDD using “GUID Partition Map” scheme, then created 3 partitions: OSXHDD, LINUXOS, WINOS. I set all the non-OSX partitions set to type ExFAT), install the macOS Catalina to your newly formatted OSX volume.
  • When completed, reboot with the USB in place, once started from the USB, select the option to boot from the OSX disk you just installed Catalina to – the install will continue – when it reboots again, select the option to boot from the OSX disk again, it may reboot again, select the OSX disk again, it will then boot to the GUI to complete the setup – go through the setup wizard to complete the configuration and create your login user account.
  • At the desktop, open the USB install drive (should be named “Install macOS Catalina”), copy the Gatekeeper and HP-ProBook-EliteBook-macOS.pkg to your Desktop.
  • Run gatekeeper and choose “Disable” to allow you to run software from any source
  • Run the Post-Installer “HP-ProBook-EliteBook-macOS.pkg”, change the installation target location to your laptop disk, select the customize button, and select all the options necessary for your specific laptop (see video on the creator web page), and complete the clover installation. My customized selection were as follows:

HP-ProBook-EliteBook-macOS
        -> HP Laptop Clover V2.5K r5103
                  -> 7 series macOS 10.12>10.15 -> Elitebook 9x70m
                  -> Intel HD 3000/4000 Graphics -> Intel HD 4000 -> Low screen 1366×768
                  -> HDMI -> HDMI Low screen
                  -> Fan Patch -> FanSmooth
        -> SSDT Generator
        -> Airport WIFI Fix -> AirportBrcmFixup (for Broadcom or Atheros for Atheros card)
        -> Bluetooth
        -> HWMonitor
        -> Applications

  • DO NOT reboot the laptop yet otherwise you will get kernel panics and it will be stuck in a loading/panic/reboot loop.
  • Open Terminal app:

# sudo su -
# mount -o rw /
# mkdir /tmp/efi
# df -h
# mount -t msdos /dev/disk0s1 /tmp/efi (*see note below)
# cd /tmp/efi/EFI/CLOVER/ACPI/patched/
# rm DSDT.dsl DSDT.aml SSDT.aml origin.dsl

Note: the EFI partition on the HDD may already be mounted (usually under /Volumes/ESP) so this mount command will throw a “Resource busy” error. If it is already mounted as /Volumes/ESP then you should “cd /Volumes/ESP/EFI/CLOVER/ACPI/patched/ ” in order to delete the files indicated above.

  • Edit /tmp/efi/EFI/CLOVER/config.plist and set the DefaultVolume to your OSX volume name, and the ScreenResolution key to your actual resolution (1366×768 for my laptop) if necessary.

# cd /
# diskutil umount /tmp/efi

Fix Sound: To get sound to work properly (AppleALC kext that comes with the post installer enables the headphone jack but not the in-built speaker), you need to use the VoodHDA kext:

  • Download VoodooHDA 2.9.2 install package from https://github.com/chris1111/VoodooHDA-2.9.2-Clover-V15/releases
  • Unzip the downloaded file and open/run the package
  • Click the Continue button (x3), agree to the license terms, then click the Customize button -> Expand “VoodooHDA Clover UEFI/ESP” -> Select “macOS Catalina” -> “Install”

Eject the USB install drive, and reboot your “Mac” laptop, it should come up with WiFI, LAN, SD card, and Sound fully functional.

NOTE: the SSDT.aml was responsible was responsible for the continuous reboot “memory panic stackshot succeeded …” kernel panic that made my laptop continuously reboot. The only file you should have in the EFI/CLOVER/ACPI/patched/ directory in the EFI partition on your boot volume is the SSDT-FIXCAT.aml

Bootloader Setup: The easiest way to use CLOVER bootloader is to mount the EFI partition and copy EFI\CLOVER\CLOVERX64.efi to EFI/Boot/BOOTX64.efi (yes, overwrite BOOTX64.efi if prompted). Note that if you are multi-booting and you installed Windows or Linux after installing Mac OSX, you may need to repeat the copy again afterwards if you still want to use CLOVER bootloader. Alternatively, you may setup your laptop (BIOS) to use CLOVER by setting up the BIOS: System Configuration -> Boot Options -> Define Customized Boot Option -> Add -> enter “EFI\CLOVER\CLOVERX64.efi” -> in “UEFI Boot Order” (Move “Customized Boot to the top position) -> Save -> Exit. If you choose this alternative option, you should delete any other file that is in EFI/Boot/ directory.

Fun stuff: You can cast sound or video or your laptop desktop to a recent TV such as the Samsung series 8 that supports AirPlay. If I select my TV, I am prompted for the Airplay code which is displayed on my TV. You can even decide whether to just mirror your desktop to the TV or use the TV as a second screen (“As Separate Display”)!

Other: In Microsoft Windows, to mount the EFI partition on a O/S disk, run “mountvol <driveletter>: /s” from any admin cmd.exe session. To mount the EFI partition on a USB drive, run “mountvol” which will list all available volume, you can then run “mountvol <driveletter>: <\\?\volume-name-as-displayed-in-mountvol-output>”

Disclaimer: if you like Mac OSX buy a real Mac. This is for educational research purposes only.

Acknowledgement: chris1111

Refs:
https://github.com/chris1111/HP-Probook-EliteBook-Package-Creator
https://www.hackintosh-montreal.com/t7559-hp-probook-elitebook-macos#111778
https://unix.stackexchange.com/questions/129305/how-can-i-enable-access-to-usb-devices-within-virtualbox-guests