sickcodes / Docker-OSX

Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.
https://hub.docker.com/r/sickcodes/docker-osx
GNU General Public License v3.0
36.1k stars 1.78k forks source link

Sonoma won't work #715

Open tyu1996 opened 7 months ago

tyu1996 commented 7 months ago

So after the failed attempt to install Ventura (it just doesn't work even I followed #571), but I successfully installed the Monterey followed the issue mentioned. Installed Sonoma update from App Store, now it becomes an unending reboot loop.

Am going to re-install Sonoma from its recovery boot, will tell again if it works.

(I'm using Win 11 WSL2 Ubuntu Jammy for docker)

Edit: Returned a failed installation.

sickcodes commented 7 months ago

Working on it rn

RichardFevrier commented 7 months ago

Any way we can help to debug/dissect this problem @sickcodes ? (process, specific tools..)

RichardFevrier commented 7 months ago

Here are some logs just in case.

Screenshot from 2023-11-23 13-57-35 Screenshot from 2023-11-23 13-58-08

khmyznikov commented 7 months ago

@RichardFevrier I have the exact same issue with original OSX-KVM project Screenshot from 2023-11-23 19-34-09 Same for Ventura/Sonoma

RichardFevrier commented 7 months ago

Related to #714

khmyznikov commented 7 months ago

Folks, try to install Big Sur first, then update to Sonoma, and change -cpu Penryn to -cpu host

Heryk13 commented 7 months ago

Folks, try to install Big Sur first, then update to Sonoma, and change -cpu Penryn to -cpu host

i tried but when it asks for reboot the installation is where it fails, i tried changing the --restart flag too when running docker but no luck, tried --restart unless-stopped but it started restarting every 10 - 15 minutes even doing nothing and don't know why.

gxlpes commented 7 months ago

I have this exact same problem when trying to install Sonoma in the OSX-KVM project from Kholia.

voidarclabs commented 7 months ago

I've also had this issue. The Ventura installer fails to copy bootbase.efi and crashes, Sonoma from the app store and from a recovery installer causes a bootloop regardless, and there aren't any current fixes. Having messed around with macOS in VMware for a while now, the bootlooping behaviour can be replicated by installing macOS 13 < and rebooting. From what research I've done, the reason that Ventura and above don't work for some is due to hardware limitations on Ryzen CPUs specifically, and is unavoidable save for some CPUID magic that we're unaware of. The issue most likely stems from the fact that Ventura supports M series chips as well as x86, and if there were some way to replicate an M1 CPUID that it would subvert the problem. Something to look into?

Heryk13 commented 7 months ago

I've also had this issue. The Ventura installer fails to copy bootbase.efi and crashes, Sonoma from the app store and from a recovery installer causes a bootloop regardless, and there aren't any current fixes. Having messed around with macOS in VMware for a while now, the bootlooping behaviour can be replicated by installing macOS 13 < and rebooting. From what research I've done, the reason that Ventura and above don't work for some is due to hardware limitations on Ryzen CPUs specifically, and is unavoidable save for some CPUID magic that we're unaware of. The issue most likely stems from the fact that Ventura supports M series chips as well as x86, and if there were some way to replicate an M1 CPUID that it would subvert the problem. Something to look into?

wow it makes sense, my computer cpu is ryzen 7 5700U

bluesailor45 commented 7 months ago

I do not think its related only to Ryzen processors. I have the same issue on my Intel Core i7-13700K processor

HDK101 commented 7 months ago

I guess no one found a fix for this

khmyznikov commented 7 months ago

I guess no one found a fix for this

For me -cpu host did the trick, but need to install Big Sur first. I have 10 gen i7

Gucan commented 7 months ago

There are two problems with installing Sonoma. First, you need to change the -cpu parameter to host, otherwise it will restart indefinitely when you try to start it after installation. Second, during online installation, I don’t know why the recovery environment will try to download the installation resources of the arm series, resulting in an error that it cannot be found. bootbase.efi, just execute the following command after the disk tool formats the partition.

mkdir -p /Volumes/'partition name'/private/tmp
cp -R "/Install macOS Sonoma.app" /Volumes/'partition name'/private/tmp/
mkdir "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport"
curl -L -o "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport/SharedSupport.dmg" https://swcdn.apple.com/content/downloads/24/37/052-09398-A_DIKZGBNOM0/y4rz9dued01dtyl65nxqgd08wj2ar5cr6v/InstallAssistant.pkg
"/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/MacOS/InstallAssistant_springboard"
ShiftHackZ commented 7 months ago

There are two problems with installing Sonoma. First, you need to change the -cpu parameter to host, otherwise it will restart indefinitely when you try to start it after installation. Second, during online installation, I don’t know why the recovery environment will try to download the installation resources of the arm series, resulting in an error that it cannot be found. bootbase.efi, just execute the following command after the disk tool formats the partition.

mkdir -p /Volumes/'partition name'/private/tmp
cp -R "/Install macOS Sonoma.app" /Volumes/'partition name'/private/tmp/
mkdir "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport"
curl -L -o "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport/SharedSupport.dmg" https://swcdn.apple.com/content/downloads/24/37/052-09398-A_DIKZGBNOM0/y4rz9dued01dtyl65nxqgd08wj2ar5cr6v/InstallAssistant.pkg
"/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/MacOS/InstallAssistant_springboard"

I can confirm this works. Just did a fresh install of Sonoma using this method with kholia/OSX-KVM.

yaakovfeldman commented 6 months ago

There are two problems with installing Sonoma. First, you need to change the -cpu parameter to host, otherwise it will restart indefinitely when you try to start it after installation. Second, during online installation, I don’t know why the recovery environment will try to download the installation resources of the arm series, resulting in an error that it cannot be found. bootbase.efi, just execute the following command after the disk tool formats the partition.

mkdir -p /Volumes/'partition name'/private/tmp
cp -R "/Install macOS Sonoma.app" /Volumes/'partition name'/private/tmp/
mkdir "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport"
curl -L -o "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport/SharedSupport.dmg" https://swcdn.apple.com/content/downloads/24/37/052-09398-A_DIKZGBNOM0/y4rz9dued01dtyl65nxqgd08wj2ar5cr6v/InstallAssistant.pkg
"/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/MacOS/InstallAssistant_springboard"

This worked for me as well, using OSX-KVM. But using docker-osx is there anyway to override the cpu type?

Also Sonoma in OSX-KVM was much much slower and laggier than Ventura in docker-osx, on the same host and with the same resources - have others found this as well?

bluesailor45 commented 6 months ago

I was able to install Ventura with OSX-KVM procedure after changing in the OpenCore-Boot.sh file to the '-cpu host' parameter. However I do not know how to change the -cpu parameter in the docker procedure (sickcodes/docker-OSX). In addition I do not understand how to execute the commands recommended after the disk format tool, as I understand this is the disk format tool within the MacOS Install. Is anybod pleased to explain the exact procedures using the sickcodes/docker-OSX procedures?

yaakovfeldman commented 6 months ago

I was able to install Ventura with OSX-KVM procedure after changing in the OpenCore-Boot.sh file to the '-cpu host' parameter. However I do not know how to change the -cpu parameter in the docker procedure (sickcodes/docker-OSX). In addition I do not understand how to execute the commands recommended after the disk format tool, as I understand this is the disk format tool within the MacOS Install. Is anybod pleased to explain the exact procedures using the sickcodes/docker-OSX procedures?

To execute the commands just open Terminal, which is a menu option within the install environment.

To change the cpu parameter would probably involve rebuilding the dockerfile as it doesn’t seem to be exposed as configurable, although I assume @sickcodes will eventually update it as they are apparently working on support.

bluesailor45 commented 6 months ago

I was able to install Ventura with sickcodes/docker-OSX only adding the "-e CORES=4 " to the docker coomand: docker run -it \ --device /dev/kvm \ -p 50922:10022 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -e GENERATE_UNIQUE=true \ -e CORES=4 \ -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \ sickcodes/docker-osx:ventura

after several 'restarts' in the install process it finally installed OK. Only two problems as so far:

  1. "Volume hash mismatch" pops up on MacOS
  2. Safary shows only contents when activating e.g the 'about Safari' popup window. or anothe popup window.
ndrewh commented 5 months ago

fwiw, i was able to install sonoma using the sonoma branch (you may need to rebuild container to get latest OSX-KVM which appears to contain some important changes?).

I did need one change, courtesy of the venerable notes.md in OSX-KVM.

diff --git a/Dockerfile b/Dockerfile
index f73c12c..6cf57c4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -194,7 +194,7 @@ RUN touch Launch.sh \
     && tee -a Launch.sh <<< '[[ "${RAM}" = half ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 2000000"))"' \
     && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \
     && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-4}000 \' \
-    && tee -a Launch.sh <<< '-cpu ${CPU:-Penryn},${CPUID_FLAGS:-vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,}${BOOT_ARGS} \' \
+    && tee -a Launch.sh <<< '-cpu ${CPU:-Haswell-noTSX},${CPUID_FLAGS:-vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,}${BOOT_ARGS} \' \
     && tee -a Launch.sh <<< '-machine q35,${KVM-"accel=kvm:tcg"} \' \
     && tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \
     && tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \
@@ -296,7 +296,7 @@ ENV BOOT_ARGS=
 ENV BOOTDISK=

 # edit the CPU that is being emulated
-ENV CPU=Penryn
+ENV CPU=Haswell-noTSX
 ENV CPUID_FLAGS='vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,'

 ENV DISPLAY=:0.0
diff --git a/Dockerfile.naked b/Dockerfile.naked
index 712d059..bf0e4f9 100644
--- a/Dockerfile.naked
+++ b/Dockerfile.naked
@@ -126,7 +126,7 @@ ENV BOOT_ARGS=
 ENV BOOTDISK=

 # edit the CPU that is beign emulated
-ENV CPU=Penryn
+ENV CPU=Haswell-noTSX

 ENV DISPLAY=:99
awsms commented 5 months ago

I have to limit my Sonoma VM to a single CPU core/thread, otherwise it will freeze during boot. Wondering if someone else has the same issue.

RichardFevrier commented 5 months ago

I have to limit my Sonoma VM to a single CPU core/thread, otherwise it will freeze during boot. Wondering if someone else has the same issue.

Nope 8 cores 2 threads for each.

awsms commented 5 months ago

I have to limit my Sonoma VM to a single CPU core/thread, otherwise it will freeze during boot. Wondering if someone else has the same issue.

Same issue here: https://github.com/sickcodes/Docker-OSX/issues/380#issuecomment-1505166214 Big Sur works fine for me though, only Sonoma requires this workaround (my CPU is a Ryzen 5 5600H)

dumabg commented 4 months ago

On docker run, I put -e CPU=Haswell-noTSX and it works:

docker run --rm -it \
    --privileged \
    --device /dev/kvm \
    -e CPU=Haswell-noTSX \
   ...

I don't need to do the mentioned by Gucan (mkdir ...) https://github.com/sickcodes/Docker-OSX/issues/715#issuecomment-1843299658

andrewcharnley commented 4 months ago

I can also confirm doing the -e CPU=Haswell-noTSX flag works. I have a Ryzen 5 5600G.

I found pacman to be a major blocker to building the DockerFile and had to add the following to retry packages

RUN pacman -Sy wget --noconfirm
RUn echo "DisableDownloadTimeout" >> /etc/pacman.conf
RUN echo "XferCommand = /usr/bin/wget --passive-ftp -q --show-progress -O %o %u" >> /etc/pacman.conf

So far Sonoma is installing well.

mihalycsaba commented 3 months ago

Bit offtopic, but can you use Xcode with Sonoma? I still couldn't install it, getting all kind of weird errors with the installation. For example I don't have input if I use Haswell-noTSX on amd 5600g

dumabg commented 3 months ago

Bit offtopic, but can you use Xcode with Sonoma? I still couldn't install it, getting all kind of weird errors with the installation. For example I don't have input if I use Haswell-noTSX on amd 5600g

Yes.

mihalycsaba commented 3 months ago

I have managed to install Sonoma with Haswell-noTSX but keyboard and mouse input doesn't work.

Lorena301 commented 3 months ago

I have managed to install Sonoma with Haswell-noTSX but keyboard and mouse input doesn't work.

Hi! I had the same problem. Have you been able to solve it?

dmelo commented 3 months ago

I was able to get sonoma, after upgrading from Big Sur. But I'm having the same problem as @Lorena301 . The interface is not responding to mouse and keyboard. Any clue?

diff --git a/Dockerfile b/Dockerfile
index f73c12c..6cf57c4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -194,7 +194,7 @@ RUN touch Launch.sh \
     && tee -a Launch.sh <<< '[[ "${RAM}" = half ]] && export RAM="$(("$(head -n1 /proc/meminfo | tr -dc "[:digit:]") / 2000000"))"' \
     && tee -a Launch.sh <<< 'sudo chown -R $(id -u):$(id -g) /dev/snd 2>/dev/null || true' \
     && tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-4}000 \' \
-    && tee -a Launch.sh <<< '-cpu ${CPU:-Penryn},${CPUID_FLAGS:-vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,}${BOOT_ARGS} \' \
+    && tee -a Launch.sh <<< '-cpu ${CPU:-Haswell-noTSX},${CPUID_FLAGS:-vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,}${BOOT_ARGS} \' \
     && tee -a Launch.sh <<< '-machine q35,${KVM-"accel=kvm:tcg"} \' \
     && tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \
     && tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \
@@ -296,7 +296,7 @@ ENV BOOT_ARGS=
 ENV BOOTDISK=

 # edit the CPU that is being emulated
-ENV CPU=Penryn
+ENV CPU=Haswell-noTSX
 ENV CPUID_FLAGS='vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,'

 ENV DISPLAY=:0.0
docker build -t docker-osx:local-big-sur --build-arg SHORTNAME=big-sur .

docker run -it \
    --device /dev/kvm \
    -p 50923:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e RAM=32 \
    -e CPU=Haswell-noTSX \
    --name diogo_macos_sonoma \
    docker-osx:local-big-sur

My CPU is an AMD Ryzen 7 3800X.

skug67 commented 3 months ago

Same problem (no mouse/keyboard response) here.

sickcodes commented 2 months ago

I've added Sonoma today, just pushing it to DockerHub as we speak.

docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e GENERATE_UNIQUE=true \
    -e CPU='Haswell-noTSX' \
    -e CPUID_FLAGS='kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on' \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom-sonoma.plist' \
    sickcodes/docker-osx:sonoma
sickcodes commented 2 months ago

The mouse and keyboard issue was resolved here: https://github.com/sickcodes/Docker-OSX/commit/a208578bf0c8173f7b4f666144f819afde509931

replaced

    && tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \`

with

    && tee -a Launch.sh <<< '-device qemu-xhci,id=xhci \' \
    && tee -a Launch.sh <<< '-device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 \' \
awsms commented 2 months ago

I've added Sonoma today, just pushing it to DockerHub as we speak.

docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e GENERATE_UNIQUE=true \
    -e CPU='Haswell-noTSX' \
    -e CPUID_FLAGS='kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on' \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom-sonoma.plist' \
    sickcodes/docker-osx:sonoma

Still having the issue where I can't boot to Sonoma unless I'm only giving a single CPU core to the VM. :(

dmelo commented 2 months ago

There are two problems with installing Sonoma. First, you need to change the -cpu parameter to host, otherwise it will restart indefinitely when you try to start it after installation. Second, during online installation, I don’t know why the recovery environment will try to download the installation resources of the arm series, resulting in an error that it cannot be found. bootbase.efi, just execute the following command after the disk tool formats the partition.

mkdir -p /Volumes/'partition name'/private/tmp
cp -R "/Install macOS Sonoma.app" /Volumes/'partition name'/private/tmp/
mkdir "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport"
curl -L -o "/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/SharedSupport/SharedSupport.dmg" https://swcdn.apple.com/content/downloads/24/37/052-09398-A_DIKZGBNOM0/y4rz9dued01dtyl65nxqgd08wj2ar5cr6v/InstallAssistant.pkg
"/Volumes/'partition name'/private/tmp/Install macOS Sonoma.app/Contents/MacOS/InstallAssistant_springboard"

This worked for me as well, using OSX-KVM. But using docker-osx is there anyway to override the cpu type?

Also Sonoma in OSX-KVM was much much slower and laggier than Ventura in docker-osx, on the same host and with the same resources - have others found this as well?

@yaakovfeldman , have you managed to make Sonoma faster? I'm experiencing the same issue here.

matias-tecnosoul commented 2 months ago

@yaakovfeldman , have you managed to make Sonoma faster? I'm experiencing the same issue here.

same here, sonoma very slow

demian-mint commented 1 month ago

I tried updating Big sur to sonoma but it still reboots endlessly