Installing Gentoo on a PS3 -- Update 2/6/2008

The following documentation now reflects using a 2.6.23 kernel. The Gentoo stages also now use a kernel equal to or greater than 2.6.23. The relevance of this is that the device names for the disks are no longer prefaced with sda but rather with ps3daX.

You should use the latest Sony otheros image or the otheros.bld provided on the minimal install CD or the livecd to boot the new media. Sony's otheros image can be found at: http://www.kernel.org/pub/linux/kernel/people/geoff/cell/CELL-Linux-CL_20080201-ADDON/PS3/otheros/

Given the hardware inside the PS3, the preferred method for installing Gentoo on a PS3 is to start with a stage4 tarball. The stage4 tarball will contain more precompiled binary packages and therefore can be setup faster.

The rest of this document describes the setup procedure. It assumes a certain level of experience with both Gentoo and Linux. If you have questions, ask and clarification can be made.


Obtain the Install media

To complete the install, you can either

Install cd

While you can install Gentoo from the kboot prompt, it is far more convenient to do so using a minimal Install CD. The install CD is available from the Gentoo mirrors under the experimental directory as an ISO image. For example: http://gentoo.osuosl.org/experimental/ppc64/livecd/

Stage 4 tarball

On a PS3, you can either run a 32bit-userland or a 64bit-userland. Both run 64bit kernels. The choice of which userland to use depends on what you intend to use the PS3 for. Many people find the 32bit-userland more desktop-friendly. You can find the tarball on the Gentoo mirrors under the experimental directory. To find a mirror near you, use this url: http://www.gentoo.org/main/en/mirrors.xml. You can download the stage4 now and store it somewhere locally or download it later during the install.

The tarball contains a normal stage3 install plus several required applications which are already compiled for you, like X, vim, eject, the kernel, and even the fluxbox window manager. It also contains a kboot.conf example and a working xorg.conf file.

Optional

The following items are optional and not required. The author finds having these make the setup faster:

  • You may find it more convienent or perhaps faster to use a portage snapshot. Snapshots of portage can be found on your favorite Gentoo mirror under the snapshots directory.
  • Put the stage4 and a portage snapshot on a USB memory stick in a vfat or ext3 filesystem.

Prepare your PS3 to boot another OS

Before you can install Linux on your PS3, you must prepare it to run another operating system (hereafter referred to as otheros). This is done through the PS3 operating system (hereafter referred to as game-os) and requires that you obtain an otheros image (otheros.bld), which is also available from Sony or Gentoo PS3-capable Install media. Follow the instructions at http://www.playstation.com/ps3-openplatform/manual.html to complete this task.

Boot the Install cd

The Install CD contains a PS3 kernel and the required applications to complete a Gentoo install.

* Insert the Install CD into the PS3 and power-on the PS3. * The PS3 will load the kboot kernel and you will soon see a "kboot:" prompt (hereafter referred to as the kboot prompt). * If you have not installed Linux on the hard disk before, you should be able to hit "tab" to scroll through the list of kernel labels until you find a label that has a resolution that most closely matches your TV or monitor.

Note: If you have installed Linux on your hard-drive before, the prior kboot.conf configuration file may interfere with the kboot configuration file on the Install CD. You can avert this by renaming or deleting the configuration file on the hard-drive, copying the kboot.conf from the Install CD to the kboot ramdisk, or by using e2label to rename the disk partition (i.e. e2label /dev/ps3da1 "") that contains it. Note: You can put the livecd iso contents in a memory stick or another storage supported by the ps3 and linux and just edit kboot accordingly changing 'sr0:' to the right device name (like sda1, sdb1 and so on). You can discover which device is entering 'sh' from the kboot prompt and then editing from there the kboot menu.

* Hit 'Enter' to boot the kernel. * The LiveCD will boot and automatically configure itself for the PS3 including network settings if you have a DHCP server on your network.


The rest of this procedure is very similar to a regular Gentoo install. The steps are grouped logically and little explanation will be given about them, unless it's a PS3 specific task


Prepare the hard disk for installation

You must partition your hard drive for an install. You should make at least two disk partitions: one for the root filesystem and one for swap. You will also have mark the root filesystem disk partition as bootable. At the time of this writing, the PS3 can only dedicate 10GB to another os. An example of partitioning looks like:

livecd ~ # fdisk /dev/ps3da

The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305): +9000M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1096-1305, default 1096): 
Using default value 1096
Last cylinder or +size or +sizeM or +sizeK (1096-1305, default 1305): 
Using default value 1305

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): a
Partition number (1-4): 1
Command (m for help): p

Disk /dev/ps3da: 10.7 GB, 10737414144 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

     Device Boot      Start         End      Blocks   Id  System
/dev/ps3da1  *            1        1095     8795556   83  Linux
/dev/ps3da2            1096        1305     1686825   82  Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
livecd ~ # 

Now you should format the root filesystem and swap, and then enable swap.

Note : Most kboot images do not support XFS, JFS, or reiserfs at the time of this writing.

livecd ~ # mkfs.ext3 -j /dev/ps3da1 
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1154176 inodes, 2303996 blocks
115199 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2361393152
71 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
livecd ~ # mkswap /dev/ps3da2 
Setting up swapspace version 1, size = 1299181 kB
no label, UUID=b621cc50-67db-496c-ad2a-32ec415d6516
livecd ~ # swapon /dev/ps3da2 
livecd ~ #

Lastly, mount the root filesystem so you can begin installing the software.

livecd ~ # mount /dev/ps3da1 /mnt/gentoo/

Install the base system

The next series of steps will install the stage4 software on to your PS3 hard drive.

livecd ~ # cd /mnt/gentoo/
livecd gentoo # links2 http://gentoo.osuosl.org/experimental/ppc64/stages/

From here, select the stage4 of your choice and download it. It should then be in /mnt/gentoo. Now extract the tarball.

livecd gentoo # tar -xjpf stage4-ppc64-ps3_32ul.tar.bz2 

You now need to mount procfs and /dev for our chroot. Also, copy resolv.conf into the chroot so name resolution will work.

livecd ~ # mount -t proc none /mnt/gentoo/proc
livecd ~ # mount -o bind /dev /mnt/gentoo/dev
livecd ~ # cp /etc/resolv.conf /mnt/gentoo/etc

You can now begin the chroot portion of the install.

livecd gentoo # chroot /mnt/gentoo/ /bin/bash
livecd / # env-update && source /etc/profile
livecd / # export PS1="(chroot) $PS1"

--- 'profiles/arch.list' is empty or not available. Empty portage tree?
>>> Regenerating /etc/ld.so.cache...

At this point, you need to add the portage tree onto your hard drive. This can be done with a portage snapshot or over the network. The author chooses to get portage over the network with:

(chroot) / # emerge --sync

Alternatively, you can use a snapshot of portage. This can be an advantage when dealing with GRP packages later.

First obtain the snapshot from a mirror:

wget http://ftp.osuosl.org/pub/gentoo-ps3/snapshots/portage-DATE.tar.bz2

Then unpack the snapshot and update the cache:

tar -xjf portage-DATE.tar.bz2 -C /usr
emerge --metadata

Final configuration of your system

The following steps are the minimum number of changes you need to make to have a bootable, working Gentoo install on your PS3.

Set the timezone

You first need to select your timezone so that your system knows where it is located. Look for your timezone in /usr/share/zoneinfo, then copy it to /etc/localtime. Please avoid the /usr/share/zoneinfo/Etc/GMT* timezones as their names do not indicate the expected zones. For instance, GMT-8 is in fact GMT+8.

(chroot) ls /usr/share/zoneinfo
(Suppose you want to use GMT)
(chroot) cp /usr/share/zoneinfo/GMT /etc/localtime

Configure the kboot bootloader

In many cases, the otheros images depend on a label being set on the root filesystem partition. Usually it is set to "/". You can set the label using e2label. Using the disk partitioning scheme, you would set the label like:

(chroot) e2label /dev/ps3da1 /

Kboot's configuration comes from the file /etc/kboot.conf. An example kboot configuration has been provided in /etc/ of the stage4 tarball. Use it as a starting point for your configuration file.

(chroot) / # cd /etc
(chroot) / # cp kboot.conf.example kboot.conf
(chroot) / # vim kboot.conf

Note: For systems where 64 bit user space will be installed, make sure to change the kernel and initrd to kernel-genkernel-ppc64-2.6.16-ps3 and initramfs-genkernel-ppc64-2.6.16-ps3. (Notice the added '64')

An example kboot.conf file for the stage4 and 720p resolution could look like:

#  The following is an example kboot configuration file.  Edit it
#  to suit your needs before attempting to reboot your system or
#  you may be unable to boot the new install.

#  default: the default kernel label to boot should the user not make
#  a selection. Uncomment the following line and set a default kernel label.
default=gentoo

#  timeout: number of seconds to wait for user input before the default
#  kernel label is booted. Uncomment the following line and set timeout.
#  timeout=20

#  The format from this point on is within a kernel label.  At a minimum,
#  you must pass the kernel and root device.  The syntax is as follows:
#
label='device:<path_to_kernel> initrd=device:<path_to_initrd> kernel_options'
#
#  You should also pass the video options as well. An example of video 
#  options are as follows:
#
#  480i = ps3fb:mode:1
#  576i = ps3fb:mode:6
#  720p = ps3fb:mode:3
#  1080i = ps3fb:mode:4
#  1080p = ps3fb:mode:5
#
#  You can review all possible video modes using the ps3videomode application
#  provided by the ps3pfutils package.  i.e. ps3videomode -v will display 
#  possibilities.

#  The following is an example kernel label.  Uncomment and edit as needed. 
gentoo='ps3da1:/boot/kernel initrd=ps3da1:/boot/initrd root=/dev/ram0 real_root=/dev/ps3da1 init=/linuxrc video=ps3fb:mode:8 rhgb'

Edit /etc/fstab

Given the prior disk partitioning scheme, you need to make sure /etc/fstab reflects the proper device naming. Here is an fstab entry with that assumption in mind:

 /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally aren't 
# needed; notail increases performance of ReiserFS (at the expense of storage 
# efficiency).  It's safe to drop the noatime options if you want and to 
# switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number of 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
/dev/ps3da1             /               ext3            noatime         0 1
/dev/ps3da2             none            swap            sw              0 0
/dev/sr0                /mnt/cdrom      iso9660         noauto,ro       0 0
#/dev/fd0               /mnt/floppy     auto            noauto          0 0

# NOTE: The next line is critical for boot!
proc                    /proc           proc            defaults        0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for 
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0
none    /spu    spufs   default    0 0

Set root password

You must set the root password using the 'passwd' utility.

Add a default non-root user

You should now add a default user, in this case John, and set his password.

(chroot) / # useradd -m -G users,wheel,audio -s /bin/bash john
(chroot) / # passwd john
Password: (Enter the password for john)
Re-enter password: (Re-enter the password to verify)

Exit the chroot, unmount filesystems, and reboot

You can now exit the chroot in order to reboot. Be sure to unmount the filesystems prior to rebooting.

(chroot) etc # exit
exit
livecd mnt # cd /mnt/
livecd mnt # umount gentoo/proc/ gentoo/dev/ gentoo/
livecd mnt # umount /mnt/usb/
livecd mnt # reboot

Eject the Install CD when the PS3 power-cycles.


Enjoy!

You now have a working install on your PS3. When you reboot to the hard drive, it will boot up and gdm will start. You can login with your new user and it will load the XFCE4 window manager automatically.


Installing GRP packages

Note: Due to a number of bugs in the current stable version of portage, you must use at least portage-2.1.2-rc4-8 to install GRP over the network. If you do not have this version of portage, you should add 'sys-apps/portage ~ppc' or 'sys-apps/portage ~ppc64' to your /etc/portage/package.keywords file and then 'emerge -u portage'. In the release of 2.1.2-r1, there will also be at least one fix in the dependency resolution of binary packages.

Our GRP packages are currently hosted on three sites:

Edit /etc/make.conf

To begin using GRP packages, you must tell portage about the repository by adding a refernce to it in your /etc/make.conf file. Depending on your location and whether you are 32 or 64-userland, you would add something like this to your make.conf:

PORTAGE_BINHOST="http://ftp-chi.osuosl.org/pub/gentoo-ps3/grp32/All/"
FEATURES="parallel-fetch"

Installing packages

To install a GRP file, you simply pass the -g|-G flag to emerge. For example, to install gnome you would:

# emerge -G gnome

With GRP installs, you might differences in the dependency resolution of the -G and -g switches. Consider trying both before performing the install the see the differences.

Recompiling the kernel

The stage 4's on the mirrors all come with a pre-compiled kernel. However, as is typical with Linux, many users want to tinker with the kernel. Here are a couple of details to keep in mind should you wish to recompile the kernel:

  • To obtain the kernel sources used to build the stage, you need to emerge 'ps3-sources' from the 'cell' overlay. Emerge layman and follow the post-install instructions to add the cell ovaerlay. Then emerge ps3-sources and you will have a heavily patched kernel tree based on mainline 2.6.23 and Sony patches.
  • The kernel config used to build the stages is in /etc/kernels/.
  • If you are using the 32-bit userland, be sure to set the CROSS_COMPILER to powerpc64-unknown-linux-gnu-