Home arrow Info pages arrow PS3 arrow Creating PS3 toolchains on Gentoo
Installing Gentoo on the PS3 PDF Print E-mail
Written by Administrator   
Sunday, 03 December 2006

At the beginning of December 2006 if I want to install Linux on my Playstation 3, the obvious options are FC5 and Yellow Dog. I'm sure both are fine distributions, but I use Gentoo for all my home machine and at work and so step one when I unpacked my PS3 was to puzzle out how to install Gentoo.

Note: The method described below is for making a standard Gentoo install from Stage 3 on a PS3 - there is no handholding and is aimed at someone who is experienced with linux. Recently the Gentoo-PPC64 team have built a stage 4 and LiveCD which simplifies the process, there are instructions at http://overlays.gentoo.org/proj/cell/wiki/InstallGentooOnPS3

However... For me half the fun of Gentoo is in building the system and a stage 4 is one stage too many:) So below are instructions on how to do a stage 3 Gentoo install on the Sony PS3.

 

Needed Items

To make the install, there are a number of items you need:

A Playstation 3

Doh!

A Screen

I did my install on a TV as I'm waiting on a cheap HDMI to DVI cable to turn up. On a standard decent quality TV the text in kboot is very readable.

A USB keyboard

Annoyingly my PS2 Linux kit keyboard didn't work with kboot, so if you have a problem with "sticky" keys find another keyboard.

otheros.self

The "other OS" installer from Sony, which you can download at: http://www.playstation.com/ps3-openplatform/index.html

The "Addon Packages CD"

A collection of items needed for a linux install, including some good doc's, you can get this from: ftp://ftp.uk.linux.org/pub/linux/Sony-PS3/ as CELL-Linux-CL_20061110-ADDON.iso. Recently a new cd was released,CELL-Linux-CL_20061208-ADDON.iso, that includes the source so the "Addon Packages source CD" isn't needed.

 

The "Addon Packages source CD"

The source code for the contents of the "Addon Packages CD" - most importantly for us, pre-patched kernel source. ftp://ftp.uk.linux.org/pub/linux/Sony-PS3/ as ftp://ftp.uk.linux.org/pub/linux/Sony-PS3/CELL-Linux-CL_20061110-SRCCD.iso

A Gentoo PPC64 Stage 3 tarball

Get this from your local Gentoo mirror, for example for the UK a good location is: http://gentoo.blueyonder.co.uk/releases/ppc/2006.1/ppc64/stages/stage3-ppc64-64ul-2006.1.tar.bz2

A Gentoo portage snapshot

Again, best to get this from a local mirror, I got mine from: http://gentoo.blueyonder.co.uk/snapshots/portage-latest.tar.bz2

Optional - A Gentoo LiveCD

Recently a LiveCD for Gentoo has been created, and it can be used during the install process - the advantage is that instead of sitting in font of your TV you can do the install via ssh.

 

Preparing for installation

The first task is to put the installer and bootloader onto a readable medium. The easiest way to do this is to use a USB stick. You need two files, the "other OS" installer called otheros.self, and the bootloader kboot called otheros.bld.

It seems that Sony's idea is that different distributions can create their own kboot packages complete with scripts to install their specific distribution. As the Gentoo install is a manual process, we can cheat and use someone else's kboot, and the easiest one to get hold of is the one for installing Fedora Core 5, and that is on the "Addon Packages" cd image, a file called otheros.bld in the folder kboot.

On a USB stick, make a directory called PS3, and in that directory another directory called otheros. Then copy  otheros.self and otheros.bld into the otheros directory.

Also, if your USB stick is big enough, copy the stage 3 tarball and the portage snapshot onto it, and also the kernel source from the Addon Packages source CD image, linux-20061110.tar.bz2 - if there isn't enough space you could burn them to a cdrom.

 

Setting up the Playstation3

Before you continue, make sure your PS3 has been updated to the latest firmware.

The first step is to partition your hard disk. Be aware that the process will destroy any save data on the PS3 HD, so back them up! The following is copied directly from the SCE install documents:


Creating a Linux partition 

1) Turn on the PS3. After initializing, you can see GameOS menu.  You select "Settings -> System Settings".
2) After selecting "Format Utility" from sub menu, following messages are displayed.

Format Memory Stick
Format SD Memory Card
Format CompackFlash
Format Hard Disk

To allocate a Linux partition on the Hard Disk, select "Format Hard Disk".

3) After following message is displayed. you select 'Yes'.

Do you want to format the hard disk?

Yes No

4) After following message is displayed. you select 'Yes'.

If you format, all data on the hard disk will be deleted.
This data cannot be restored.
Are you sure you want to continue?

Yes No

5) You can see following message.

Select a partition setting for the hard disk.

Use All for the PS3 System
Custom

To allocate a Linux partition on the Hard Disk, select "Custom".
After selecting "Custom", following messages are displayed.

Select a partition setting for the hard disk.

Use All for the PS3 System
Allot 10GB to the Other OS
Allot 10GB to the PS3 System

To allocate a Linux partition on the Hard Disk, select one of following items.

Allot 10GB to the Other OS
Allot 10GB to the PS3 System

If your hard disk size is 20GB, you have to select 'Allot 10GB to the Other OS'.

6) After selecting the item, format process is started.
7) After creating a Linux partition, following messages are displayed.

Format Complete.
Press the X button to restart the system.

After pressing the X button, restart the system software and you can see GameOS menu.


 

The only thing I need to add to that is that the two games I've installed to my PS3 HD take over 4GB each, so you would be better off keeping the larger partion for the GameOS if you have a 60GB drive.

Installing the bootloader(kboot)

The process of installing the bootloader is pretty simple, and is done though the PS3's menu's. Insert the USB stick containing the bootloader into the PS3. Go to the System settings menu, and then find the sub menu called "Install Other OS" and follow the instructions. If there is an error, check the folder structure on the stick.

If there are no errors, congratulations, you are now ready to boot your PS3 with kboot! 

To LiveCD or not to LiveCD

When I built my first install and created these docs there was no Gentoo LiveCD for PS3, so the instructions below are for an install using the PS3 bootloader. It works fine but an issue is that you need to directly type all commands into the console on your TV, there is no option to use sshd and a remote session on another computer. If you want to do a more traditional LiveCD based Gentoo install, you can get the CD image from the experimental section of your local PS3 mirror, for example I got mine from http://gentoo.virginmedia.com/experimental/ppc64/livecd/installcd-ps3-minimal-beta.iso.

Kboot first steps

To boot up with kboot, first go to the System settings menu of the GameOS, and then choose the sub menu "Default System" - choose  "Other OS".Now when your PS3 boot's it will use kboot instead of the GameOS -to return to booting the GameOS if you quit the Gentoo install before finishing, type the command "boot-game-os" in kboot to change the boot settings.

Now shutdown your PS3, plug in the USB keyboard, and restart.

At this point you could boot up on a LiveCD, start sshd and continue this tutorial via ssh. 

If you are not using a LiveCD, after the kboot boot process completes, you should have access to a command prompt. Kboot is a simple bootloader, and includes a rescue mode with BusyBox, meaning we have access to nearly all the commands we are used to during a normal Gentoo install. To get away from the Kboot prompt, and to see our old friend BusyBox's welcome, just type sh.

Creating the Linux partitions

You can go crazy with multiple partitions, but I wanted to keep my first test install simple, and with no need of a boot partition, I created just two, swap and root. If you don't know how to use fdisk, see the wonderful Gentoo install handbook.

The Fedora Core install seems to use 512MB for swap, and that size makes sense, so my final partition layout is:

Disk /dev/sda: 10.7 GB, 10737414144 bytes
64 heads, 32 sectors/track, 10239 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         489      500720   82  Linux swap / Solaris
/dev/sda2   *         490       10239     9984000   83  Linux

Note that the PS3 drive is /dev/sda!

Now we are all used to fdisk whining at us after changing the partion table during an install, that we should reboot the system to "ensure the partition table is updated" - and we ignore it! Well it seems that at this point the PS3 doesn't re-read the partition table so the simpliest solution is to just reboot and then continue with the installation.

Next up, you need to format the root partion.

# mkfs.ext3 /dev/sda2

Kboot doesn't seem to have mkswap so just wait until you have chrooted into Gentoo and set up the swap partition then. Then mount /dev/sda2 as in a normal Gentoo install

# mkdir /mnt/gentoo
# mount  /dev/sda2 /mnt/gentoo

Installing the Gentoo Installation Files

We need to copy over the Stage 3 tarball and the portage snapshot to the PS3 drive. So just mount the USB stick (or the cdrom if you burn one)

# mount /dev/sdd1 /mnt/tmp
# cp /mnt/tmp/stage3-ppc64-64ul-2006.1.tar.bz2 /mnt/gentoo
# cp /mnt/tmp/portage-latest.tar.bz2 /mnt/gentoo

And now we just need to decompress them 

# cd /mnt/gentoo
# tar xvjpf stage3-*.tar.bz2
# tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

At this stage in a normal Gentoo install we start fiddling with make.conf, but we don't need to yet, the default settings are fine.

CHROOT'ing to Gentoo

Before we chroot, we need to copy over resolv.conf to our new install: 

# cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf

And then mount the proc filesystem

# mount -t proc none /mnt/gentoo/proc

Normally we would also bind /dev, however people have been having issue's with -o bind and mount and kboot, and for this quick install we don't really need it. If I am making some kind of horrible error by not doing this get in touch:)

And finally chroot as normal:

# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile

Congratulations, even though just a chroot you are in Gentoo on a PS3! 

Next up, sync portage:

# emerge --sync

You could also change your profile at this point, but I'd get a working install first due to the time it will take to compile a new gcc and glib.

 Before we continue there are a few bits we need to tidy up. To start with you should alter your /etc/make.conf file. Mine currently is:

# These settings were set by the catalyst build script
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="-mcpu=G5 -O2 -maltivec -mabi=altivec -pipe -fno-strict-aliasing"
CHOST="powerpc64-unknown-linux-gnu"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1"

MAKEOPTS="-j2"

USE="altivec nptl nptlonly"

 Also, to stop Genkernel moaning, you should alter your/etc/fstab file now, if you used my partitioning scheme above you can use the following edit to the default file:

#/dev/BOOT              /boot           ext2            noauto,noatime  1 2
/dev/sda2               /               ext3            noatime         0 1
/dev/sda1               none            swap            sw              0 0

Label /root

# e2label /dev/sda2 / 

 And finally set up the swap partition

# makeswap /dev/sda1
# swapon /dev/sda1

Configuring the Kernel

Copy the pre-patched SCE 2.6.16 cell kernel from your USB stick (or cdrom) to the PS3 filesystem:

# cp /mnt/tmp/linux-20061110.tar.bz2 /usr/src
# cd /usr/src
# tar jxvf linux-20061110.tar.bz2
# ln -s linux-20061110 /usr/src/linux

 Copy the .config file

# cd /usr/src/linux
# cp arch/powerpc/configs/ps3pf_defconfig .config

and then build the kernel

# make
# make modules_install

and finally copy the new kernel to /boot

# cp vmlinux /boot

Whitesanjuro found that the PS3 storage driver must be a module, so as we need an initial ramdisk - the easiest way to do this under Gentoo is to use Genkernel.

First emerge Genkernel:

# emerge genkernel

Whitesanjuro wrote on his webpage that we need to edit /usr/share/genkernel/ppc64/modules_load:

MODULES_SCSI=""
MODULES_FIREWIRE=""
MODULES_ATARAID=""
MODULES_PCMCIA=""
MODULES_USB="scsi_mod ps3pf_storage sd_mod ehci-hcd uhci-hcd usbhid"

Then:

# genkernel initrd

 You should now have in /boot

# ls -lh /boot
total 25M
lrwxrwxrwx 1 root root    1 Dec  2 11:48 boot -> .
-rw-r--r-- 1 root root 1.7M Dec  2 13:59 initramfs-genkernel-ppc64-2.6.16
-rwxr-xr-x 1 root root  24M Dec  2 14:07 vmlinux

 Getting there:)

Finally as we are using Kboot as our bootloader, it needs a config file, /etc/kboot.conf

default=linux
timeout=10
root=/dev/ram0
linux='/boot/vmlinux real_root=/dev/sda2            initrd=/boot/initramfs-genkernel-ppc64-2.6.16'

 ***Note that the html formatting on this webpage has split the last line above***

Finishing the install

From this point on, you can just follow from Chapter 8 in the Gentoo handbook, you need to:

Setup networking

Set the admin password

Set the clock and keymap config files

Emerge  syslog-ng, vixie-cron, dhcpcd, slocate

And then thats it. Type "exit" to leave the chroot, and then "reboot" to reboot your PS3. When the PS3 has rebooted to kboot, wait 10 seconds and then it should start booting Gentoo!!!

 

Installing the SCE PS3 utilities

The first thing you probably will want to do once you have a working Gentoo install is to compile and install the Linux utilities for PS3. They include the all important boot-game-os (reboots the PS3 back to the GameOS), and ps3videomode (needed when you install Xorg unless you are running on a 480i tv).

The easy way to do this is to install the utilities via the lu_zero overlay, before you can do this however you will need to install it, if you haven't there are instructions at:

http://www.daniel.jp/joomla/info/ps3/installing-the-lu_zero-overlay.html  

I should also thank powerdeveloper.org for hosting many of the files needed in the overlay.

Once you have the overlay installed, you need to make a change to your /etc/portage/package.keywords file, by adding:

app-misc/ps3pf_utils

And then install the utils with:

# emerge ps3pf_utils

Then type boot-game-os and go play Ridge Racer:)

Changing to GCC-4.1.1

Your next major task is to change from using gcc-3.4.6 to gcc-4.1.1. As on any embedded system, this is going to take a while due to limited memory, so best to do this in the evening so you can leave it running over night.

The first task is to change the profile of your install:

# rm /etc/make.profile
# ln -snf /usr/portage/profiles/default-linux/ppc/ppc64/2006.1/64bit-userland-gcc4 /etc/make.profile

Next you will want to add "nptl nptlonly" to USE for glibc-2.4. Open /etc/make.conf with nano and add "nptl nptlonly" to USE="". Then set off the compile:

# emerge -u gcc

When it has finished there are a number of further steps you should take:

# gcc-config powerpc64-unknown-linux-gnu-4.1.1
# env-update && source /etc/profile
# fix_libtool_files.sh 3.4.6
# emerge --oneshot -av libtool

The next step is a little controversial:) After changing the compiler from gcc 3 to gcc 4, I would completely recompile the toolchain, and then the entire install. Maybe you can get away with just the toolchain, but I'd rather be safe - it doesn't take that long!

# emerge -e system

Much later on followed by

# emerge -e world

Congratulations, you are now running the latest stable version of PPC64 Gentoo on your PS3!  

 

 

 

 

Last Updated ( Monday, 05 March 2007 )
 
< Prev