Skip to content

Commit

Permalink
feat: Use VirtIO disks instead of IDE (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Jun 2, 2024
1 parent 6cabae6 commit 4b99df9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 40 deletions.
48 changes: 24 additions & 24 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ kubectl apply -f kubernetes.yml

- Start the container and connect to [port 8006](http://localhost:8006) using your web browser.

- Select `macOs Base System` with your keyboard to begin the installation.
- Select `macOs Base System` using your keyboard to begin the installation.

- Select `Disk Utility` and then select the `QEMU HARDDISK Media` that has the size you specified.
- Select `Disk Utility` and then select the largest `Apple Inc. VirtIO Block Media` disk.

- Click `Erase` to format the disk, you can give it any name you want.
- Click `Erase` to format the disk, and give it a recognizable name you like.

- When finished, go back by closing the window and then proceed the installation by clicking `Reinstall macOS <version>`.
- Close the window and proceed the installation by clicking `Reinstall macOS <version>`.

- When prompted where to install it, select the disk you created.
- When prompted where to install it, select the disk you just created.

- Once you see the desktop, your OSX installation is ready for use.

Expand All @@ -88,14 +88,14 @@ kubectl apply -f kubernetes.yml
| **Value** | **Version** | **Size** |
|----|-----|----|
| `high-sierra` | High Sierra | ? GB |
| `mojave` | Mojave | ? GB |
| `catalina` | Catalina | ? GB |
| `big-sur` | Big Sur | ? GB |
| `monterey` | Monterey | ? GB |
| `ventura` | Ventura | 3 GB |
| `sonoma` | Sonoma | ? GB |

| `ventura` | Ventura | 3.0 GB |
| `monterey` | Monterey | ? GB |
| `big-sur` | Big Sur | ? GB |
| `catalina` | Catalina | ? GB |
| `mojave` | Mojave | ? GB |
| `high-sierra` | High Sierra | ? GB |

* ### How do I change the storage location?

To change the storage location, include the following bind mount in your compose file:
Expand All @@ -118,17 +118,6 @@ kubectl apply -f kubernetes.yml

This can also be used to resize the existing disk to a larger capacity without any data loss.

* ### How do I verify if my system supports KVM?

To verify if your system supports KVM, run the following commands:

```bash
sudo apt install cpu-checker
sudo kvm-ok
```

If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.

* ### How do I change the amount of CPU or RAM?

By default, the container will be allowed to use a maximum of 2 CPU cores and 4 GB of RAM.
Expand All @@ -140,7 +129,18 @@ kubectl apply -f kubernetes.yml
RAM_SIZE: "8G"
CPU_CORES: "4"
```


* ### How do I verify if my system supports KVM?

To verify if your system supports KVM, run the following commands:

```bash
sudo apt install cpu-checker
sudo kvm-ok
```

If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.

* ### Is this project legal?

Yes, this project contains only open-source code and does not distribute any copyrighted material. So under all applicable laws, this project will be considered legal.
Expand Down
11 changes: 6 additions & 5 deletions src/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ set -Eeuo pipefail

BOOT_DESC=""
BOOT_OPTS=""
BOOT_DRIVE="/images/OpenCore.qcow2"
BOOT_DRIVE_ID="OpenCoreBoot"
BOOT_DRIVE_BUS="ide.2"
BOOT_DRIVE="/images/OpenCore.qcow2"
SECURE="off"
OVMF="/usr/share/OVMF"

Expand All @@ -34,13 +33,15 @@ case "${BOOT_MODE,,}" in
;;
esac

BOOT_OPTS="$BOOT_OPTS -smbios type=2 -device vmware-svga,bus=pcie.0,addr=0x5 -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off"
BOOT_OPTS="$BOOT_OPTS -smbios type=2 -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off"
BOOT_OPTS="$BOOT_OPTS -device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"

# OVMF
BOOT_OPTS="$BOOT_OPTS -drive if=pflash,format=raw,readonly=on,file=$OVMF/$ROM"
BOOT_OPTS="$BOOT_OPTS -drive if=pflash,format=raw,file=$OVMF/$VARS"

# OpenCoreBoot
BOOT_OPTS="$BOOT_OPTS -device ide-hd,drive=$BOOT_DRIVE_ID,bus=$BOOT_DRIVE_BUS,rotation_rate=1,bootindex=1"
BOOT_OPTS="$BOOT_OPTS -drive file=$BOOT_DRIVE,id=$BOOT_DRIVE_ID,format=qcow2,cache=writeback,aio=threads,discard=on,detect-zeroes=on,if=none"
DISK_OPTS="$DISK_OPTS -device virtio-blk-pci,drive=${BOOT_DRIVE_ID},scsi=off,bus=pcie.0,addr=0x5,iothread=io2,bootindex=1"
DISK_OPTS="$DISK_OPTS -drive file=$BOOT_DRIVE,id=$BOOT_DRIVE_ID,format=qcow2,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on,if=none"

return 0
1 change: 1 addition & 0 deletions src/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -Eeuo pipefail
: "${USB:="qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0"}"

APP="OSX"
VGA="vmware"
SUPPORT="https://github.com/dockur/osx/"

cd /run
Expand Down
35 changes: 24 additions & 11 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,47 @@
set -Eeuo pipefail

# Docker environment variables
: "${VERSION:="sonoma"}" # OSX Version
: "${VERSION:="ventura"}" # OSX Version

BASE_IMG="$STORAGE/BaseSystem.img"
BASE_IMG_ID="InstallMedia"
BASE_IMG_BUS="ide.4"
BASE_IMG="$STORAGE/BaseSystem.img"

downloadImage() {

local msg="Downloading $APP $VERSION image..."
info "$msg" && html "$msg"
/run/fetch-macOS-v2.py -s "$VERSION"
dmg2img -i BaseSystem.dmg "$BASE_IMG"
echo "$VERSION" > "$STORAGE/$PROCESS.version"

if ! /run/fetch-macOS-v2.py -s "$VERSION"; then
error "Failed to fetch MacOS $VERSION!"
return 1
fi

msg="Converting base image format..."
info "$msg" && html "$msg"

if ! dmg2img -i BaseSystem.dmg "$BASE_IMG"; then
error "Failed to convert base image format!"
return 1
fi

rm -f BaseSystem.dmg

echo "$VERSION" > "$STORAGE/$PROCESS.version"
}

if [ ! -f "$BASE_IMG" ]; then
downloadImage
! downloadImage && exit 34
fi

STORED_VERSION=$(cat "$STORAGE/$PROCESS.version")

if [ "$VERSION" != "$STORED_VERSION" ]; then
info "Different version detected switching base image from $STORED_VERSION to $VERSION"
info "Different version detected, switching base image from $STORED_VERSION to $VERSION"
rm -f "$BASE_IMG"
downloadImage
! downloadImage && exit 34
fi

DISK_OPTS="$DISK_OPTS -device ide-hd,drive=$BASE_IMG_ID,bus=$BASE_IMG_BUS,rotation_rate=1"
DISK_OPTS="$DISK_OPTS -drive file=$BASE_IMG,id=$BASE_IMG_ID,format=raw,cache=writeback,aio=threads,discard=on,detect-zeroes=on,if=none"
DISK_OPTS="$DISK_OPTS -device virtio-blk-pci,drive=${BASE_IMG_ID},scsi=off,bus=pcie.0,addr=0x6,iothread=io2"
DISK_OPTS="$DISK_OPTS -drive file=$BASE_IMG,id=$BASE_IMG_ID,format=raw,cache=$DISK_CACHE,aio=$DISK_IO,discard=$DISK_DISCARD,detect-zeroes=on,if=none"

return 0

0 comments on commit 4b99df9

Please sign in to comment.