How to install Mac OS 9 in QEMU

Revision as of 10:48, 28 August 2024 by Undefishin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page details how to install Mac OS 9 in QEMU. Mac OS 9 is an operating system created by Apple in October of 1999. This was the final release in the classic Mac OS series. The OS was famously discontinued in 2002 with a mock funeral by Steve Jobs at the Apple Worldwide Developers Conference.

Mac OS 9.2 desktop

This article will describe in detail how to install Mac OS 9.2 with mouse drivers, sound, networking, and graphics. This tutorial should work with Mac OS 9.0 and 9.1 (which needs an additional flag; more details below).

Prerequisites

QEMU

You need QEMU installed, specifically the PowerPC version since old Macs used PowerPC instead of x86. On Arch you can install it with pacman -S qemu-system-ppc and on Debian/Ubuntu you can install it with apt install qemu-system-ppc. The Windows version should come with it already installed.

Mac OS 9.2.1 CD

You will need a Mac OS 9.2.1 CD. You can either use a physical disc or download one from WinWorldPC.

Starting up

Installation

As always, the first thing we want to do is create the hard disk image by opening the Terminal or Command Prompt and typing this:

qemu-img create -f qcow2 macos9.img 2G

2G can be replaced with however big you want the hard drive to be (with G standing for Gigabytes). Mac OS 9 is a very old OS and thus does not take up a lot of space. See this page for more information on how this command works.

When that's done, we can start up QEMU with the following command:

qemu-system-ppc -M mac99 -m 512 -hda macos9.img -cdrom /path/to/macos-9-cd.iso -netdev user,id=mynet -device sungem,netdev=mynet -device usb-mouse -device usb-kbd -boot d

This sets the machine type to "mac99" (basically a G4 Mac). You can also set it to -M g3beige which is a Power Mac G3. We also add a USB mouse and keyboard for far smoother input.

We set the RAM to 512 MB, though you can run it with as little as 40 MB and as high as 768 MB. The OS starts becoming severely unstable if more than a GB of RAM is given.

If you are installing Mac OS 9.0 or 9.1, you'll also need to add -cpu G3 to the flags for it to work.

When you start QEMU, you should see a yellow screen with some details like this:

 

The system should begin starting up after a few seconds:

 

It usually takes around a minute to start, but if you're on a slower/older machine it may take several minutes. When it's done it should drop you into a live Mac OS 9 environment like this:

 

Click the "Utilities" folder. Open the "Drive Setup" utility and initialize the volume (labeled <not initialized>).

 

It'll warn you that it will destroy all data on the volumes. Click Initialize and proceed. It will partition the disk, and then we can proceed with the installation. Go back to the root CD folder and click "Install Mac OS 9.2.1" (or whatever version). Click Continue, make sure the Destination Disk is the one you just initialized, accept the software license agreement, and click "Start" to begin the installation.

         

The system will now install. It will give an ETA of about 7 minutes usually but it might take longer to actually install. Just sit back, let it do its thing, go watch some YouTube videos or something while it does this.

 

When it's done installing you will get a message box asking if you want to exit or continue to install other software. Choose "Continue" and close out of QEMU (press Ctrl+ALT+G to release the mouse grab). Change the -boot d flag to -boot c so that it boots to the new image, like so:

qemu-system-ppc -M mac99 -m 512 -hda macos9.img -netdev user,id=mynet -device sungem,netdev=mynet -device usb-mouse -device usb-kbd -boot c

You may also remove the CD rom if you want. You will see the same yellow boot screen as before, and if all went well, you should see this (you may have to jiggle your mouse a bit to make it actually load):

 

And if all went well, you should be in the desktop! Hooray!

 

You may have a "Setup Assistant" appear. You can go through and set everything up or close it, it doesn't matter much, though it will help you set up some basic network functions like shared folders and the like, so I recommend it. It's a very simple wizard.

Software

Now that we have our system set up, we'll probably want to install some software. Fortunately, a lot of it was preserved thanks to the efforts of Macintosh Garden, Macintosh Repository, and the Internet Archive. Pretty much every major software for OS 9 is on Macintosh Garden and Repository, so I recommend checking those ones out first. Some convenient and interesting software is listed below.

Note: You may have to right click some of the links and click "Save link as...". This is due to a recent change in policy in browsers such as Chrome regarding HTTP links.

Sound support

Unfortunately, the stock QEMU does not come with proper sound drivers for Mac OS 9, so we'll need to build a fork of QEMU that adds these sound card drivers. This section will be technically advanced and is only recommended for more experienced users. The instructions change depending on your OS.

Compiling on Linux

Clone the source code tree like so:

git clone --recursive -b screamer https://github.com/mcayland/qemu.git qemu-screamer

cd qemu-screamer/

Install the proper build dependencies. This varies from distro to distro, so I included a table with a few example commands:

Distribution Command
Arch Linux pacman -S libffi gettext glib2 pkgconf autoconf automake pixman ninja mesongnutls libjpeg-turbo libpng libslirp libssh libusb lzo ncurses nettle snappy vde2
Debian/Ubuntu apt install libglib2.0-dev libgcrypt20-dev zlib1g-dev autoconf automake libtool bison flex libpixman-1-dev

cd into the folder. We'll configure the build here. We're only going to compile the PowerPC version of QEMU to save time, though if you want to build every version, just remove the --target-list=ppc-softmmu flag at the very end. Execute the following command:

./configure --target-list=ppc-softmmu

Finally, build QEMU:

cd build/
make -j$(nproc)

Afterwards, you'll find the proper qemu-system-ppc in the build/ folder.

Compiling on macOS

First things first, this requires Homebrew. If you don't have it, install it by following the guide on the official website.

Clone the source code tree like so:

git clone --recursive -b screamer https://github.com/mcayland/qemu.git qemu-screamer

cd qemu-screamer/

Then, install all the build dependencies through Homebrew:

brew install libffi gettext glib pkg-config autoconf automake pixman ninja meson gnutls jpeg libpng libslirp libssh libusb lzo ncurses nettle snappy vde

Now, cd into the folder. We are going to configure the build. We are only going to compile the PowerPC version of QEMU to save time, though if you want to build every version of QEMU, just remove the --target-list=ppc-softmmu flag at the very end. Execute the following command:

PKG_CONFIG_PATH="$(brew --prefix)/opt/ncurses/lib/pkgconfig" ./configure --target-list=ppc-softmmu

Finally, build QEMU:

cd build/
make -j$(sysctl -n hw.ncpu)

Afterwards, you'll find the proper qemu-system-ppc in the build/ folder.

Compiling on Windows

We will need to download and install the latest version of MSYS2. Follow the instructions on the page.

A terminal should open when the installation finishes, if not just open it from the Start menu. When the terminal is open, we'll update MSYS2's packages by running:

pacman -Syu

When the updates are installed, the terminal will close. Open it again and run the following command to finish updating the packages:

pacman -Su

Now, install the build dependencies for QEMU:

pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-glib2 mingw64/mingw-w64-x86_64-gtk3 mingw64/mingw-w64-x86_64-SDL2 git python python-setuptools ninja

When this is finished, close the MSYS2 terminal and open the MinGW terminal (should be in the Start menu), and run the commands below to prepare the build environment for QEMU's build scripts:

cp -v /mingw64/bin/x86_64-w64-mingw32-gcc-ar.exe /mingw64/bin/x86_64-w64-mingw32-ar.exe
cp -v /mingw64/bin/x86_64-w64-mingw32-gcc-ranlib.exe /mingw64/bin/x86_64-w64-mingw32-ranlib.exe
cp -v /mingw64/bin/windres.exe /mingw64/bin/x86_64-w64-mingw32-windres.exe
cp -v /mingw64/bin/nm.exe /mingw64/bin/x86_64-w64-mingw32-nm.exe
cp -v /mingw64/bin/objcopy.exe /mingw64/bin/x86_64-w64-mingw32-objcopy.exe

Now it's time to clone the source tree like so:

git clone --recursive -b screamer https://github.com/mcayland/qemu.git qemu-screamer

cd qemu-screamer/

Now we'll configure the build. To save time we only build the PowerPC QEMU target, but if you want to build all of them, just remove the --target-list=ppc-softmmu flag from the end. Also, unlike with macOS/Linux builds, we'll be disabling the GTK UI since it has mouse input issues, as well as DirectSound audio backend because it results in audio issues with OS X (though not Mac OS 9).

./configure --cross-prefix=x86_64-w64-mingw32- --disable-gtk --enable-sdl --audio-drv-list=sdl --target-list=ppc-softmmu

Now we build QEMU:

cd build/
make -j$(nproc)

Afterwards, you'll find the proper qemu-system-ppc in the build/ folder.

Credits