The Penguin in the Apple

Working through a Gentoo installation on an Apple PowerBook.

On June 24, 2003, Linux User & Developer Expo took place in Birmingham, during which the Best Linux Hardware Award has been assigned to the SGI Altix 3000, a cluster system. It competed against the Xinit Sharp SPS440, which are powerful enterprise servers, and two notebooks, the Apple PowerBook and iBook.

This list of nominees is really strange, even though the victory went to the SGI cluster solution. 2003 has been the year during which, thanks to the 2.4 series kernels and several other projects (KDE and GNOME, for example), Linux has become a system usable even on desktop machines. This has been realized by the introduction of stable support in hardware categories users want to access for every day use, including USB devices.

Apple solutions are based on PowerPC processors and adopt solutions such as widescreens, gigabit Ethernet and wireless cards on board. Notebooks with this ind of hardware have been taboo for Linux until a short time ago; as recently as 2000, installing Linux on a x86 notebook was considered work for experts. Now, we not only can run Linux on this hardware, but we also can claim it to be the best.

Apple, moreover, has been extremely intelligent in its relationships with the Open Source community. Even though Apple continues to develop, support and sell closed-source solutions (Mac OS X), they have shown great interest in the Open Source world and have released the kernel of OS X (Darwin) under an open-source license. Under such circumstances, it is not surprising that more Linux users are approaching Apple solutions, which are innovative and not hostile to open-source solutions.

In this article we discuss the Apple PowerBook, covering the hardware features and the installation of Gentoo Linux and trying to understand if it really is a good choice for Linux users.

Hardware

The PowerBook is produced by Apple in three different models that differ mainly in their screen dimensions--12, 15 and 17 inches. Each model is available with either a combination CD burner/DVD reader drive or a CD/DVD burner superdrive.

The first feature user notices surely is the screen dimension: the 12" model has a definition of 1024x768. The other two models exhibit a 16:9 widescreen, as compared to the more common 4:3 monitors, so you get a lot of work area. The maximum resolution available on the 15" model is 1280x854, and on the 17" model the resolution is 1440x900. All have DVI/VGA and S-Video output plugs to connect with an external digital or analog monitor and to televisions.

The microprocessor is a PowerPC G4, with frequencies up to 1 GHz and with three cache memory levels. The RISC architecture at the base of the PowerPC is quite different from that of the x86. Later in this article, we try to compare some performances. The minimum amount of memory mounted on the PowerBooks is 256MB, upgradable up to 1GB, and the hard drives are Ultra ATA/66 with 40 or 60GB of storage space.

The widely supported NVIDIA GeForce4 card is mounted on the 12" and 17" models. The 15" model comes with an ATI Mobility Radeon 9000 card, also well supported under Linux.

The networking section has some surprises for the user: each model is equipped with a Gigabit Ethernet card and an Airport wireless card, which reaches 11 or 54 Mbit/s. We also find two USB ports and a FireWire port, a PCMCIA slot, a microphone and line out ports and speakers.

A note about weight: the three models with batteries in weigh, respectively, 2.1, 2.45 and 3.1 Kg and are really slim compared to an x86 laptop of the same class.

The general impression one receives from every Apple product is they are solid both on the hardware and the design side. Unfortunately, this leads to high prices; Apple has no half measures, so it sells no cheap and less powerful versions of its notebooks.

Mac OS X

This article is not the proper place to offer a complete overview of Mac OS X. Just know that it is possible to run OS X perfectly from Linux through Mac-On-Linux, a project similar to Wine but with stable support for all OS X features.

Installing Linux

I successfully installed Gentoo Linux on the PowerBook, and the procedure was quite straightforward even if there are some issues to keep in mind. The tested machine is a Titanium PowerBook with a PowerPC G4 800MHz processor, 512MB of memory, 40GB of hard disk space, 15" screen (1280x854 pixels), Radeon Mobility 9000 video card, Gigabit Ethernet and wireless Airport card integrated.

You can follow the PPC general instructions on the Gentoo site to install Gentoo Linux. For the rest of this article, I focus only on Titanium-specific configurations.

Step 1: Bootstrap

Disk repartitioning probably is the most difficult part of the whole installation. You need to create empty space using the Mac OS X tool (from the installation CD) and then create Linux partitions using the mac-fdisk utility. The latter is not documented in the Gentoo install instructions, but you can find a good tutorial here.

Once you know the main mac-fdisk commands, you can follow the Gentoo instructions exactly and partition your disk in less than 10 minutes.

The Gentoo Linux installation requires many hours: during the first phase (bootstrap) the system compiles an optimized version of glibc, GCC, binutils and gettext, but the whole process can take up to five hours. To skip the compilation of the base system, we can use Stage 3 of the installation, which installs a precompiled version of the kernel. The result is a not totally optimized system, but it is quite usable.

Step 2: Configuration and Kernel Compilation

The configuration of the Gentoo system through the make.conf file is quite simple. Given that the PowerBook's hardware always is the same, we can find the right switches for the best performances. You have to write only the USE flags, reflecting the real use of your notebook. The right compilation flags for the PowerBook series are:

CFLAGS="-O2 -pipe -mcpu=7450 -maltivec -mabi=altivec
-mpowerpc-gfxopt -fsigned-char -mstring -mmultiple"
CXXFLAGS="${CFLAGS}"

Kernel configuration takes a bit longer; in order to correctly handle PowerBook hardware, you have to use Benjamin Herrenschmidt's patched kernel, available as ppc-sources-benh. The 2.4.21 version has a little bug that crashes the system when you exit X (for example shutting the system), so the best choice for now is version 2.4.20-r10. The kernel configuration is quite perfect for the PowerBook, but some things differs from the x86 configuration, so here's a short description of the most important things (when not indicated, compile it in the kernel and not as a module):

Platform Support: select AltiVec Support CPU Frequency scaling. AltiVec is the SIMD (single instruction multiple data) PowerPC extension by Motorola that gives a noticeable boost to G4 performances. CPU frequency scaling is a useful PPC feature; you can scale the frequency of the microprocessor on the fly through the /proc filesystem. This means you can tune the working frequency based on the current CPU load and the battery status. For example, if you are writing something with your text editor and your battery is at 10%, you can set the CPU frequency to a low value and work for a long time.

Network device support: select Sun GEM and Apple GMAC support.

Networking options: to get MAC OS X networking up while running through Mac-On-Linux, you have to set up packet filtering. To obtain this, simply compile as modules network packet filtering and, in the section IP: Netfilter configuration, connection tracking, IP tables support, full NAT and MASQUERADE target support. Later, you need to set up the system to load these modules at boot.

Console drivers: to get X working with your video card, you have to select Open Firmware frame buffer device support and ATI Radeon display support (if you own a 12" or 17" PowerBook, install NVIDIA drivers following Gentoo documentation).

Macintosh device drivers: de-select Support for ADB raw Keycodes or you are not able to use you keyboard correctly. Select Support for PMU-based PowerMacs, power management support for PowerBooks and APM emulation. PowerBooks do not have an APM system, and they use the power management unit, which is its PPC counterpart.

Character devices: compile as modules Apple UniNorth support and Direct Rendering Manager with the ATI Radeon drivers, and de-select Enhanced Real Time Clock Support.

Sound: build sound card support and PowerMac DMA sound support as modules; later you can install ALSA drivers that work better than the OSS ones.

To complete the configuration of our system, we need to select which modules should be loaded at boot and edit the file /etc/modules.autoload. To activate Netfilter in order to let Mac OS X run, we need the following modules: ip_tables, iptable_nat, ip_conntrack and ipt_MASQUERADE.

Step 3: Graphical Environments and Desktop Stuff

After completing steps 1 and 2, we already have a GNU/Linux working system. For everyday use, anyway, we also could install the graphical environment (after all, this is not an high-end server). Compiling X and KDE takes about 10 hours. It is not a good idea to let the notebook run with 100% CPU load for such a long time, so remember that you can stop the compile process at any time simply by pressing the Ctrl-C key combination and powering off the notebook. Later, you can restart the process by giving the same initial command (emerge kde, for example), and it starts compiling from the last packet it was working on when you stopped. It picks up from the beginning of the packet; no half compilation results are stored. This lets you split the whole process into two or three parts, thus obtaining the desired result without melting the notebook hardware.

The sound card works well with the ALSA driver: to install them, follow Gentoo instructions and remember that you need the PowerMac sound driver.

I recommend buying a three-button USB external mouse, because the one-button touchpad on the laptop is difficult to use. You can emulate the right and central buttons with two keyboard buttons (while you are waiting your external mouse to be shipped), just by adding the following lines to the /etc/sysctl.conf file

dev.mac_hid.mouse_button_emulation = 1
dev.mac_hid.mouse_button2_keycode = 68
dev.mac_hid.mouse_button3_keycode = 87

These lines map the two buttons on the F10 and F11 keys, respectively.

The keyboard has another interesting issue: notice the lack of the AltGr button. The solution is quite simple: through the small xmodmap utility you can find the keycode of every key on the keyboard. Then you can assign a specific function or map to it by writing some lines in a .Xmodmap file stored in your home directory. For example, the keycode of the Apple key is 115, so you can write keycode 115 = Multi_key in the file, and the Apple key then will work as AltGr.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: The Penguin in the Apple

Anonymous's picture

Good article Leo but I fell I should point out one thing. The article you link to get us how to use mac-fdisk seems to have inaccurate info. First of all, it says that one needs to use disk utility to create a HFS+ partition which Mac-fdisk turns into free space. Well, this is redundant and an unecessary extra step because disk utility (OS X) or OS 9's disk drive can set up a free space (a OS X "term", OS 9 calls it something else but is obvious when you cross that bridge).
How do I figure this? YDL, not my favorite distro but oh well, installs over this free space as does mdk-ppc (yes I've done them both).

Another seemingly apparent error is "Using HFS+ for MacOSX is not recommended as MacOS will debless the OSX partition rendering it unbootable" (did they mean UFS?). This is rediculous! HFS+ is where most the apple dev occurs so why would istalling OS X using HFS+ render it unbootble. Even if it did all you have to do is boot up from the OS X disk and select the startup disk as the OS X disk. Of coarse this would screw yaboot but depending on how you set things up (order of partitions I think) running ybin will correct this again (I've had o do this). At the very least booting while pressing the option key will start apple's graphcal bootloader and then you can choose to boot OS X or your linux distro. (I assume you have to keep what the hidden apple partitions for this to work, but you would keep them if you're still keeping OS X anyway.)

Chascon

Linux Installation Reports on PowerBooks and iBooks

Anonymous's picture

There are many links to reports about Linux installations on Apple PowerBooks and iBooks at TuxMobil. All entries are annotated with the Linux distribution. Links to drivers and important resources are provided.

I'm not sure I understand...

Anonymous's picture

I own a TiBook. What would the benefit be to switching to Linux? I wouldn't gain any new applications, and I'd be harming the performance of my Apple applications and apparantly suffering with worse hardware support at the same time.

What's the benefit here?

Re: I'm not sure I understand...

Anonymous's picture

Running Linux is, in itself, the benefit ;)

Re: I'm not sure I understand...

Anonymous's picture

You would be using free software, it's a political issue...

Re: I'm not sure I understand...

Anonymous's picture

You'll be gaining speed, and battery life. In addition, you will have an OS that you do not have to pay for software. The combination of these things were enough to make me install YDL on my iBook 700mhz Combo. I havn't gone into MacOS 9/X in a while. YDL is excellent all around. I have also used Debian, which is also excelllent.

Mike

Re: The Penguin in the Apple

Anonymous's picture

Thanks for the article, Leonardo. I'm sure there are many of us who would like to see benchmarks comparing Powerbook and PC notebook performance. If you could post a URL to such, I would appreciate it.

WLM

Thanks

Anonymous's picture

Thanks for your appreciation: unfortunately I did not find Linux related benchmarks on Internet but this one

http://users.linpro.no/janl/tibook.html

I would like to test performance a bit deeper anyway, and when I have some time I will post something, or write an article.

Re: The Penguin in the Apple

Anonymous's picture

The RISC architecture at the base of the PowerPC is quite different from that of the x86. Later in this article, we try to compare some performances.

Did you omit this section or did I just miss it?

Excuse me

Anonymous's picture

Excuse me, my original idea was to perform some benchmarks too, but the article would have been too long. I missed to remove this phrase too.

Leonardo Giordani

Re: Excuse me

Anonymous's picture

If you get the chance, try to write a follow up article to include the discussions on architecture, benchmarks and other Linux distributions for the Mac. I would be particularly interested in which might be best "for the less geeky" as I am a civil engineer not a computer engineer. (and Linux is home to lots of engineering software)

Have a happy new year,
David Gibson

Other distros

Anonymous's picture

By omitting any mention of them, the article gives the impression that Gentoo is the only distribution with support for the Powerbook. This is of course not the case. Debian has a PPC branch which works well with this hardware. And for the "less geeky", YellowDog Linux is the best choice - it is very similar to RedHat 9, and extremely easy to install. (Also, I'm given to understand that Mandrake has a PPC version, though I've never tried it).

If you want a Linux laptop and can live without Flash, RealPlayer and Wine, a 15" Powerbook is probably your best choice right now. It's more expensive than a comparable Intel-based laptop, but in my opinion it's worth it.

Re: Other distros, performance with

Anonymous's picture

>It's more expensive than a comparable Intel-based laptop...

It's hard to make these kinds of judgments without the proper perspectives, one such been performance benchmarks. Apple computers thus, from a price/performance point of view are unbeatable, in my opinion.

Re: Other distros, performance with

Anonymous's picture

Url update: http://www.apple.com/powerbook/specs.html

See PDF document entitled "Tech Overview"

Re: Other distros

Anonymous's picture

As long as it was brought up, there is also a PPC version of Suse and a port of Slackware to PPC called Slackintosh. If you are interested in something more esoteric, there is also MkLinux, which oddly enough is not really Linux at all but based on the Mach microkernel. There used to be a PPC distribution called SharkLinux, but it would appear to be discontinued and unmaintained.

Re: The Penguin in the Apple

Anonymous's picture

Good article, and I agree; if you need a laptop and want to run Linux, Apple is the way to go. I bought the 800Mhz iBook a few weeks ago for 949$, threw an Airport card in it, and another 512Megs RAM in it to max it out to 640Megs. I put Gentoo 1.4 PPC on it, and I love it. I've got everything configured; airport, sound, gnome2, kismet working, all the power prefs set, I've got all the multimedia keys (sound, brightness, eject), etc. Battery life is great, and I love having it with me at work since it's so different and compact compared to all the bulky Dells around.

Speaking of work, I really do look fwd to when I can use it with external monitors so I can give presentations with it. Also, I do wish it had two buttons below the pad, but I'm getting used to F10 and F11. Overall, I'm very happy with it.

P

Re: The Penguin in the Apple

Anonymous's picture

I have an external monitor on my ibook 800 Mhz now and working perfect (not mirrored) at 1920x1440 - 60 Hz - millions.

and try the prog sidetrack to use your pad with scrollers for up and down and right and left scrolling. Use touchpad for single click and button for right click...

throw in windowshade for minimizing in place and stuff and your ibook is set to work and feel just like any other laptop.

l8erz!!

Re: The Penguin in the Apple

Anonymous's picture

note: nvidia refuses to support ppc products under linux, so there is currently no hope of getting 3d-accelerated graphics on the 12" or 17" powerbooks. nvidia only provides drivers for x86 linux. the 'nv' driver which comes with xfree86 will make the nvidia cards do 2d and software-only 3d.

the ati radeon can do hardware 3d under linux though (using the xfree-drm ebuild)

Re: The Penguin in the Apple

Anonymous's picture

You are right. Thank you for your comment and excuse me for the wrong information.

Leonardo Giordani

Re: The Penguin in the Apple

Anonymous's picture

Linux has become a system usable even on desktop machines
What an ignorant comment. Do you think that Linus developed Linux as a server, cross-compiling from Windows 3.1?

Re: The Penguin in the Apple

Anonymous's picture

Please be careful when you say that someone is ignorant: you do not know me and are not allowed to check my knowledge of something from 10 words I wrote in an article speaking about something completely different; if you want to discuss about Linux and desktop I am ready: but please do not post thing such as "desktop is for losers", "Linus want this, want that". Those are not useful.

Leonardo Giordani

Pure puke

Anonymous's picture

Are you suggesting that if someone finds new ways to use Linux then it is bad?

:roll:

Re: The Penguin in the Apple

Anonymous's picture

"Apple, moreover, has been extremely intelligent in its relationships with the Open Source community....."

Ouch.
The TiBook described is old and afaik if it's hardware is well supported today it's because of the hard work of people like Ben and some help (after some delay) of hardware manufacturer such as ATI (radeon). Apple provides no help to get it's (I agree very nice) hardware under linux.
That's why we can't use the internal microphone today.

Christophe, who owns a TiBook and run GNU/linux (debian) on it since september 2002.

Re: The Penguin in the Apple

Anonymous's picture

The open source community isn't just Linux. Apple don't provide info to Linux developers because they don't make use of any Linux code.

However, they do have strong relationships with a number of important open source projects, the most prominent of which are FreeBSD and the Konqueror/KHTML developers. On all the open source projects Apple makes use of, they are extremely diligent about returning their patches to the maintainers, even in projects where the license doesn't explicitly require it.

In this respect, the author is correct in saying that Apple has good relationships with the open source community.

Re: The Penguin in the Apple

Anonymous's picture

Good point. These days also, with open standards been a marker for "openness", the fact that both Linux and Mac 0S-X are POSIX influenced bodes well for interoperability in a networked world.

Re: The Penguin in the Apple

Anonymous's picture

Yes they have relationships with open source projects. But that has nothing to do with the fact that you can run linux (or even *bsd) on an Apple laptop.
Apple has no reason to help us install linux on their expensive hardware and clearly don't.
By implying that if this laptop is well supported by linux it is (at least partially) because of Apple, the author is misleading potential buyers.
If you want to buy a laptop from a linux-friendly manufacturer, Apple is not the best choice. Now if you want the best hardware, Apple is in my opinion the best choice.

It amuses me that you propose Konqueror/KHTML as your second example. Clearly you have never used MacOS X. There is plenty of more significant Free Software used in it (Apache, Samba, ...).

Re: The Penguin in the Apple

Anonymous's picture

It amuses me that you propose Konqueror/KHTML as your second example. Clearly you have never used MacOS X. There is plenty of more significant Free Software used in it (Apache, Samba, ...).

Yeah except there's a big difference between Mac OS X helping the open source community projects like Konqueror/KHTML, and simply letting their users use open source software (Apache, Samba, ...). Essentially that's one of the benefits of OS X so apple are actually getting a good deal out of it.

Apple is a business company

Anonymous's picture

I wrote "Apple has been intelligent" not "Apple has become an Open Source company". I know Apple hardware is still not officially supported, and I think Ben and other people do a amazing work, but we are speaking about a business company just like which not only sells propietary software, but also hardware: what is better, Apple that begins his relationship with Open Source community or Microsoft which tries to remove us from the scene?

Please remember that we need patience and that in the world few things are absolutely white or black: I know what "would be better", but what Apple is now is already nice for me. But that is an opinion: I'm interested in speaking about it!

Thank you

Leonardo Giordani

Apple and Terra Soft

Anonymous's picture