Linux on Mac: a Power Programmer's Primer

xiaoxiao2021-03-06  105

Linux on Mac: a Power Programmer's Primer

content:

About PowerPCSO you want to run linux - Why Buy a PowerPC Machine? SO you OWN A MAC - Why Run Linux? DistributionsPartitioning, Multi-Boot Management, And EmulationResourcesoSabout the Authorrate this Article

related information:

PowerPC AssemblyPorting IA32 Applications to Linux PowerPCporting Intel Applications to 64 Bit Linux PowerPcpcPowerPC Architecture BookDeveloperWorks Toolbox Subscription

In the Linux area:

Tutorial Tools & Product Codes & Component Articles

Your Favorite Operating System Isn't Only for x86

Level: Introductory

David mertz, ph.d.d.d.d.

(mertz@gnosis.cx) Developer, Gnosis Software, Inc.20 January 2004

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 PowerPCThe POWER architecture describes a family of RISC CPUs that arose out of a consortium of IBM, Apple, and Motorola. Within this chip family, higher-end POWER4 chips are used in various IBM mid-range machines (see Resources for links to more information on IBM iSeries and pSeries hardware and software); at a personal computer, workstation, or workgroup-server level, the PowerPC branch of POWER chips are used in widely-used consumer machines from Apple Computer Chips in the PowerPC family - especially. those from Motorola -. are also used in various embedded and specialized systems, including PCs from smaller manufacturers such as the phoenix-like current incarnation of Amiga 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. Withnin The PowerPC Family Branch, Five-Year-Old Apple Mac hines 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 Offercial 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? The "default"

systems for running Linux are unquestionably x86 machines. Whether based on CPUs from Intel, AMD, Cyrix, Transmeta, or smaller makers, the x86 architecture is well known and makes up the large majority of personal computers, workstations, and small servers. It is certainly safe to go with the majority 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 Crunch 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) - y ou 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? To a surprising degree, operating systems (other than those from the highly-proprietary Microsoft) have become commodities. What this means is that most vertical applications are a mere recompilation away from running equally well on Linux, FreeBSD, SunOS, Irix, AIX, or Indeed on Mac OS X;

in some cases even this step is not necessary, since ABIs (application binary interfaces) support foreign binaries. 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 FIR t 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 cassers............................................................................................................................................................................................................................................................... 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 Fink Creates, Additional, IS Almost Like A Third OVERLAY. MOREOVER, EVEN Though OS X Has An X11 server built in, I have still found a variety of minor glitches (redraws, key bindings, etc.) in using X11 applications there - Linux with a good window manager such as KDE or GNOME is a much more seamless environment in this case . 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 sites via maintain SSH, FTP, or Web-based interfaces - regardless of whether a domain is hosted on PPC or x86 Chips. Considier 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 can not 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. DistributionsFor this article, I installed and evaluated four distributions of Linux for PowerPC machines:. Debian, Knoppix, Yellow Dog, and Mandrake All were installed and tested on a G4 iMac I found two of the distributions to be well polished and easy to use, right on par. with the best x86 Linux distributions;. the other two I would have to describe as ". not ready yet" A few other distributions exist as well - and more will certainly be created over time I was not aiming to provide a thorough comparison of Every Distributi on readers might choose to use, but simply to get a sense of the "state of the art" - no slight is intended towards those distributions I did not look at The two distributions that I found less that compelling were Debian (Woody). And knoppix. The latter is an intence 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 Distribu TION 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 apt-get) However,. the killer problem I found with Debian / PPC was my inability to get X11 working on it -. the installation seemed wholly unaware of any remotely relevant video card models, and some post-installation attempts at configuration proved fruitless, too I am certain that there are Debian / PPC users who have worked out the configuration issues, but compared to the ease of installation of other distributions, I have trouble recommending Debian to many users. Both Yellow Dog (Sirius / 3.0.1) and Mandrake (B amboo / 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 / usr / X11R6 / bin / Xautoconfig once to clear up the problem. 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 fo r 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 apt-get for later updates to the system I have not looked at the internals of the setup, but I could type apt-get install OpenOffice at one line, and have every dependency resolved correctly, the whole 350 megabytes (after expansion) of files downloaded, and the links added to my KDE menu without restarting X11. After wasting many hours WRESTLING WITH RPM Dependencies, this was a marvel to behold. of course, I've been spoiled by using fink under mac OS X, Which Does The Same Thing (and is based on apt-get). Partitioning, Multi-Boot Management, and emulationLinux / PPC has an important disadvantage relative to Linux / x86: As of this writing, no tools yet exist for non-destructive repartitioning of HFS partitions (at least none that are post-alpha and can run from OS X or Linux). Unfortunately, this Means That You Cannot Easily Configure a Multi-boot system from an existing mac os x system;

. Most recent Linux / x86 distributions provide an analogous capability to add Linux to an existing Windows system It is simple enough to destructively partition an existing drive, then reinstall OS X to one of those new partitions; but doing this means losing your existing data and system configuration (backup / restore might work, but can be tricky to get right). Of course, if you simply want a dedicated Linux machine, this is not something you need worry about. 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 (hda2) to load the subsequent operating system from one of the regular partitions. The partition Map Also Occupies HDA1 YOU WILL INSTALL ANY OPERATING ISTEM IS NUMBERED AT Least HDA3. DURING MACHINE Startup - Using The Multi-Boot Tool Yaboot - Your Boot Proce ss goes through two stages, rather than the one-level x86 MBR boot loaders such as lilo and grub use At the first stage, you have a choice of booting from, for example, harddisk, CD-ROM, or to Open Firmware.; assuming you proceed to the harddisk, you might have the option of booting various operating systems / versions that live on normal partitions. 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 ybin (as root, of course). To find partition information, you must use the tool pdisk rather than the traditional fdisk on x86 Linux systems. Again, the interface is similar but not quite the same, between the tools. For Mandrake users, the tool DiskDrake is a much friendlier and more flexible GUI-based tool to do the same thing . Using yaboot, you can choose among multiple Linux distributions and / or MacOS versions at boot time. 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 windo w. The Mac OS lives in a kind of "sandbox" where it can not 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.

Read a concise history of the POWER architecture. Read more details specifically on the history of the PowerPC. See some general information about distributions of LinuxPPC and additional installation tips. For the latest developments on Linux on 32-bit and 64-bit PowerPC, go . to penguinppc.org Terra Soft Solutions is the maker of Yellow Dog Linux and also offers custom PowerPC systems - both as an Apple reseller and their own systems -. with pre-installed versions of Yellow Dog on them Mandrake.com provides more information on Mandrake's PowerPC Linux distribution. More information on Debian Linux can be found at debian.org. The official Knoppix Web site is maintained by the author of Knoppix, Klaus Knopper. For more on Knoppix, read "Knoppix gives bootable, one-disk Linux "(developerWorks, February 2003) and System recovery with Knoppix (developerWorks, October 2003)." Find out the current status of Mac-on-Linux. IBM's iSeries and pSeries servers can run Linux on top of t heir POWER processors. For more information on these systems, go to the Linux on IBM eServer iSeries and pSeries home pages. You'll find a large assortment of downloadable evaluation software for Linux on iSeries and pSeries, as well as documentation and education resources, at the Linux on iSeries and pSeries download center. "PowerPC assembly" (developerWorks, July 2002) gives an introduction to using PPC assembly language under Linux. "Porting IA32 Applications to Linux PowerPC" and "Porting Intel Applications to 64 bit Linux PowerPC"

are excellent resources for those looking to switch their applications to the PPC platform. For an exhaustive overview of the PowerPC architecture, read all three installments of the "PowerPC Architecture Book". Also on the eServer Developer Domain is "POWER4 and shared memory synchronization" . Find more resources for Linux developers in the developerWorks Linux section.About the authorDavid Mertz is owner and chief consultant for Gnosis Software, Inc. whose corporate slogan is "We Know Stuff!" (and we do). You can reach David at mertz @ Gnosis.cx; You Can Investigate All Aspects of His Life At His Personal Web Page. Suggestions and Recommendations ON Past or Future Column Are Welcome. Check Out His Book, Text Processing In Python.

转载请注明原文地址:https://www.9cbs.com/read-103669.html

New Post(0)