Version 10 (modified by jazz, 6 months ago) (diff) |
---|
Hackintosh
2024-05-28
- https://github.com/topics/hackintosh
- 使用星星數最多的 https://github.com/kholia/OSX-KVM 來做敲門磚
- 測試環境:AWS EC2 - 因為還有 60 美金左右的 credit 必須在 5/31 前用完
- Base OS: Ubuntu 24.04
jazzwang:~$ ssh kvm Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-1008-aws x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro System information as of Tue May 28 03:32:52 UTC 2024 System load: 0.08 Temperature: -273.1 C Usage of /: 0.8% of 192.69GB Processes: 133 Memory usage: 1% Users logged in: 0 Swap usage: 0% IPv4 address for ens5: 172.31.18.147 Expanded Security Maintenance for Applications is not enabled. 0 updates can be applied immediately. Enable ESM Apps to receive additional future security updates. See https://ubuntu.com/esm or run: sudo pro status The list of available updates is more than a week old. To check for new updates run: sudo apt update Last login: Tue May 28 03:32:55 2024 from x.x.x.x To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
(1) OSX-KVM
- 安裝必要的套件 Install QEMU and other packages.
- 由於 qemu 在 Ubuntu 22.04 LTS 是 dummy package, 在 Ubuntu 24.04 LTS 已經沒有這個套件。先拿掉再來看到底程式會用到什麼 QEMU 指令。
ubuntu@ip-172-31-18-147:~$ sudo apt-get update ubuntu@ip-172-31-18-147:~$ sudo apt-get install uml-utilities virt-manager git \ wget libguestfs-tools p7zip-full make dmg2img tesseract-ocr \ tesseract-ocr-eng genisoimage vim net-tools screen -y
ubuntu@ip-172-31-18-147:~$ cd ~; git clone --depth 1 --recursive https://github.com/kholia/OSX-KVM.git; cd OSX-KVM Cloning into 'OSX-KVM'... remote: Enumerating objects: 639, done. remote: Counting objects: 100% (639/639), done. remote: Compressing objects: 100% (563/563), done. remote: Total 639 (delta 46), reused 611 (delta 37), pack-reused 0 Receiving objects: 100% (639/639), 30.11 MiB | 31.63 MiB/s, done. Resolving deltas: 100% (46/46), done. Submodule 'resources/OcBinaryData' (https://github.com/acidanthera/OcBinaryData.git) registered for path 'resources/OcBinaryData' Cloning into '/home/ubuntu/OSX-KVM/resources/OcBinaryData'... remote: Enumerating objects: 1190, done. remote: Counting objects: 100% (398/398), done. remote: Compressing objects: 100% (381/381), done. remote: Total 1190 (delta 23), reused 32 (delta 16), pack-reused 792 Receiving objects: 100% (1190/1190), 67.73 MiB | 25.41 MiB/s, done. Resolving deltas: 100% (149/149), done. Submodule path 'resources/OcBinaryData': checked out '4e7e1b7465aae297d706afe5de5c4d1572d86917'
- 由於 qemu 在 Ubuntu 22.04 LTS 是 dummy package, 在 Ubuntu 24.04 LTS 已經沒有這個套件。先拿掉再來看到底程式會用到什麼 QEMU 指令。
- 啟用 KVM 模組。 KVM may need the following tweak on the host machine to work.
ubuntu@ip-172-31-18-147:~/OSX-KVM$ git pull --rebase Already up to date. ubuntu@ip-172-31-18-147:~/OSX-KVM$ sudo modprobe kvm; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs 1
- 由於確認過 CPU 是 Intel 的,就複製 kvm.conf
ubuntu@ip-172-31-18-147:~/OSX-KVM$ head /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 85 model name : Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz stepping : 7 microcode : 0x5003605 cpu MHz : 2499.996 cache size : 36608 KB physical id : 0 ubuntu@ip-172-31-18-147:~/OSX-KVM$ sudo cp kvm.conf /etc/modprobe.d/kvm.conf
- Add user to the kvm and libvirt groups (might be needed).
ubuntu@ip-172-31-18-147:~/OSX-KVM$ sudo usermod -aG kvm $(whoami) sudo usermod -aG libvirt $(whoami) sudo usermod -aG input $(whoami)
- Fetch macOS installer.
ubuntu@ip-172-31-18-147:~/OSX-KVM$ ./fetch-macOS-v2.py 1. High Sierra (10.13) 2. Mojave (10.14) 3. Catalina (10.15) 4. Big Sur (11.7) 5. Monterey (12.6) 6. Ventura (13) - RECOMMENDED 7. Sonoma (14) Choose a product to download (1-7): 6 Downloading 042-23155... Saving http://oscdn.apple.com/content/downloads/28/14/042-23155/4rscm4lvp3084gutfgpkwj5eex0yyxmzkt/RecoveryImage/BaseSystem.dmg to ./BaseSystem.dmg... Note: The total download size is 677.99 MB 340.0 MBs downloaded... Download complete!MBs downloaded... Saving http://oscdn.apple.com/content/downloads/28/14/042-23155/4rscm4lvp3084gutfgpkwj5eex0yyxmzkt/RecoveryImage/BaseSystem.chunklist to ./BaseSystem.chunklist... Note: The total download size is 2740 bytes Download complete!25 MBs downloaded... Verifying image with chunklist... Image verification complete!
- Convert the downloaded BaseSystem.dmg file into the BaseSystem.img file.
ubuntu@ip-172-31-18-147:~/OSX-KVM$ dmg2img -i BaseSystem.dmg BaseSystem.img dmg2img v1.6.7 (c) vu1tur (to@vu1tur.eu.org) BaseSystem.dmg --> BaseSystem.img decompressing: opening partition 0 ... 100.00% ok opening partition 1 ... 100.00% ok opening partition 2 ... 100.00% ok opening partition 3 ... 100.00% ok opening partition 4 ... 100.00% ok opening partition 5 ... 100.00% ok opening partition 6 ... 100.00% ok opening partition 7 ... 100.00% ok Archive successfully decompressed as BaseSystem.img
- Create a virtual HDD image where macOS will be installed.
ubuntu@ip-172-31-18-147:~/OSX-KVM$ qemu-img create -f qcow2 mac_hdd_ng.img 256G Formatting 'mac_hdd_ng.img', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=274877906944 lazy_refcounts=off refcount_bits=16
- CLI method (primary). Just run the OpenCore?-Boot.sh script to start the installation process.
ubuntu@ip-172-31-18-147:~/OSX-KVM$ ./OpenCore-Boot.sh
- 失敗,找不到 KVM。
ubuntu@ip-172-31-18-147:~/OSX-KVM$ sudo apt-get -y install xvfb tightvncserver xterm openbox tint2 ubuntu@ip-172-31-18-147:~/OSX-KVM$ vncserver ubuntu@ip-172-31-18-147:~/OSX-KVM$ export DISPLAY=:1 ubuntu@ip-172-31-18-147:~/OSX-KVM$ ./OpenCore-Boot.sh qemu-system-x86_64: warning: Unknown X11 keycode mapping '<null>'. Please report to qemu-devel@nongnu.org including the following information: - Operating system - X11 Server - xprop -root - xdpyinfo Could not access KVM kernel module: No such file or directory qemu-system-x86_64: failed to initialize kvm: No such file or directory
(2) OSX-Simple-KVM
- 參考: https://www.baeldung.com/linux/xcode
- https://github.com/foxlet/macOS-Simple-KVM
- 先安裝必要的套件
ubuntu@ip-172-31-18-147:~$ sudo apt-get install qemu-system qemu-utils python3 python3-pip
- 下載 git repo
ubuntu@ip-172-31-18-147:~$ git clone https://github.com/foxlet/macOS-Simple-KVM.git ubuntu@ip-172-31-18-147:~$ cd macOS-Simple-KVM/
- 用 jumpstart.sh 下載並轉換成 BaseSystem.img,執行 basic.sh 來跑 QEMU
ubuntu@ip-172-31-18-147:~/macOS-Simple-KVM$ ./jumpstart.sh ubuntu@ip-172-31-18-147:~/macOS-Simple-KVM$ ./basic.sh qemu-system-x86_64: -drive if=pflash,format=raw,readonly,file=/home/ubuntu/macOS-Simple-KVM/firmware/OVMF_CODE.fd: warning: short-form boolean option 'readonly' deprecated Please use readonly=on instead Could not access KVM kernel module: No such file or directory qemu-system-x86_64: failed to initialize kvm: No such file or directory
(3) Darling
- 類似 WINE (在 Linux 上模擬 Windows 執行環境)
- https://github.com/darlinghq/darling.git
- 參考
ubuntu@ip-172-31-18-147:~$ sudo apt install cmake automake clang-15 bison flex libfuse-dev libudev-dev pkg-config libc6-dev-i386 \ gcc-multilib libcairo2-dev libgl1-mesa-dev curl libglu1-mesa-dev libtiff5-dev \ libfreetype6-dev git git-lfs libelf-dev libxml2-dev libegl1-mesa-dev libfontconfig1-dev \ libbsd-dev libxrandr-dev libxcursor-dev libgif-dev libavutil-dev libpulse-dev \ libavformat-dev libavcodec-dev libswresample-dev libdbus-1-dev libxkbfile-dev \ libssl-dev libstdc++-12-dev ubuntu@ip-172-31-18-147:~$ GIT_CLONE_PROTECTION_ACTIVE=false git clone --recursive https://github.com/darlinghq/darling.git ubuntu@ip-172-31-18-147:~$ cd darling/ ubuntu@ip-172-31-18-147:~/darling$ git lfs install ubuntu@ip-172-31-18-147:~/darling$ git pull ubuntu@ip-172-31-18-147:~/darling$ git submodule update --init --recursive ubuntu@ip-172-31-18-147:~/darling$ sudo tools/uninstall Uninstall complete ubuntu@ip-172-31-18-147:~/darling$ mkdir build && cd build ubuntu@ip-172-31-18-147:~/darling/build$ cmake .. ubuntu@ip-172-31-18-147:~/darling/build$ make ubuntu@ip-172-31-18-147:~/darling/build$ make -j8 CC=distcc ## 如果有裝 distcc 的話 ubuntu@ip-172-31-18-147:~/darling/build$ sudo make install
- 雖然安裝成功,也可以裝 Xcode 跟 Homebrew,但根據文件的說法 GUI 應用程式多半都不能用。
- 看起來若要在 Linux 底下用 LINE,只有 Windows 版比較有機會。