home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeRunning LinuxSearch this book

D.3. Preparing to Boot LinuxPPC

To get LinuxPPC installed on your Mac, you will have to partition your hard disk, install the OS, and configure your system for dual-booting LinuxPPC. Each step will be explained in detail later.

Booting LinuxPPC was revolutionized in 1998 when Benjamin Herrenschmidt released a utility called BootX, which gave PowerMac owners easy dual-boot capability. The BootX utility runs in the Mac OS as an application and comes with an extension that runs at system startup. Prior to BootX, the only way to boot PowerMacs was to edit their Open Firmware settings, which was a tricky proposition, at best. BootX also provides basic video support for machines that don't have video drivers.

With the BootX system, the Linux kernel is stored on the Macintosh hard disk. When the user gives the command to boot into Linux, BootX issues shutdown commands to the Mac OS. Just when the Mac is about to restart, the Mac OS is kicked out of the computer's RAM, and Linux begins to boot.

D.3.2. Partitioning the Hard Disk

Chapter 2, "Preparing to Install Linux", discusses the reasons for partitioning and general concepts behind it, whileSection 3.1.2, "Drives and Partitions Under Linux"" in Chapter 3, "Installation and Initial Configuration", explains the names and sizes typically used for Linux partitions. Read those sections for background; here I discuss information specific to LinuxPPC.

A full installation of LinuxPPC takes up about 650 MB. You'll want to have more available for adding files and software. For a robust installation, we recommend devoting at least one gigabyte partition. Give it more if you can spare the disk space. It is possible to pare down the installation to fit on a 100 MB ZIP disk, but there's not much you can fit on there.

Before partitioning a disk, make a complete backup of the disk. Once you partition the hard disk, all of the data on the    disk will be destroyed, and it will not be possible to recover it after it has been partitioned.

If you only have one hard disk, back up the whole disk! After you've backed up your data, boot the computer from the Mac OS CD-ROM that came with the machine, and use Apple's Drive Setup utility to format and partition the hard disk into two HFS partitions. Then install the Mac OS on the first partition, reboot into the Mac OS, restore your data, and resume the partitioning and installation process.

In this sample installation, we will use a 4 GB hard drive that has been split into two partitions of 2 GB each. The first will become an Apple HFS partition and will need to be installed on that partition. The second will be further partitioned into a pair of Linux partitions.

To partition the hard disk, you'll need the Mac OS version of pdisk, the disk partition utility. This is provided by the Red Hat installer under the name fdisk and can also be grabbed from ftp://ftp.linuxppc.org /pub/linuxppc/linuxppc-R4/RedHat/tools/pdisk.hqx. (Please use an FTP mirror site to lighten the load on the LinuxPPC system, especially if you're not in the United States. The mirror list is at http:// www.linuxppc.org /mirrors.shtml.)

Unlike most Mac OS programs, pdisk is entirely text-based. It's also a very literal program, in that it will do exactly what you tell it to do. It won't delete your hard disk--unless you tell it to. To make it harder to accidentally wipe everything out, pdisk has a few safeguards built in:

  • It won't save any changes unless you specifically tell it to do so.

  • If you quit the program (In the File menu, choose Quit), it will not save the changes you've made to your hard disk. You have to tell it to save the changes with the w (write) command.

The pdisk commands are shown in Table D-1.

Table D-1. pdisk Partitioning Commands

Command Purpose
e Edits a device's map. A "device" is a hard disk.
h Prints the available commands.
l Lists a device's partition map.
L Lists all devices' maps.
q Quits the program.
v Prints the version number and release date.

When you use pdisk, you're actually editing your hard disk's partition map. The partition map is a scary sounding name for a file that contains a list of all the partitions on your hard disk. The partition map is stored on a partition all its own.

When you're in the Mac OS, you see only one partition, which you think of as your hard disk. The other four partitions are invisible, and you don't have any reason to directly interact with them. (Unless you've decided to go and install Linux.) The first partition holds the partition map. The next three are device drivers, pieces of software that tells the Mac how to use the hard disk and where to look for the Mac OS partition. Your Mac OS software and the OS are stored on the fifth partition, which is an Apple HFS or HFS Plus partition.


As of this writing, LinuxPPC cannot read HFS Extended (also known as HFS Plus) disks, including hard disks. Research is under way to get HFS Plus support working, but there isn't a date set for when we'll have HFS Plus compatibility. Check on http://www.linuxppc.org for an announcement.

When you start up pdisk, it presents you with a text prompt:

Top level command (? for help):
Now what? Type L and press Return. The system will print out a list of every SCSI and IDE device attached to your computer, including hard disks, CD-ROM drive, ZIP drive, and so on:
Top level command (? for help): L
pdisk: can't open file '/dev/sda'  (No such device)
pdisk: can't open file '/dev/sdb'  (No such device)
pdisk: can't open file '/dev/sdc'  (No such device)
pdisk: can't open file '/dev/sde'  (No such device)
pdisk: can't open file '/dev/sdf'  (No such device)
pdisk: can't open file '/dev/sdg'  (No such device)

Partition map (with 512 byte blocks) on '/dev/hda'
 #:                type name             length   base    ( size )
 1: Apple_partition_map Apple                63 @ 1
 2:      Apple_Driver43*Macintosh            54 @ 64
 3:      Apple_Driver43*Macintosh            74 @ 118
 4:    Apple_Driver_ATA*Macintosh            54 @ 192
 5:    Apple_Driver_ATA*Macintosh            74 @ 246
 6:       Apple_Patches Patch Partition     512 @ 320
 7:           Apple_HFS untitled        4194304 @ 832     (  2.0G)
 8:           Apple_HFS untitled        4256944 @ 4195136 (  2.0G)
If you don't have any SCSI devices on your machine, you'll see a bunch of error messages go whizzing by that say things similar to:
pdisk: can't open file '/dev/sda'  (No such device)
pdisk: can't open file '/dev/sdb'  (No such device)
The can't open file messages are pdisk's cryptic way of reporting that it didn't find any device attached to your computer at that address. Instead of referring to a device as CD-ROM Drive at SCSI ID 4 or ATAPI HD 1, pdisk uses Linux's device name format. To Linux, everything is a device. Your modem, your hard disk, the floppy drive, even the RAM are considered devices.

The name of a hard disk depends on whether it's an IDE or SCSI hard disk. IDE disks are referred to as /dev/hdx, and SCSI disks are /dev/sdx. The variable x is one of the letters a, b, c, d, e, f, or g. The letter on the end of the name is how Linux distinguishes between drives.

Did you notice that IDE drives are hd and SCSI drives are sd? Those letters just denote which bus the devices are on. The letter after hd or sd is what you really need to pay attention to. If your computer has one IDE hard disk in it, it will be listed as /dev/hda. You also will get an error on /dev/hdb, which is your CD-ROM drive. Don't worry about it, though. (Trust me!)

If you have SCSI drives in your computer, pdisk will first display their names with "fake" SCSI names in the format /dev/scsibus.scsi_id, such as /dev/sdc1.5. Fortunately, it also lists their device name in proper /dev/sdletter format. Linux refers to SCSI devices with the /dev/sdletter scheme, so use that format when working with the device.

If you have an Ultra/Wide SCSI card by Adaptec or Apple, and you're planning on installing Linux on the hard disk attached to the card, prepare to be a little confused. Linux might say that your hard disk is in a different place than pdisk says it's in. This is because when Linux boots, it looks at the names of the devices attached to it. The Adaptec and Apple Ultra-Wide SCSI cards show up on the letter A. The Mac's SCSI controller is called the MESH chip, which is alphabetically after "Adaptec."

A hard disk on an Adaptec card will be at /dev/sda. Devices on the regular internal SCSI bus will follow at /dev/sdb and /dev/sdc. If your machine has only one device on the SCSI card, you're in the clear. If you have other devices attached to it, the naming game can get a little hairy.

And now, we partition:

  1. Choose the partition you're going to edit. In pdisk, type the letter e:

    Top level command (? for help): e
    Name of device: /dev/hda
    Edit /dev/hda -
    Command (? for help):

  2. Delete the second HFS partition. You have to delete the partition in order to create free space, which you will use to make Linux partitions. Looking at the partition map, the seventh partition is the HFS partition, which will be erased. To delete a partition, type the letter d followed by the number of the partition you wish to delete:

    Command (? for help): d8
    Command (? for help): p
    Typing p again will display the partition map. The Apple HFS partition has turned into free space, which you can use to make new partitions:
     7:           Apple_HFS untitled        4194304 @ 832     (  2.0G)
     8:          Apple_Free Extra           4256944 @ 4195136 (  2.0G)

  3. Create the swap partition:

    Command (? for help): c  "c" is the command to make a new partition.
    First block: 8p  "8p": Use the first block of the free space partition,
                           which is the eighth partition.
    Length in blocks: 30m  Make it 30MB. k = kb, m = mb, g = gb
    Name of partition: swap  The partition will be called swap.
    Command (? for help):

There! You've created your swap partition. Print out the partition map again. Examine the eighth and ninth partitions:

 8:     Apple_UNIX_SVR2 swap              61440 @ 4195136 ( 30.0M)
 9:       Apple_Free Extra           4195504 @ 4256576 (  2.0G)
The free space is now the ninth partition, and the new swap partition is at /dev/hda7. Next, make the root partition. Once you make root, you will be done partitioning.

When creating the root partition, instead of typing the length in megabytes, use the free-space partition's length in blocks. In this example, the Apple_Free partition is 4,195,504 blocks long, which is roughly 2 GB. By typing the partition's exact length in blocks, you will use up all the available disk space and not have wasted space left over after partitioning:

Command (? for help): c
First block: 9p
Length in blocks: 4195504
Name of partition: root
Command (? for help): p

Partition map (with 512 byte blocks) on '/dev/hda'
 #:                type name             length   base    ( size )
 1: Apple_partition_map Apple                63 @ 1
 2:      Apple_Driver43*Macintosh            54 @ 64
 3:      Apple_Driver43*Macintosh            74 @ 118
 4:    Apple_Driver_ATA*Macintosh            54 @ 192
 5:    Apple_Driver_ATA*Macintosh            74 @ 246
 6:       Apple_Patches Patch Partition     512 @ 320
 7:           Apple_HFS untitled        4194304 @ 832     (  2.0G)
 8:     Apple_UNIX_SVR2 swap              61440 @ 4195136 ( 30.0M)
 9:     Apple_UNIX_SVR2 root            4195504 @ 4256576 (  2.0G)

In this example, partition /dev/hda9 will become your root device. Write down which partition is your root device. You will need to know that later. If you have a SCSI hard disk, it would be /dev/sda7. Also note that if you are planning on installing Linux on a drive other than your startup disk, you don't have to have the Apple_HFS partition on the disk. You can devote the entire drive to Linux.

When you're done partitioning, type w:

Command (? for help): w
Writing the partition map will permanently save changes.
Save changes? (y/N): y
pdisk will come back to the Top level command prompt. At this point, the changes to your hard disk will have been saved. Type q to quit pdisk.

Tips for partitioning include the following:

  • If you make a mistake, it's not fatal. You can quit pdisk at any time without saving changes.

  • Changes are not final until you tell pdisk to write the new partition map with the w command.

Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.