Linux on Mac: a POWER programmer's primer | ||||
David Mertz, Ph.D. (mertz@gnosis.cx) Even though most Linux users have treated Linux as an operating system for their x86 white boxes, Linux runs equally well on PowerPC machines. David looks at Linux on the PowerPC and the appealing range of PPC machines produced by Apple, where the option of using Linux is of great value to many users. About PowerPC The interrelations among various POWER architecture chips are similar to those in the x86 world -- for the most part, later generations of chips provide backward compatibility with earlier ones while also offering new and enhanced capabilities. Within the PowerPC family branch, five-year-old Apple machines used 601, 603, and 604 model chips. The current models have phased out the G3 but continue to use the similar G4, both 32-bit chips, running at various clock speeds; the recently introduced G5 is a 64-bit IBM chip that mostly adds some multimedia-specialized instructions to the POWER4 chip models. The bottom line on all these chips, from a Linux developer's perspective, is that they all run Linux happily and well. For the PowerPC branch of the chips, excellent consumer-friendly distributions are available and offer commercial customer support. IBM also installs Linux for customers of its high-end POWER4 machines. So you want to run Linux -- Why buy a PowerPC machine? For many Linux users, the best reason to buy a PowerPC machine will be, quite simply, the range of well engineered and reasonably priced machines available from Apple. Admittedly, the G4 lines -- bottom line -- do not quite keep up with comparably priced x86 machines in CPU power. The G4s do not lag that far behind, but they do a little. However, Apple makes some of the best laptops available from an ergonomic, aesthetic, battery-life, and weight perspective. All of those features are far more important to me, for a laptop, than raw number-crunching. On the desktop, the G4 models differentiate themselves mostly on an aesthetic or ergonomic perspective -- for example, in the compactness of Apple's cantilever-mounted flat-panel iMacs. All of Apple's machines, moreover, have a good reputation for durability and reliability -- including their rack mount servers, which are nice for clusters and server arrays. At the high-end, Apple's G5 towers are comparable in speed to the fastest x86-derived CPUs and systems; in other words, the Intel Itanium and AMD Athlon64. Benchmarks among the three contenders are a mixed bag, but all three chips obtain quite similar performance (all are remarkably fast, and suitable for intensive number crunching applications). Moreover, on price, Apple's G5 towers seem to sell for less than comparably configured systems from x86 vendors such as Dell, Gateway, HP, and other well-known PC retailers (contrary to Apple's reputation for imposing a price premium). It is worth noting that Apple has contributed optimizations to GCC3+ that bring its generation of PPC object code to a quality similar to that of Intel's ICC or IBM's VisualAge C++ compilers for x86 (which are arguably better than GCC on x86). At the end of the day, the differences between Linux/x86 and Linux/PPC are remarkably minimal. This article will cover a bit more detail on distributions below, but generally, on Linux/PPC you can use the same window managers, run the same utilities, host the same servers, and so on, as you might on any x86 box. Unless you look at the physical hardware -- or are a rare user with a need for precise performance characteristics of various operations (for example, your application is specially designed around particular vector extensions) -- you will not even know which architecture you are running Linux on. The screen will look exactly the same, most configuration files will contain the same settings, and the same bytes will go out over the wire. So you own a Mac -- Why run Linux? If you bought an Apple machine in the last few years, it came preinstalled with a high-quality Unix-derived operating system called OS X. OS X has a kernel and collection of base utilities called Darwin, which is under a Free Software license and is derived (in part) from FreeBSD -- the only proprietary elements are in the GUI (Aqua) and in the collection of end-user and system-administration applications that come bundled with OS X. Even X11 (specifically XFree86, despite what the name implies) is supported on OS X, in either full-screen or rootless modes; "rootless" here means that X11 applications run side-by-side with native Aqua ones. You can run Apache on OS X; you can run NcFTP server; you can even run GIMP or KOffice. Why bother installing Linux? There are a number of scenarios where it makes more sense to run Linux on your Apple machine than to run OS X. A first situation -- one that will appeal much more to hobbyists than to corporate users -- is when the Mac in question is an older machine. OS X is either entirely unsupported, or at least quite sluggish, on older Macs: 603s, 604s, or even early G3s. Linux can be quite snappy on these older systems; and Linux is a lot more useful as a server, or in many cases even as a desktop, than is the Mac OS 9 (or earlier) that came with those older machines. Still, the hobbyist segment is fairly narrow, or at least does not need to look here for advice. A more important situation where Linux is worthwhile as an operating system for G3, G4, or G5 machines from Apple is when you want to assure a uniform system/user interface across machines. Many enterprises, hosting companies, schools, or research facilities will have a mixture of x86 and PPC systems that it provides to users. While you can recompile most specific Linux applications for OS X, doing so does not bring the systems all the way to having a uniform GUI, configuration files, directory structure, and build environment between the various maintained machines. "Linux everywhere" assures a much greater degree of consistency. One thing in particular that can be confusing to Linux developers about OS X is its overlay of two distinct directory organizations -- the traditional /etc/, /usr/local/, /sbin/, and so on of Linux/Unix systems, and the /Application/, /Library/, /System/ from Mac OS 9. The /sw/ hierarchy Apart from developers who might use PPC desktops or laptop machines, Web-hosting companies would like to present a predictable system to its customers who maintain sites via SSH, FTP, or Web-based interfaces -- regardless of whether a domain is hosted on PPC or x86 chips. Considering servers further, Linux offers several advantages over OS X, even over the server version of OS X. One major strength of Linux is the variety of filesystems that have been developed for it or ported to it: ext2, ext3, ReiserFS, IBM's JFS, SGI's XFS, etc. Each of these has its own strengths, often specific to particular usage scenarios (Web host, streaming multimedia server, RDBMS, etc.). While the server version of OS X supports an enhanced version of HFS+ with journaling and optional filename case-sensitivity, it cannot match Linux's range of filesystem options. Also, I should mention -- but not overemphasize -- the little matter of cost: An unlimited-client version of Mac OS X Server will cost you US$1000 per machine, whereas Linux is free of cost (and even a support contract from a distribution vendor is much cheaper than this). The caveat here is that if OS X Server's administration tools save your IS staff even a little work each day, that kilodollar outlay can quickly pay for itself. Distributions The two distributions that I found less that compelling were Debian (Woody) and Knoppix. The latter is an interesting creature that I've found useful on x86 machines. Knoppix uses a "live boot" CD -- that is, booting from the Knoppix CD gives you a working Linux environment with KDE, OpenOffice, and a good collection of utilities. Using Knoppix, there is no need to create any partitions or boot setup on a PC, and you can carry the Knoppix CD between various machines to have a uniform configuration on each. Unfortunately, testing on three separate systems, Knoppix/PPC never managed to boot quite right: KDE would not load, and the fallback was a crude TWM shell that did not get the video mode quite right (colormap and sizing problems). Networking, including wireless, however, seem to be recognized correctly; so you can use the command-line tools. Once Knoppix/PPC gets some more polish to it, it -- or something like it -- will be a very useful way to run Linux non-destructively on existing Mac OS X machines. (See Resources for links to full articles on Knoppix.) The problems I had with Debian/PPC are probably similar to what dedicated Debian users most love about their distribution to start with. Installation is strictly a text-mode affair, with no options for changing configuration once a fatal "Y" or "N" has been pressed. As long as you make no mistakes and read each installation screen carefully, installation proceeds well enough. It even automatically finds on the network any modules that do not happen to be on the installation CD(s). Many installed utilities and applications -- GCC, Python, the kernel, OpenOffice, etc., lag quite a few versions behind the most current ones, but most widely used tools are available as Debian packages (and hence fetchable using the wonderful Both Yellow Dog (Sirius/3.0.1) and Mandrake (Bamboo/9.1) have quite slick Linux distributions for PowerPC. Overall, I would recommend Yellow Dog over Mandrake to most users, but each have some strengths and weaknesses. The fact that Yellow Dog's maker, Terra Soft Solutions, specializes in PowerPC systems probably leads them to pay somewhat greater attention to the small details of tuning Linux for PPC. On the other hand, for enterprise users aiming at a thorough consistency might choose Mandrake for both x86 and PPC machines. Yellow Dog and Mandrake both use attractive and friendly installation GUIs; perhaps a slight edge functionally goes to Mandrake for its list of pending and completed steps to the left of the dialog area, but I nonetheless prefer the aesthetics of Yellow Dog screens. Both systems come with a large collection of applications and utilities: Gnome/KDE, OpenOffice, XFree86 4.3, Mozilla, Mac-on-Linux, various servers. For most applications and utilities (and the kernel), Yellow Dog ships with slightly more recent versions, but generally only a micro-release difference, not a whole minor version. In any case, neither Yellow Dog nor Mandrake had any difficulty recognizing my network, graphics card, partitions, mouse, keyboard, and so on. However, I did experience a glitch with Yellow Dog's first attempt to reboot into X11 -- I needed to run A few differences between Mandrake and Yellow Dog stand out. The menu organization and theme are a bit different under the KDE window manager that I selected (the default for both), but both systems were very reasonable (and configurable once the system is installed, in any case). And the package selection presets contained a similar set of "personal," "server," and "workstation" options (with customization allowed). I really liked Mandrake's DiskDrake tool for partition management. This graphical utility lets you add, delete, non-destructively resize, format, and otherwise manipulate partitions (but no non-destructive resize on HFS+). Among other things, DiskDrake let me choose the format for my Mandrake partition(s) during installation, rather than simply defaulting to ext3 as Yellow Dog did (but I could still add an extra ReiserFS partition easily enough later under Yellow Dog). And I am generally very impressed with Mandrake's Control Center, on both x86 and PPC, not because it does anything unique, but because it unifies configuration tasks under one interface. Despite Mandrake's advantages, my ultimate reason for preferring Yellow Dog is its package management system. Yellow Dog seems to be something of a hybrid system: it uses RPMs during installation, but it also installs Partitioning, multi-boot management, and emulation Partitioning and bootstrapping work a bit differently on Apple machines compared to x86 ones. Specifically, Apple's Open Firmware (an enhanced version of the BIOS Linux users know from x86 PCs) relies on a small "Apple Bootstrap" partition ( Configuring yaboot is generally similar to working with lilo. A file called /etc/yaboot.conf contains options for various systems, kernels, partitions, and so on; the format is mostly the same as in lilo.conf. When you have configured yaboot.conf properly, you load yaboot onto the bootstrap partition using the command One nice thing about running Linux on PPC machines is that you can run the Free Software tool Mac-on-Linux this way. This works much like the commercial VMWare does on x86 machines. An entire Mac OS system (either OS X, or an earlier version such as Mac OS 9) runs inside a window within a Linux/X11 display. In fact, you can run multiple Mac OS versions simultaneously, each in their own virtual display window. The Mac OS lives in a kind of "sandbox" where it cannot see its Linux environment, but PPC instructions nonetheless run at full native speed. Assuming you have enough memory to run such a sandbox, Mac-on-Linux gives you a nice way to continue using your Mac OS applications while running Linux -- even proprietary applications for which you have no source code. No need for recompilation as is needed to move Linux applications to an OS X environment. Resources
|