LINUXCOVER USERSTORY SchlagwortMac on sollte hier stehen

Running Mac OS X under Linux AN APPLE A DAY…

We used the Ubuntu distribution for the PowerPC processor, as it proved impossible to get either Gentoo or the commercial Yellow Dog distribution to display a GUI on our iBook G4/800 with a Radeon Mobility 9200 graphics chip. The Ubuntu installer works with the apt-get package manager, which downloads files off the Internet. Mac-on- Linux needs a few kernel modules for PPC Linux, and you will need to compile these modules yourself. Compiling these modules means installing a few tools, if they are not already installed. The fol- lowing command downloads the pack- ages and installs them:

sudo apt-get install build-U essential linux-headers-2.6-U

If you are prompted for a password, type now give users the ability to run their beloved Mac OS X on your normal user account password, as Ubuntu does not typically have an Linux, bringing birds of a feather back together. administrative (root) account (see [8]). Instead, users can run commands that BY OLIVER FROMMEL typically need root privileges using sudo. Unfortunately, the standard Ubuntu repository does not include the files, so he easiest way to run Mac pro- also gives you Linux device drivers that you will first need to add the Multiverse grams on Linux is the free Mac- have been optimized for this application repository, which includes packages that Ton-Linux [1] software. Mac-on- in an approach similar to Vmware’s, are not part of the standard Ubuntu dis- Linux does not give you a hardware which explains why Mac-on-Linux is tribution. To do so, add the lines in Box 1 emulation and thus requires an Apple quicker than an . to your /etc/apt/sources.list. computer. The Mac-on-Linux package Now update the local cache with the theoretically supports other PowerPC Mac OS as a Linux Program new repository by typing sudo apt-get architectures [2], such as the Pegasos Mac-on-Linux boots a standard Apple update. Then install the source code for [3], but installing the Apple operating as a Linux program. In the Mac-on-Linux kernel modules: system, MacOS, on these architectures our example, we’ll use Mac OS X, but would contravene the license agreement. Mac-on-Linux also supports older vari- sudo apt-get install mol- ants, such as System 9, which is still modules-source Linux for Apple fairly common. You can use Mac-on-Linux with any Gentoo users can download and com- Launch an editor to open a header file Apple computer. Of course your Linux pile Mac-on-Linux in the typical Gentoo of this package and remove an error that distribution needs to support the Pow- way using emerge mol. Yellow Dog actu- will otherwise prevent you from building erPC processor [4]. The following distri- ally includes the program by default. the modules. If you prefer to use another butions have this ability: Fedora Core 3 [5], Gentoo [6], Debian [7], Ubuntu [8], Box 1: Additions to /etc/apt/sources.list and Yellow Dog [9]. 01 deb http://archive.ubuntu.com/ubuntu warty multiverse Mac-on-Linux does not emulate hard- 02 deb-src http://archive.ubuntu.com/ubuntu warty multiverse ware; it passes commands to the CPU. It

38 ISSUE 54 MAY 2005 WWW.LINUX- MAGAZINE.COM Mac on Linux COVER STORY

editor rather than vi, replace vi with the Box 2: /etc/mol/tunconfig name of your preferred editor. 01 #!/bin/bash sudo vi /usr/src/linux-U 02 /sbin/ifconfig tun0 192.168.40.1 headers-2.6.8.1-4-powerpc/U 03 /sbin/iptables -D POSTROUTING -t nat -s 192.168.40.0/24 -d ! include/asm/setup.h 192.168.40.0/24 -j MASQUERADE 04 /sbin/iptables -t nat -s 192.168.40.0/24 -d ! 192.168.40.0/24 -A Delete the line containing #include POSTROUTING -j MASQUERADE and save the file 05 /sbin/iptables -t filter -P FORWARD ACCEPT again. Then change to the directory with 06 echo 1 > /proc/sys/net/ipv4/ip_forward the Linux source code and unpack the archive that apt-get has stored there. The package manager resolves depen- on-Linux uses a terminal window to cd /usr/src dencies itself and additionally installs display messages that occur at boot sudo tar xzvf mol-modules.tar.gz the mol and mol-drivers-macosx, and time. These messages are stored perma- mol-drivers-linux, which you will only nently in a file below /var/log. This is You need to set a few environmental need if you want to run a PPC Linux ver- where you should look if something variables to make sure the modules sion with Mac-On-Linux. goes wrong. match your current kernel version: If you specify --loadonly when launch- ing the program, it tells you if the kernel Network Tunnel export KVERS="$(uname -r)" module is loaded (Figure 1). The most Setting up the network is a more diffi- export KSRC="/usr/src/linux- common mistake is to have kernel and cult proposal, and unfortunately, there headers-$(uname -r)" module versions that do not match. is no smart helper to point us in the export KDREV="ubuntu0" Although the parameter -a allows differ- right direction. Start by enabling the ent version numbers, you should not tunnel interface in /etc/mol/molrc.net; Now change to the Mac-on-Linux subdi- expect a configuration without matching this interface automatically loads the rectory and call the build script when numbers to work. right kernel module and assigns an IP you get there: After loading the module, you can address. To enable the tunnel interface, now turn to the video configuration. The remove the # in the line with netdev: cd modules/mol sudo molvconfig command launches the tun0 -tun. Your boot messages should sudo debian/rules build required program, which either tries out now include a line such as Ethernet the operating modes itself or allows you Interface 'tun-' @ 00:00:0D: After a short delay, the build should to set a mode manually. In our lab, both EA:DB:EE. complete; you can now create a Debian approaches worked out fine with the A new disk appears in Mac OS X; you package with the files this step gave you: defaults. can open the disk by double clicking. startmol helps you organize the key- It contains special drivers Mac OS X sudo debian/rules binary-U board assignments. The --keyconfig para- needs to access the network in emula- mol-modules meter launches an interactive program, tion mode. To install the drivers, click on which displays the name of the key (for the Pkg package and follow the instruc- The final product should now be in example Return or Apple-Key) and tions. /usr/src. Change to this directory and prompts you to press that key. You will probably want to use Mac-on- install it on your Ubuntu system: After completing the configuration, Linux to access both your local network you can launch Mac OS X in a window and the Internet. To pass traffic to Mac- sudo dpkg -i mol-modules-U by typing sudo startmol -X. It automati- on-Linux, you need to edit the /etc/mol/ 2.6.8.1-3-powerpc_0.9.70+U cally locates the installation on your tunconfig script, which is launched by ubuntu0_powerpc.deb hard disk and “boots” the system. Mac- startmol. The default version of tuncon-

This finally completes the preparation work, and you can go on to install the remaining packages for Mac-on-Linux:

sudo apt-get install mol mol-U drivers-macosx Figure 1: Launching Mac-on-Linux with the --loadonly option logs the required modules. COVER STORY Mac on Linux

Figure 2: Mac OS X browsing the Web in a Linux window. Figure 3: The PearPC start screen allows you to select the boot partition. fig launches a DHCP server and uses the approach. That is, you need a genuine Then copy the sample configuration files iptables command to map IP addresses. emulator that fools Mac OS X into to that directory: In our lab we used an alternative believing it is running on an Apple plat- tunconfig with a static IP address assign- form. It also helps if you enjoy experi- cp pearpc-0.3.1/ppccfg.example U ment (see Box 2). In Mac OS X, assign menting, and of course you need a set of ppc/ppccfg the IP address 192.168.40.2 to the net- Mac OS X installation CDs. work interface en3 and assign 192.168. PearPC [11] implements a PowerPC To imitate the graphics adapter, PearPC 40.1 as the router. CPU and a set of peripherals. The instal- also needs a video.x file, which you After you complete this complex con- lation is as easy as pie: again need to copy to your working figuration, Mac-on-Linux now has Inter- directory. Also, move the hard disk net access. tar xfj pearpc-0.3.1.tar.bz2 image, macosx.img, to the same direc- cd pearpc-0.3.1 tory to have all the files you need in the Accelerator ./configure --enable-ui=sdl U right place. To launch Mac-on-Linux in full screen --enable-cpu=jitc_x86 You can edit the ppccfg configuration mode in X, you need to modify a file make file with a text editor. For the time being, called /etc/mol/molrc.video. In the su -c 'make install' the existing entries will be fine, but you enable_xvideo: ... line, change the value need to modify the name of your hard from yes to no. This value makes Mac In this example, PearPC is using the SDL disk image. To do so, change the line in OS X run a lot more quickly, as it library to draw a GUI desktop, although the file as follows: removes the need for a whole bunch of you can use --enable-ui=x11 as an alter- time-consuming graphics operations. native. pci_ide0_master_image = U You can achieve the same effect by After completing the build, first create "macosx.img" launching Mac-on-Linux directly in a an empty file, which PearPC will use as text console. For more details check out a virtual disk. The following command The prom_bootmethod entry specifies [10]. creates a 3Gbyte file called macosx.img: how PearPC boots. The preset value, To enable changing CD ROMs you auto, uses the first bootable partition. If need to add a line similar to the follow- dd if=/dev/zero of=macosx.U you change this to select, the emulator ing to the molrc.osx file: img bs=516096 seek=6241 count=0 will prompt you to select a partition (Figure 2). blkdev: /dev/sg0 -cd Contrary to what the instructions in the Insert the first Mac OS X installation PearPC documentation tell you, you can CD to launch into the install. If you are This assumes you are using the IDE- partition the virtual hard disk without not already in the ppc directory, change SCSI module to enable SCSI emulation Darwin OS. As a side note Darwin OS is to that directory and launch the emula- for your IDE CD ROM. is the free version of Mac OS X. How- tor, specifying your configuration file as ever, it only includes the text-based com- a parameter: Mac OS without Apple ponents. The GUI desktop and other Hardware core components are missing. ppc ppccfg If you do not have an Apple computer, To keep track of the files the PearPC but you would still like to take a look at emulator requires, you might like to cre- If you then select to boot from the CD, this colorful operating system, you need ate a new directory for the emulator, and the Mac OS X start screen should appear, to look around for an alternative call it ppc for example. as shown in Figure 3. You can press [Alt-

40 ISSUE 54 MAY 2005 WWW.LINUX- MAGAZINE.COM Mac on Linux COVER STORY

Figure 4: The Mac OS X installer running in the Pear PC emulator. Figure 5: After finishing the installation even the Dock works.

Enter] to toggle between full-screen and When you reboot, the emulator might Linux outpaces its competitor should be window display mode. complain about a missing network tun- no surprise. After all, strictly speaking, After a short while, the installation nel interface /dev/net/tun. If so, run Mac-on-Linux isn’t an emulator but a program appears. If you go through the modprobe tun as root to load the kernel program that runs Mac OS X (and other required steps, you are prompted for a module. programs) on Linux. In fact, it is quick “target volume” at some point, but The virtual Ethernet card is automati- enough for you get down to some seri- unfortunately, you do not have one at cally detected by Mac OS X; to locate the ous work on a modern computer. present. You first have to partition the card, check the network configuration in Both programs have a fairly compli- virtual hard disk. Launch the partition- your system settings. Assign the static IP cated network configuration, but this ing tool with Installer | Hard disk tool. address of 192.168.1.1, which PearPC has more to do with the complexity of In the hard disk tool click on the Parti- configured in scripts/ifppc_up. The the functions that Linux needs to sup- tioning tab and then select the 1 Parti- router address is 192.168.1.80. /etc/ port the virtual network connection. tion option for Volume Schema. Click on resolv.conf on the Linux system gives The QEMU package, which is compa- Partition and confirm the dialog that you a working nameserver. rable to the two, shows that emulated then follows. The program partitions the Just like Mac-on-Linux, PearPC will networking is possible without Network virtual disk and formats the new parti- configure the virtual network fairly Address Translation. Both projects could tion. After quitting the tool, the partition autonomously in the background and benefit from the concepts the QEMU should be visible in the Installer. even set up Network Address Transla- project puts to work. ■ If the Installer complains about being tion. To do so, it needs a few files from low on disk space, you can de-select a the software directory. Simple copy the INFO few packages such as the Language whole of the scripts subdirectory to the [1] Mac-on-Linux: packages and Additional voices. After right place: http://www.maconlinux.org completing the package selection, the [2] PowerPC processor: http://www.ibm. Installer will then copy your packages to cp -R pearpc-0.3.1/scripts ppc com/chips/products/powerpc the virtual disk. [3] Pegasos Computer: After completing this step, quit PearPC As the programs change the Linux net- http://www.pegasosppc.com and insert the second installation CD. work settings, you need root privileges [4] Linux-PPC homepage: When you reboot, select the partition for this step. In other words, you need to http://www.penguinppc.org created earlier as your boot partition. launch PearPC as the administrator or [5] Fedora Core 3 PPC: http:// The Installer will copy a few more files assign SUID root privileges to the ifppc_ fedoraproject.org/fedorappc/FC-3 and complete the install. You can skip up.setuid and ifppc_down.setuid pro- [6] Gentoo PPC: http://www.gentoo.org/ the questions about registering your user grams (chmod +s). doc/en/handbook/handbook-ppc.xml account. By default, PearPC creates a network [7] Debian PPC: http://www.debian.org/ interface called ppc and an address of ports/powerpc Networking for Experts 192.168.1.80 on the Linux system; you [8] Ubuntu: http://www.ubuntulinux.org To allow Mac OS X to use the network in can call /sbin/ifconfig ppc to verify this. [9] Yellow Dog: a PearPC environment, you need to http://www.yellowdoglinux.com/ modify the entry for the network card in A Happy Alliance [10] Full-screen mode in Mac-on-Linux: http://www.maconlinux.org/ the configuration file: Mac-on-Linux and PearPC impress by userguide/cvideo.html virtue of their feature richness, ease of [11] PearPC: http://pearpc.sourceforge.net pci_rtl8139_installed = 1 use, and speed. The fact that Mac-on-

WWW.LINUX- MAGAZINE.COM ISSUE 54 MAY 2005 41