├── README.md
├── img
├── 1-OC.png
├── 2-diskutility.png
├── 3-diskutility2.png
├── 4-kernelpanic.png
├── 5-bless.png
├── 6-newboot.png
├── 7-dd.png
└── 8-finished.png
└── quirks.txt
/README.md:
--------------------------------------------------------------------------------
1 | # How to install OS X Snow Leopard with OpenCore KVM
2 |
3 | ### 0. Things you'll need
4 |
5 | 1. Snow Leopard install ISO (You can grab one from archive.org)
6 | 1. OSX-KVM (https://github.com/kholia/OSX-KVM.git)
7 |
8 | ### 1. Patch OpenCore config
9 |
10 | We need to change some properties in the OpenCore config plist.
11 | OpenCore is installed on an external drive by default (as `OpenCore/OpenCore.qcow2`).
12 | We need to edit `EFI/OC/config.plist` in the disk.
13 |
14 | Mount the disk as follows:
15 |
16 | ```bash
17 | mkdir -p ocfs
18 | sudo modprobe nbd
19 | sudo qemu-nbd --connect=/dev/nbd0 ./OpenCore/OpenCore.qcow2
20 | sudo mount -o user /dev/nbd0p1 ocfs
21 | ```
22 |
23 | Next, edit the config file with:
24 |
25 | ```bash
26 | sudo vim ocfs/EFI/OC/config.plist
27 | ```
28 |
29 | Make sure the following varaibles are set:
30 |
31 | ```
32 | AvoidRuntimeDefrag: YES
33 | DevirtualiseMmio: YES
34 | EnableSafeModeSlide: YES
35 | ProtectUefiServices: NO
36 | ProvideCustomSlide: YES
37 | RebuildAppleMemoryMap: YES
38 | AllowRelocationBlock: YES
39 | ```
40 |
41 | (See `quirks.txt` for the exact contents of my config plist)
42 |
43 | Once you are done, unmount the disk with:
44 |
45 | ```bash
46 | sudo umount ocfs
47 | sudo qemu-nbd --disconnect /dev/nbd0
48 | ```
49 |
50 | ### 2. Modify OSX-KVM
51 |
52 | Edit `boot-macOS-headless.sh` with the following changes:
53 | - Change the Install Media drive from `BaseSystem.dmg` to your snow leopard installer ISO.
54 | - Change `OVMF_VARS-1920x1080.fd` to `OVMF_VARS.fd`
55 | - Change the network interface to use an `e1000-82545em` device (otherwise networking will just not work).
56 | - Decrease the core and thread count to 1, and bump RAM up to 8192.
57 |
58 | ```diff
59 | -ALLOCATED_RAM="7192" # MiB
60 | +ALLOCATED_RAM="8192" # MiB
61 | -CPU_CORES="2"
62 | -CPU_THREADS="4"
63 | +CPU_CORES="1"
64 | +CPU_THREADS="1"
65 | - -drive if=pflash,format=raw,file="$REPO_PATH/$OVMF_DIR/OVMF_VARS-1920x1080.fd"
66 | + -drive if=pflash,format=raw,file="$REPO_PATH/$OVMF_DIR/OVMF_VARS.fd"
67 | - -drive id=InstallMedia,if=none,file="$REPO_PATH/BaseSystem.img",format=raw
68 | + -drive id=InstallMedia,if=none,file="./snowleopard.iso",format=raw
69 | - -netdev user,id=net0,hostfwd=tcp::2222-:22 -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:c9:18:27
70 | + -netdev user,id=net0,hostfwd=tcp::2023-:22 -device e1000-82545em,netdev=net0,id=net0
71 | ```
72 |
73 | Finally, create a qcow2 hard disk for your VM (by default called `mac_hdd_ng.img`) following the OSX-KVM instructions (`qemu-img create -f qcow2 mac_hdd_ng.img 16G`), and boot with `./boot-macOS-headless.sh`.
74 |
75 | Note that 16G should be enough for Snow Leopard with XCode but you can make it as large as you want.
76 |
77 | ### 3. Install OS X
78 |
79 | Connect to the VM over VNC (by default, port 5901).
80 |
81 | 
82 |
83 | You should see the OpenCore boot manager with three options- press enter on "Mac OS X Install DVD".
84 |
85 | (Note that your mouse cursor may not work in OpenCore, that is ok- use the arrow keys).
86 |
87 | Proceed with the installation as normal.
88 |
89 | You'll need to format the disk as a `MacOS Extended (Journaled)` filesystem using Disk Utility, which can be found in the "Utilities" menu:
90 |
91 | 
92 |
93 | 
94 |
95 | Next, proceed to install Snow Leopard to the Qemu disk (should take around 30 mins).
96 |
97 | ### 4. Re-bless the drive after the kernel panic
98 |
99 | The installation will end in a kernel panic when the installer tries to `bless` the new drive.
100 | This is expected and can be fixed.
101 |
102 |
103 |
104 | 
105 |
106 | Shut down the VM, restart it, and enter the installer again.
107 |
108 | Open a Terminal window using Utilities -> Terminal (like how you opened Disk Utility).
109 |
110 | Type the following into the Terminal:
111 |
112 | ```bash
113 | bless --mount /Volumes/Hackintosh\ HD/ --verbose --bootefi --file /Volumes/Hackintosh\ HD/System/Library/CoreServices/boot.efi
114 | ```
115 |
116 | Where `Hackintosh\ HD` is replaced with whatever you called your new Snow Leopard drive when you formatted it in Disk Utility (note that this needs to be replaced in two spots in the command).
117 |
118 | 
119 |
120 | Finally, shut the VM down once again (you can use `shutdown -h now` from the Terminal window).
121 |
122 | ### 5. Booting into Snow Leopard
123 |
124 | Restart the VM.
125 | You should see your new Snow Leopard volume appear in the OpenCore boot manager.
126 |
127 | 
128 |
129 | Booting into it should take you to the setup screen for Snow Leopard.
130 |
131 | Setup your new VM!
132 |
133 | ### 6. Installing OpenCore to the VM Disk
134 |
135 | We can remove the dependence on `OpenCore.qcow2` by copying the EFI partition off of the Open Core disk into the new Snow Leopard volume.
136 |
137 | First, use `diskutil list` to show all available disks.
138 |
139 | We want to use `dd` to duplicate the EFI partition from the OpenCore disk onto the EFI partition of the Snow Leopard disk.
140 |
141 | 
142 |
143 | The OpenCore EFI partition is the EFI partition that belongs to the OpenCore disk.
144 | You can identify it by it being a `GUID_partition_scheme` disk with a long identifier for the second partition.
145 | It will not have an `Apple_HFS` filesystem on it.
146 |
147 | The target volume is your Snow Leopard install, it should have an `Apple_HFS` partition with the name you specified earlier in Disk Utility on it.
148 |
149 | In this example screenshot, OpenCore is on `disk0` and Snow Leopard is on `disk2`.
150 | Since we want the EFI partition of each, we will `dd` from `disk0s1` to `disk2s1` as follows:
151 |
152 | ```bash
153 | sudo dd if=/dev/disk0s1 of=/dev/disk2s1
154 | ```
155 |
156 | **Warning**: Be careful here as you can accidentally wipe your new volume.
157 | Maybe make a backup of `mac_hdd_ng.img` before doing this!
158 |
159 | ### 7. Removing Installation Media
160 |
161 | You can now shut down the VM and edit `boot-macOS-headless.sh` and remove all the installation media and OpenCore disk, as we don't need them anymore.
162 |
163 | ```diff
164 | - -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/OpenCore/OpenCore.qcow2"
165 | - -device ide-hd,bus=sata.2,drive=OpenCoreBoot
166 | - -device ide-hd,bus=sata.3,drive=InstallMedia
167 | - -drive id=InstallMedia,if=none,file="./snowleopard.iso",format=raw
168 | ```
169 |
170 | Congratulations! You should now be able to boot into a fully working Snow Leopard Qemu KVM VM!!
171 |
172 | 
173 |
174 | Enjoy your new virtual Mac :)
175 |
176 | ### 8. Getting files in and out of the VM
177 |
178 | If you want to edit the OpenCore configuration or the VM contents using the Linux `hfs` filesystem drivers, you can do so with the following.
179 |
180 | First, inside the VM, run the following to disable journaling (as if journaling is enabled, the HFS volume will be read-only):
181 |
182 | ```bash
183 | Ravis-Mac:~ ravi$ diskutil disableJournal /Volumes/Hackintosh\ HD
184 | Journaling has been disabled for volume Hackintosh HD on disk0s2
185 | ```
186 |
187 | (Where `Hackintosh\ HD` is replaced by your volume name).
188 |
189 | | Note that while non-journaled HFS volumes are possible, MacOS cannot boot from them. So, we must install the VM into a journaled HFS volume, and later disable it.
190 |
191 | | I have found that you need to re-run the disable journaling command every time you want to change the contents of the volume from the host.
192 |
193 | Now, shut down the VM and run the following:
194 |
195 | ```bash
196 | mkdir -p ocfs hfs
197 | sudo modprobe nbd max_part=8
198 | sudo qemu-nbd --connect=/dev/nbd0 $PWD/mac_hdd_ng.img
199 | sudo mount -o user /dev/nbd0p2 hfs
200 | sudo mount -o user /dev/nbd0p1 ocfs
201 | ```
202 |
203 | This will mount the HFS (MacOS) partition into the `hfs` folder, and the OpenCore EFI partition into the `ocfs` folder.
204 |
205 | You can now edit the MacOS filesystem inside of the `hfs` folder and the OpenCore configuration within the `ocfs` folder.
206 |
207 | When you're done, run this to clean up:
208 |
209 | ```bash
210 | sudo umount hfs
211 | sudo umount ocfs
212 | sudo qemu-nbd --disconnect /dev/nbd0
213 | sudo rmmod nbd
214 | ```
215 |
--------------------------------------------------------------------------------
/img/1-OC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/1-OC.png
--------------------------------------------------------------------------------
/img/2-diskutility.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/2-diskutility.png
--------------------------------------------------------------------------------
/img/3-diskutility2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/3-diskutility2.png
--------------------------------------------------------------------------------
/img/4-kernelpanic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/4-kernelpanic.png
--------------------------------------------------------------------------------
/img/5-bless.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/5-bless.png
--------------------------------------------------------------------------------
/img/6-newboot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/6-newboot.png
--------------------------------------------------------------------------------
/img/7-dd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/7-dd.png
--------------------------------------------------------------------------------
/img/8-finished.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jprx/how-to-install-snow-leopard-in-qemu/40859319fb365d3a98cf280faae54feb3a9c1e62/img/8-finished.png
--------------------------------------------------------------------------------
/quirks.txt:
--------------------------------------------------------------------------------
1 | Quirks
2 |
3 | AllowRelocationBlock
4 |
5 | AvoidRuntimeDefrag
6 |
7 | DevirtualiseMmio
8 |
9 | DisableSingleUser
10 |
11 | DisableVariableWrite
12 |
13 | DiscardHibernateMap
14 |
15 | EnableSafeModeSlide
16 |
17 | EnableWriteUnprotector
18 |
19 | ForceBooterSignature
20 |
21 | ForceExitBootServices
22 |
23 | ProtectMemoryRegions
24 |
25 | ProtectSecureBoot
26 |
27 | ProtectUefiServices
28 |
29 | ProvideCustomSlide
30 |
31 | ProvideMaxSlide
32 | 0
33 | RebuildAppleMemoryMap
34 |
35 | ResizeAppleGpuBars
36 | -1
37 | SetupVirtualMap
38 |
39 | SignalAppleOS
40 |
41 | SyncRuntimePermissions
42 |
43 |
--------------------------------------------------------------------------------