mirror of https://github.com/kholia/OSX-KVM.git
Merge 32f01d5cf6
into 6cf56dd2d1
This commit is contained in:
commit
4e712f7883
|
@ -1,7 +1,7 @@
|
|||
*.dist
|
||||
*.dmg
|
||||
*.img
|
||||
*.iso
|
||||
*.img
|
||||
*.pkg
|
||||
*.sha256sum
|
||||
*.smd
|
||||
|
|
Binary file not shown.
268
README.md
268
README.md
|
@ -1,3 +1,115 @@
|
|||
|
||||
### Ubuntu 22.04 Quick Install
|
||||
- Full install and activation uses wget and curl commands to run the full sequence so you don’t have to manually configure everything.
|
||||
|
||||
**Automatic Installation (one-liner)**:
|
||||
```
|
||||
sudo curl -fsSL https://raw.githubusercontent.com/kholia/OSX-KVM/master/wget.install.script | bash
|
||||
```
|
||||
**Or `wget` install**:
|
||||
```
|
||||
sudo wget https://raw.githubusercontent.com/kholia/OSX-KVM/master/wget.install.script -O wget.install.script
|
||||
```
|
||||
|
||||
#### macOS Recovery and Installation
|
||||
- Once OpenCore boots, you can download the macOS installer:
|
||||
```
|
||||
$ ./fetch-macOS-v2.py
|
||||
```
|
||||
Choose from:
|
||||
```shell
|
||||
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)
|
||||
8. Sequoia (15)
|
||||
|
||||
Select a product to download (1-8): 6
|
||||
```
|
||||
#### Disk Setup
|
||||
1. Select **Disk Utility** from the OpenCore menu.
|
||||
2. Reformat the `256 GB SATA` disk as APFS (or your preferred macOS format).
|
||||
3. Exit Disk Utility and go to **Install macOS**, selecting the formatted `SATA` disk.
|
||||
4. Follow the on-screen steps to complete the macOS installation.
|
||||
|
||||
#### Post-Installation
|
||||
- After installation completes:
|
||||
1. Open *KVM* (or *virt-manager*) and create a new VM.
|
||||
2. Assign your freshly installed `macOS SATA` disk.
|
||||
3. Begin building your new macOS VM with the following settings:
|
||||
- CPU: Match your host cores
|
||||
- RAM: Minimum *8 GB (recommended 16+ GB)*
|
||||
- Network: `VirtIO` or `bridged adapter`
|
||||
- Boot: `OpenCore.qcow2` + `macOS SATA` disk
|
||||
|
||||
- Boot the VM and macOS should start with OpenCore managing the EFI environment.
|
||||
- Optionally, you can keep `fetch-macOS-v2.py` handy to upgrade or reinstall newer macOS versions.
|
||||
|
||||
---
|
||||
|
||||
### Fedora 38+ Quick Install
|
||||
- Full install and activation uses wget and curl commands to run the full sequence so you don’t have to manually configure packages or dependencies.
|
||||
|
||||
**Automatic Installation**:
|
||||
|
||||
```
|
||||
sudo curl -fsSL https://raw.githubusercontent.com/kholia/OSX-KVM/master/wget.fedora.install.script | bash
|
||||
```
|
||||
**Or `wget` install**:
|
||||
```
|
||||
sudo wget https://raw.githubusercontent.com/kholi
|
||||
a/OSX-KVM/master/wget.fedora.install.script -O wget.fedora.install.script
|
||||
```
|
||||
|
||||
#### macOS Recovery and Installation
|
||||
- Once OpenCore boots, you can download the macOS installer using:
|
||||
```
|
||||
$ ./fetch-macOS-v2.py
|
||||
```
|
||||
Choose from:
|
||||
```
|
||||
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)
|
||||
8. Sequoia (15)
|
||||
|
||||
Select a product to download (1-8): 6
|
||||
```
|
||||
#### Disk Setup
|
||||
1. Open **Disk Utility** in the OpenCore menu.
|
||||
2. Reformat the `256 GB SATA` disk as APFS (or your preferred macOS format).
|
||||
3. Exit Disk Utility and select **Install macOS** on the formatted `SATA` disk.
|
||||
4. Follow the installer steps to complete macOS setup.
|
||||
|
||||
#### Post-Installation
|
||||
- After installation completes:
|
||||
1. Open *KVM* (or *virt-manager*)and create a new VM.
|
||||
2. Assign the freshly installed `macOS SATA` disk.
|
||||
3. Recommended VM settings:
|
||||
- CPU: Match host cores
|
||||
- RAM: Minimum *8 GB(16+ GB preferred)*
|
||||
- Network: `VirtIO` or `bridged adapter`
|
||||
- Boot: `OpenCore.qcow2` + `macOS SATA` disk
|
||||
|
||||
- Boot the VM; OpenCore handles the EFI environment and macOS should load.
|
||||
- Keep `fetch-macOS-v2.py` available for future upgrades or reinstallations.
|
||||
|
||||
---
|
||||
|
||||
#### Notes
|
||||
- Fedora users should ensure `kvm` modules are loaded and their user is added to `kvm` and `libvirt` groups.
|
||||
- Required Fedora packages installed by the script: `git`, `wget`, `curl`, `python3`, `python3-pip`, `qemu-kvm`, `qemu-img`, `virt-manager`, `libguestfs-tools`, `p7zip`, `make`, `dmg2img`, `tesseract`, `tesseract-langpack-eng`, `genisoimage`, `vim`, `net-tools`, `screen`.
|
||||
- Script handles automatic installation and verification of all dependencies.
|
||||
|
||||
---
|
||||
|
||||
### Note
|
||||
|
||||
This `README.md` documents the process of creating a `Virtual Hackintosh`
|
||||
|
@ -15,6 +127,7 @@ Working with `Proxmox` and macOS? See [Nick's blog for sure](https://www.nickshe
|
|||
|
||||
Yes, we support offline macOS installations now - see [this document](./run_offline.md) 🎉
|
||||
|
||||
---
|
||||
|
||||
### Contributing Back
|
||||
|
||||
|
@ -40,6 +153,7 @@ help (pull-requests!) with the following work items:
|
|||
|
||||
* (Not so) crazy idea - automate the macOS installation via OpenCV.
|
||||
|
||||
---
|
||||
|
||||
### Requirements
|
||||
|
||||
|
@ -53,170 +167,155 @@ help (pull-requests!) with the following work items:
|
|||
|
||||
* A CPU with AVX2 support is required for >= macOS Ventura
|
||||
|
||||
Note: Older AMD CPU(s) are known to be problematic but modern AMD Ryzen
|
||||
> [!Note]
|
||||
> Older AMD CPU(s) are known to be problematic but modern AMD Ryzen
|
||||
processors work just fine (even for macOS Sonoma).
|
||||
|
||||
---
|
||||
|
||||
### Installation Preparation
|
||||
|
||||
* Install QEMU and other packages.
|
||||
|
||||
```
|
||||
```
|
||||
sudo apt-get install qemu-system uml-utilities virt-manager git \
|
||||
wget libguestfs-tools p7zip-full make dmg2img tesseract-ocr \
|
||||
tesseract-ocr-eng genisoimage vim net-tools screen -y
|
||||
```
|
||||
```
|
||||
|
||||
This step may need to be adapted for your Linux distribution.
|
||||
- This step may need to be adapted for your Linux distribution.
|
||||
|
||||
* Clone this repository on your QEMU system. Files from this repository are
|
||||
used in the following steps.
|
||||
* Clone this repository on your QEMU system. Files from this repository are used in the following steps.
|
||||
|
||||
```
|
||||
```
|
||||
cd ~
|
||||
|
||||
git clone --depth 1 --recursive https://github.com/kholia/OSX-KVM.git
|
||||
|
||||
cd OSX-KVM
|
||||
```
|
||||
```
|
||||
|
||||
Repository updates can be pulled via the following command:
|
||||
- Repository updates can be pulled via the following command:
|
||||
|
||||
```
|
||||
```
|
||||
git pull --rebase
|
||||
```
|
||||
```
|
||||
|
||||
This repository uses rebase based workflows heavily.
|
||||
- This repository uses rebase based workflows heavily.
|
||||
|
||||
* KVM may need the following tweak on the host machine to work.
|
||||
|
||||
```
|
||||
```
|
||||
sudo modprobe kvm; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs
|
||||
```
|
||||
```
|
||||
|
||||
To make this change permanent, you may use the following command.
|
||||
Use `lscpu` if you are not sure.
|
||||
- To make this change permanent, you may use the following command.
|
||||
- Use `lscpu` if you are not sure.
|
||||
|
||||
```
|
||||
```
|
||||
sudo cp kvm.conf /etc/modprobe.d/kvm.conf # for intel boxes only
|
||||
|
||||
sudo cp kvm_amd.conf /etc/modprobe.d/kvm.conf # for amd boxes only
|
||||
```
|
||||
```
|
||||
|
||||
* Add user to the `kvm` and `libvirt` groups (might be needed).
|
||||
|
||||
```
|
||||
```
|
||||
sudo usermod -aG kvm $(whoami)
|
||||
sudo usermod -aG libvirt $(whoami)
|
||||
sudo usermod -aG input $(whoami)
|
||||
```
|
||||
```
|
||||
|
||||
Note: Re-login after executing this command.
|
||||
> [!Note]
|
||||
> Re-login after executing this command.
|
||||
|
||||
* Fetch macOS installer.
|
||||
|
||||
```
|
||||
```
|
||||
./fetch-macOS-v2.py
|
||||
```
|
||||
```
|
||||
|
||||
You can choose your desired macOS version here. After executing this step,
|
||||
you should have the `BaseSystem.dmg` file in the current folder.
|
||||
- You can choose your desired macOS version here. After executing this step, you should have the `BaseSystem.dmg` file in the current folder.
|
||||
|
||||
ATTENTION: Let `>= Big Sur` setup sit at the `Country Selection` screen, and
|
||||
other similar places for a while if things are being slow. The initial macOS
|
||||
setup wizard will eventually succeed.
|
||||
> [!Important]
|
||||
> Let `>= Big Sur` setup sit at the `Country Selection` screen, and other similar places for a while if things are being slow.
|
||||
> The initial macOS setup wizard will eventually succeed.
|
||||
|
||||
Sample run:
|
||||
|
||||
```
|
||||
$ ./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)
|
||||
8. Sequoia (15)
|
||||
|
||||
Choose a product to download (1-8): 6
|
||||
```
|
||||
|
||||
Note: Modern NVIDIA GPUs are supported on HighSierra but not on later
|
||||
versions of macOS.
|
||||
> [!Note]
|
||||
>
|
||||
> Modern NVIDIA GPUs are supported on HighSierra
|
||||
> But not on later versions of macOS.
|
||||
|
||||
* Convert the downloaded `BaseSystem.dmg` file into the `BaseSystem.img` file.
|
||||
|
||||
```
|
||||
```
|
||||
dmg2img -i BaseSystem.dmg BaseSystem.img
|
||||
```
|
||||
```
|
||||
|
||||
* Create a virtual HDD image where macOS will be installed. If you change the
|
||||
name of the disk image from `mac_hdd_ng.img` to something else, the boot scripts
|
||||
will need to be updated to point to the new image name.
|
||||
* Create a virtual HDD image where macOS will be installed. If you change the name of the disk image from `mac_hdd_ng.img` to something else, the boot scripts will need to be updated to point to the new image name.
|
||||
|
||||
```
|
||||
```
|
||||
qemu-img create -f qcow2 mac_hdd_ng.img 256G
|
||||
```
|
||||
```
|
||||
|
||||
NOTE: Create this HDD image file on a fast SSD/NVMe disk for best results.
|
||||
> [!NOTE]
|
||||
> Create this HDD image file on a fast SSD/NVMe disk for best results.
|
||||
|
||||
* Now you are ready to install macOS 🚀
|
||||
|
||||
---
|
||||
|
||||
### Installation
|
||||
### Manual Installation
|
||||
|
||||
- CLI method (primary). Just run the `OpenCore-Boot.sh` script to start the
|
||||
installation process.
|
||||
- CLI method (primary). Just run the `OpenCore-Boot.sh` script to start the installation process.
|
||||
|
||||
```
|
||||
```
|
||||
./OpenCore-Boot.sh
|
||||
```
|
||||
```
|
||||
|
||||
Note: This same script works for all recent macOS versions.
|
||||
> [!Note]
|
||||
> This same script works for all recent macOS versions.
|
||||
|
||||
- Use the `Disk Utility` tool within the macOS installer to partition, and
|
||||
format the virtual disk attached to the macOS VM. Use `APFS` (the default)
|
||||
for modern macOS versions.
|
||||
- Use the `Disk Utility` tool within the macOS installer to partition, and format the virtual disk attached to the macOS VM. Use `APFS` (the default) for modern macOS versions.
|
||||
|
||||
- Go ahead, and install macOS 🙌
|
||||
|
||||
- (OPTIONAL) Use this macOS VM disk with libvirt (virt-manager / virsh stuff).
|
||||
|
||||
- Edit `macOS-libvirt-Catalina.xml` file and change the various file paths (search
|
||||
for `CHANGEME` strings in that file). The following command should do the
|
||||
trick usually.
|
||||
- Edit `macOS-libvirt-Catalina.xml` file and change the various file paths (search for `CHANGEME` strings in that file). The following command should do the trick usually.
|
||||
|
||||
```
|
||||
```
|
||||
sed "s/CHANGEME/$USER/g" macOS-libvirt-Catalina.xml > macOS.xml
|
||||
|
||||
virt-xml-validate macOS.xml
|
||||
```
|
||||
```
|
||||
|
||||
- Create a VM by running the following command.
|
||||
- Create a VM by running the following command.
|
||||
|
||||
```bash
|
||||
```bash
|
||||
virsh --connect qemu:///system define macOS.xml
|
||||
```
|
||||
```
|
||||
|
||||
- If needed, grant necessary permissions to libvirt-qemu user,
|
||||
- If needed, grant necessary permissions to libvirt-qemu user,
|
||||
|
||||
```
|
||||
```
|
||||
sudo setfacl -m u:libvirt-qemu:rx /home/$USER
|
||||
sudo setfacl -R -m u:libvirt-qemu:rx /home/$USER/OSX-KVM
|
||||
```
|
||||
```
|
||||
|
||||
- Launch `virt-manager` and start the `macOS` virtual machine.
|
||||
|
||||
---
|
||||
|
||||
### Headless macOS
|
||||
|
||||
- Use the provided [boot-macOS-headless.sh](./boot-macOS-headless.sh) script.
|
||||
|
||||
```
|
||||
```
|
||||
./boot-macOS-headless.sh
|
||||
```
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Setting Expectations Right
|
||||
|
||||
|
@ -224,15 +323,20 @@ Nice job on setting up a `Virtual Hackintosh` system! Such a system can be used
|
|||
for a variety of purposes (e.g. software builds, testing, reversing work), and
|
||||
it may be all you need, along with some tweaks documented in this repository.
|
||||
|
||||
However, such a system lacks graphical acceleration, a reliable sound sub-system,
|
||||
USB 3 functionality and other similar things. To enable these things, take a
|
||||
> [!Note]
|
||||
> However, such a system lacks graphical acceleration, a reliable sound sub-system,
|
||||
|
||||
#### For USB 3 functionality and other similar things
|
||||
**To enable these things**:
|
||||
- take a
|
||||
look at our [notes](notes.md). We would like to resume our testing and
|
||||
documentation work around this area. Please [reach out to us](mailto:dhiru.kholia@gmail.com?subject=[GitHub]%20OSX-KVM%20Funding%20Support)
|
||||
if you are able to fund this area of work.
|
||||
|
||||
It is possible to have 'beyond-native-apple-hw' performance but it does require
|
||||
- It is possible to have 'beyond-native-apple-hw' performance but it does require
|
||||
work, patience, and a bit of luck (perhaps?).
|
||||
|
||||
---
|
||||
|
||||
### Post-Installation
|
||||
|
||||
|
@ -246,10 +350,13 @@ work, patience, and a bit of luck (perhaps?).
|
|||
|
||||
* Highly recommended macOS tweaks - https://github.com/sickcodes/osx-optimizer
|
||||
|
||||
---
|
||||
|
||||
### Is This Legal?
|
||||
|
||||
The "secret" Apple OSK string is widely available on the Internet. It is also included in a public court document [available here](http://www.rcfp.org/sites/default/files/docs/20120105_202426_apple_sealing.pdf). I am not a lawyer but it seems that Apple's attempt(s) to get the OSK string treated as a trade secret did not work out. Due to these reasons, the OSK string is freely included in this repository.
|
||||
The "secret" Apple OSK string is widely available on the Internet.
|
||||
- It is also included in a public court document [available here](http://www.rcfp.org/sites/default/files/docs/20120105_202426_apple_sealing.pdf).
|
||||
- I am not a lawyer but it seems that Apple's attempt(s) to get the OSK string treated as a trade secret did not work out. Due to these reasons, the OSK string is freely included in this repository.
|
||||
|
||||
Please review the ['Legality of Hackintoshing' documentation bits from Dortania's OpenCore Install Guide](https://dortania.github.io/OpenCore-Install-Guide/why-oc.html#legality-of-hackintoshing).
|
||||
|
||||
|
@ -264,6 +371,7 @@ Apple EULA.
|
|||
Note: This is not legal advice, so please make the proper assessments yourself
|
||||
and discuss with your lawyers if you have any concerns (Text credit: Dortania)
|
||||
|
||||
---
|
||||
|
||||
### Motivation
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,178 @@
|
|||
#!/usr/bin/bash
|
||||
# macOS KVM Installation Script for Fedora
|
||||
# Quick Install: curl -fsSL <URL> | bash
|
||||
|
||||
set -e # Exit on any error
|
||||
|
||||
# Default settings
|
||||
USE_CURL=false
|
||||
INSTALL_DIR="$HOME/OSX-KVM"
|
||||
|
||||
# Function to display help
|
||||
show_help() {
|
||||
cat <<EOF
|
||||
macOS KVM Installation Script (Fedora)
|
||||
|
||||
Usage: $0 [OPTIONS]
|
||||
|
||||
Options:
|
||||
--use-curl Use curl instead of wget for downloads
|
||||
--help Show this help message
|
||||
|
||||
This script will:
|
||||
1. Install all required packages
|
||||
2. Clone the OSX-KVM repository
|
||||
3. Download macOS recovery image
|
||||
4. Convert BaseSystem.dmg to raw format
|
||||
5. Create macOS disk image (256GB)
|
||||
6. Set proper permissions for libvirt
|
||||
7. Launch macOS VM
|
||||
EOF
|
||||
}
|
||||
|
||||
# Function to check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to install packages via dnf
|
||||
install_package() {
|
||||
local pkg="$1"
|
||||
if ! rpm -q "$pkg" >/dev/null 2>&1; then
|
||||
echo "Installing missing package: $pkg"
|
||||
sudo dnf install -y "$pkg"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to download files
|
||||
download_file() {
|
||||
local url="$1"
|
||||
local output="$2"
|
||||
echo "Downloading: $url"
|
||||
if [ "$USE_CURL" = true ] && command_exists curl; then
|
||||
curl -L -o "$output" "$url"
|
||||
elif command_exists wget; then
|
||||
wget -O "$output" "$url"
|
||||
elif command_exists curl; then
|
||||
curl -L -o "$output" "$url"
|
||||
else
|
||||
echo "Error: Neither wget nor curl found. Please install one of them."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--use-curl)
|
||||
USE_CURL=true
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Updating package database..."
|
||||
sudo dnf makecache -y
|
||||
|
||||
# Install required packages
|
||||
REQUIRED_PKGS=(git wget curl python3 python3-pip qemu-kvm qemu-img virt-manager \
|
||||
libguestfs-tools p7zip p7zip-plugins make dmg2img tesseract tesseract-langpack-eng \
|
||||
genisoimage vim net-tools screen)
|
||||
|
||||
for pkg in "${REQUIRED_PKGS[@]}"; do
|
||||
install_package "$pkg"
|
||||
done
|
||||
|
||||
echo "✓ All required packages installed"
|
||||
|
||||
# Check system commands
|
||||
for cmd in git qemu-img wget curl python3 make dmg2img; do
|
||||
if ! command_exists "$cmd"; then
|
||||
echo "Error: $cmd is required but not installed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✓ System commands verified"
|
||||
|
||||
# Create installation directory
|
||||
if [ -d "$INSTALL_DIR" ]; then
|
||||
echo "Warning: $INSTALL_DIR exists. Backing up to ${INSTALL_DIR}.backup"
|
||||
mv "$INSTALL_DIR" "${INSTALL_DIR}.backup.$(date +%Y%m%d_%H%M%S)"
|
||||
fi
|
||||
|
||||
# Clone repository
|
||||
echo "Cloning OSX-KVM repository..."
|
||||
git clone https://github.com/kholia/OSX-KVM.git "$INSTALL_DIR"
|
||||
cd "$INSTALL_DIR"
|
||||
|
||||
# Setup KVM
|
||||
sudo modprobe kvm
|
||||
echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs >/dev/null || true
|
||||
[ -f kvm_amd.conf ] && sudo cp kvm_amd.conf /etc/modprobe.d/kvm.conf
|
||||
|
||||
sudo usermod -aG kvm "$(whoami)"
|
||||
sudo usermod -aG libvirt "$(whoami)"
|
||||
sudo usermod -aG input "$(whoami)"
|
||||
|
||||
# Download macOS recovery image
|
||||
echo "Downloading macOS recovery image..."
|
||||
if [ -f "fetch-macOS-v2.py" ]; then
|
||||
python3 fetch-macOS-v2.py
|
||||
else
|
||||
RECOVERY_URL="https://updates.cdn-apple.com/2019FallFCS/fullrestores/061-44998/B5A3E286-1C4A-11EA-99D4-864D6786AB92/BaseSystem.dmg"
|
||||
download_file "$RECOVERY_URL" "BaseSystem.dmg"
|
||||
fi
|
||||
|
||||
# Convert BaseSystem.dmg to raw format
|
||||
echo "Converting BaseSystem.dmg to raw format..."
|
||||
if [ -f "BaseSystem.dmg" ]; then
|
||||
qemu-img convert BaseSystem.dmg -O raw BaseSystem.img
|
||||
echo "✓ BaseSystem.img created successfully"
|
||||
else
|
||||
echo "Error: BaseSystem.dmg not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create macOS disk image
|
||||
echo "Creating macOS disk image (256GB)..."
|
||||
qemu-img create -f qcow2 macOS.qcow2 256G
|
||||
ln -sf macOS.qcow2 mac_hdd_ng.img
|
||||
echo "✓ Disk image created"
|
||||
|
||||
# Set permissions for libvirt
|
||||
sudo chown libvirt-qemu:libvirt-qemu macOS.qcow2 2>/dev/null || true
|
||||
sudo chmod 664 macOS.qcow2 2>/dev/null || true
|
||||
sudo chmod 755 "$INSTALL_DIR" 2>/dev/null || true
|
||||
|
||||
# Make scripts executable
|
||||
chmod +x *.sh
|
||||
|
||||
# Build OpenCore if missing
|
||||
if [ ! -f "OpenCore/OpenCore.qcow2" ]; then
|
||||
echo "OpenCore not found, attempting to build..."
|
||||
cd OpenCore || exit
|
||||
[ -f "Makefile" ] && make || echo "Warning: Could not build OpenCore"
|
||||
cd ..
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🎉 Installation completed successfully!"
|
||||
echo "Next steps:"
|
||||
echo "1. Start macOS VM: cd $INSTALL_DIR && sudo ./OpenCore-Boot.sh"
|
||||
echo "2. Use virt-manager: import XML, start VM"
|
||||
echo ""
|
||||
|
||||
# Prompt to start VM
|
||||
read -p "Start macOS VM now? (y/n): " -n 1 -r
|
||||
echo
|
||||
[[ $REPLY =~ ^[Yy]$ ]] && sudo ./OpenCore-Boot.sh || echo "VM can be started later"
|
|
@ -0,0 +1,178 @@
|
|||
#!/usr/bin/bash
|
||||
# macOS KVM Installation Script for a brand-new Linux system
|
||||
# Quick Install: curl -fsSL <URL> | bash
|
||||
|
||||
set -e # Exit on any error
|
||||
|
||||
# Default settings
|
||||
USE_CURL=false
|
||||
INSTALL_DIR="$HOME/OSX-KVM"
|
||||
|
||||
# Function to display help
|
||||
show_help() {
|
||||
cat <<EOF
|
||||
macOS KVM Installation Script
|
||||
|
||||
Usage: $0 [OPTIONS]
|
||||
|
||||
Options:
|
||||
--use-curl Use curl instead of wget for downloads
|
||||
--help Show this help message
|
||||
|
||||
This script will:
|
||||
1. Install all required packages
|
||||
2. Clone the OSX-KVM repository
|
||||
3. Download macOS recovery image
|
||||
4. Convert BaseSystem.dmg to raw format
|
||||
5. Create macOS disk image (100GB)
|
||||
6. Set proper permissions for libvirt
|
||||
7. Launch macOS VM
|
||||
EOF
|
||||
}
|
||||
|
||||
# Function to check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Function to install packages via apt
|
||||
install_package() {
|
||||
local pkg="$1"
|
||||
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
|
||||
echo "Installing missing package: $pkg"
|
||||
sudo apt-get install -y "$pkg"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to download files
|
||||
download_file() {
|
||||
local url="$1"
|
||||
local output="$2"
|
||||
echo "Downloading: $url"
|
||||
if [ "$USE_CURL" = true ] && command_exists curl; then
|
||||
curl -L -o "$output" "$url"
|
||||
elif command_exists wget; then
|
||||
wget -O "$output" "$url"
|
||||
elif command_exists curl; then
|
||||
curl -L -o "$output" "$url"
|
||||
else
|
||||
echo "Error: Neither wget nor curl found. Please install one of them."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--use-curl)
|
||||
USE_CURL=true
|
||||
shift
|
||||
;;
|
||||
--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "Updating package list..."
|
||||
sudo apt-get update -y
|
||||
|
||||
# Install required packages
|
||||
REQUIRED_PKGS=(git wget curl python3 python3-pip qemu-system qemu-utils \
|
||||
uml-utilities virt-manager libguestfs-tools p7zip-full make dmg2img \
|
||||
tesseract-ocr tesseract-ocr-eng genisoimage vim net-tools screen)
|
||||
|
||||
for pkg in "${REQUIRED_PKGS[@]}"; do
|
||||
install_package "$pkg"
|
||||
done
|
||||
|
||||
echo "✓ All required packages installed"
|
||||
|
||||
# Check system commands
|
||||
for cmd in git qemu-img wget curl python3 make dmg2img; do
|
||||
if ! command_exists "$cmd"; then
|
||||
echo "Error: $cmd is required but not installed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✓ System commands verified"
|
||||
|
||||
# Create installation directory
|
||||
if [ -d "$INSTALL_DIR" ]; then
|
||||
echo "Warning: $INSTALL_DIR exists. Backing up to ${INSTALL_DIR}.backup"
|
||||
mv "$INSTALL_DIR" "${INSTALL_DIR}.backup.$(date +%Y%m%d_%H%M%S)"
|
||||
fi
|
||||
|
||||
# Clone repository
|
||||
echo "Cloning OSX-KVM repository..."
|
||||
git clone https://github.com/kholia/OSX-KVM.git "$INSTALL_DIR"
|
||||
cd "$INSTALL_DIR"
|
||||
|
||||
# Setup KVM
|
||||
sudo modprobe kvm
|
||||
echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs >/dev/null || true
|
||||
[ -f kvm_amd.conf ] && sudo cp kvm_amd.conf /etc/modprobe.d/kvm.conf
|
||||
|
||||
sudo usermod -aG kvm "$(whoami)"
|
||||
sudo usermod -aG libvirt "$(whoami)"
|
||||
sudo usermod -aG input "$(whoami)"
|
||||
|
||||
# Download macOS recovery image
|
||||
echo "Downloading macOS recovery image..."
|
||||
if [ -f "fetch-macOS-v2.py" ]; then
|
||||
python3 fetch-macOS-v2.py
|
||||
else
|
||||
RECOVERY_URL="https://updates.cdn-apple.com/2019FallFCS/fullrestores/061-44998/B5A3E286-1C4A-11EA-99D4-864D6786AB92/BaseSystem.dmg"
|
||||
download_file "$RECOVERY_URL" "BaseSystem.dmg"
|
||||
fi
|
||||
|
||||
# Convert BaseSystem.dmg to raw format
|
||||
echo "Converting BaseSystem.dmg to raw format..."
|
||||
if [ -f "BaseSystem.dmg" ]; then
|
||||
qemu-img convert BaseSystem.dmg -O raw BaseSystem.img
|
||||
echo "✓ BaseSystem.img created successfully"
|
||||
else
|
||||
echo "Error: BaseSystem.dmg not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create macOS disk image
|
||||
echo "Creating macOS disk image (256GB)..."
|
||||
qemu-img create -f qcow2 macOS.qcow2 256G
|
||||
ln -sf macOS.qcow2 mac_hdd_ng.img
|
||||
echo "✓ Disk image created"
|
||||
|
||||
# Set permissions for libvirt
|
||||
sudo chown libvirt-qemu:libvirt-qemu macOS.qcow2 2>/dev/null || true
|
||||
sudo chmod 664 macOS.qcow2 2>/dev/null || true
|
||||
sudo chmod 755 "$INSTALL_DIR" 2>/dev/null || true
|
||||
|
||||
# Make scripts executable
|
||||
chmod +x *.sh
|
||||
|
||||
# Build OpenCore if missing
|
||||
if [ ! -f "OpenCore/OpenCore.qcow2" ]; then
|
||||
echo "OpenCore not found, attempting to build..."
|
||||
cd OpenCore || exit
|
||||
[ -f "Makefile" ] && make || echo "Warning: Could not build OpenCore"
|
||||
cd ..
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🎉 Installation completed successfully!"
|
||||
echo "Next steps:"
|
||||
echo "1. Start macOS VM: cd $INSTALL_DIR && sudo ./OpenCore-Boot.sh"
|
||||
echo "2. Use virt-manager: import XML, start VM"
|
||||
echo ""
|
||||
|
||||
# Prompt to start VM
|
||||
read -p "Start macOS VM now? (y/n): " -n 1 -r
|
||||
echo
|
||||
[[ $REPLY =~ ^[Yy]$ ]] && sudo ./OpenCore-Boot.sh || echo "VM can be started later"
|
Loading…
Reference in New Issue