Gentoo on Playstation 3
I'd been wanting to build a home media center for a while, and a month or so ago Paula and I were in town wandering through Zavvi looking for some bargain CD's and DVDs when I noticed they were selling off their PS3 stock at £250 which seemed like a fairly good deal, and after a quick bit of searching it appeared it would probably fit well as the media center….after a Gentoo install of course!
Download Everything you Need
OtherOS
In all the instructions from Sony you will see reference to otheros this refers to the kernel and boot prompt which you will use to boot your Linux install on the PS3. Many different versions kernel versions are kicking around, and unfortunately the documentation for Gentoo points to a rather old version that is missing various features such as bluetooth and wireless.
More recent versions are available from Official Kernel, and a fellow Gentoo user antonlacon kindly pointed me to his recent builds. You need to choose a kernel version to install (as of writing only ps3-petitboot-experimental-08.08.15.bld worked), download it, rename to otheros.bld and place it in PS3/otheros
on a USB flash drive (which in the code below I've assumed is mounted at /mnt/usb
and already has the PS3/otheros
directory present).
mkdir /mnt/usb/ps3/otheros
cd /mnt/usb/ps3/otheros
wget http://www.kernel.org/pub/linux/kernel/people/geoff/cell/ps3-petitboot/ps3-petitboot-experimental-08.08.15.bld
cp ps3-petitboot-experimental-08.08.15.bld otheros.bld
Install CD
You will also need a Gentoo minimal install CD from which to install your system. I found that the weekly automated builds didn't work for me, nor did the 2008.0 release. Eventually I found that the ''installcd-ps3-minimal-20071212-r1.iso'' worked fine. Downloaded it then burn the CD using your preferred CD burning application.
wget http://gentoo.osuosl.org/experimental/ppc64/livecd/installcd-ps3-minimal-20071212-r1.iso
Stage3/Stage4
You should also grab an appropriate Stage tarball. Stage1 and Stage2 installs on any architecture are generally deprecated, so you should be using a Stage3 from your local mirrors experimental
tree. Download and copy to your USB drive.
mkdir /mnt/usb/ps3/gentoo
wget ftp://gentoo.virginmedia.com/sites/gentoo/releases/ppc/autobuilds/20090607/stage3-ppc-20090607.tar.bz2
cp stage3-ppc-20090607.tar.bz2 /mnt/usb/ps3/gentoo/.
A recent version based on a 2008.0 release is available from Gentoo user anunakin. If you want to use this grab it from here
mkdir /mnt/usb/ps3/gentoo
wget ftp://lug.mtu.edu/gentoo/releases/ppc/2008.0/stages/stage3-970-32ul-2008.0.tar.bz2
cp stage3-970-32ul-2008.0.tar.bz2 /mnt/usb/ps3/gentoo/.
Some people make Stage4 tarballs available. These are quite similar to a Stage3 tarball, but include many pre-compiled packages such as Xorg, a Window Manager and so forth and therefore save you time as you don't have to compile these straight off.
Portage
Grab a copy of the latest Portage snapshot from your nearest mirror.
wget http://gentoo.virginmedia.com/snapshots/portage-latest.tar.bz2
cp portage-latest.tar.bz2 /mnt/usb/ps3/gentoo/.
Recent kernel
The kernel that comes with the live CD linked above is a bit old (2.6.23
), and as such doesn't have support for wireless, so if you've not got a wired net connection you're going to be severely limited in what you can do after things are up and running. The solution is to grab a more recent kernel (>2.6.27
) that includes wireless support.
Preparing the PS3 for Install
Upgrade your HD
Whether you've an 80Gb or 160Gb HD in your PS3, more space won't do any harm. I grabbed a Western Digital 500Gb drive. Any SATA drive will do as long as it is 9mm thick.
Changing the HD is very simple, there are lots of instructions out there such as this or this (even a video). Remember to save your trophies online first and back up your current HD to an external USB drive so you can restore your game saves to the new HD. I found that none of the guides indicated what to do if the new HD you'd bought wasn't formatted as FAT32 as I found when I tried booting the PS3.
The solution was to simply download the latest update from the Sony website, copy it to /ps3/updates/
on a USB drive (as described here), plug the USB drive into the PS3 and press Start
and Select
as advised. Follow the on-screen instructions (no need to worry about the warnings as there's nothing on your drive!) and you'll then have a 500Gb install.
mkdir -p /mnt/usb/ps3/updates
cp /mnt/usb/ps2/updates/.
Partitioning the HD
Irrespective of whether you've opted to replace the HD this is a very simple, but essential step. I'd recommend doing this before downloading any games from the Sony store or saving any games.
Before doing
anything on your new PS3, go into
Settings > System Settings > Partition Hard Disk
.
Either allocate 10Gb to the PS3
OS or 10Gb to the Gentoo install.
Keyboard/Mouse
At a bare minimum you will need a USB keyboard and once you've got everything installed and running a USB mouse will be very handy too.
Install Petitboot
Now take your USB drive which has everything listed above saved to it, insert it into a USB slot and under the Sony Game OS go to System Settings
> ''Install OtherOS''. The PS3 will automatically detect the location of the **otheros.bld** that is saved under ''/ps3/otheros'' and will install it for you.
Booting into OtherOS
Follow the on-screen instructions to reboot into Petitboot (you can either insert your install CD now, or after the PS3 has booted into Petitboot). Plug in the USB keyboard (and optionally the mouse, although you won't need it yet). You should now be at the Petitboot prompt.
Installing Gentoo Linux
If you have not inserted the Install CD do so now. You will have the option to either boot the GameOS, or (once the Install CD has been detected) to boot the kernel from the CD. Navigating these is simple using the directional arrows on your USB keyboard. On the ''installcd-ps3-minimal-20071212-r1.iso'' image all of the kernels are the same, the multiple entries simply allow for different resolutions depending on the connection and capabilities of your monitor. Choose one that fits with your monitor and hit Return
.
What follows now is basically just a rehash of whats on the Gentoo Cell Overlay. You should read and have to hand a copy of the Gentoo PPC64 Install Handbook.
Partition the HD
You've already partitioned your HD once, to allow the GamesOS and Gentoo Linux to co-exist on the same drive, however, you now need to partition the remaining portion of the HD that has been set aside for Gentoo Linux to leave at a bare minimum a root
(/
) and swap
partition. In the example below I have allocated 10Gb to the GameOS. The remaining disk is then partitioned into 10Gb for root
, 1Gb for Swap and the remainder as /data
. Under the PS3 the HD device is called /dev/ps3da
as opposed to /dev/sda
(SATA) or /dev/hda
(IDE) drives on a more traditional computer.
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): +1024M
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 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
/dev/ps3da3 * 1 1095 8795556 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
livecd ~ #
Apply the appropriate filesystem formatting to each of your partitions. Ext3 is a good option for root
and data
whilst swap partitions need to be formatted for swap
livecd ~ # mkfs.exts /dev/ps3da1
livecd ~ # mkfs.exts /dev/ps3da3
livecd ~ # mkswap /dev/ps3da2
livecd ~ # swapon /dev/ps3da2
Restart wireless network
By chance I decided to try restarting my wireless network interface, and lo and behold it worked! This is surprsing as I'd been led to believe that wireless was only added in kernel >2.6.27. It might be that the stage4 I installed included it, but I deleted all of the directories prior to trying this in favour of using a current stage3 install, so I doubt it. Assuming you've already sorted out a connection to your network and registered the MAC address if you filter, then without WPA WEP/2 you can simply do the following (of course you can configure it for more secure connections if you want).
iwconfig eth0 essid <your network ESSID>
killall dhcpcd
dhcpcd eth0
If you have a network connection you can grab a copy of the relevant stage…
mount /dev/ps3da1 /mnt/gentoo
cd /mnt/gentoo
wget ftp://gentoo.virginmedia.com/sites/gentoo/releases/ppc/autobuilds/20090607/stage3-ppc-20090607.tar.bz2
tar xjvf stage3-ppc-2009-6-7.tar.bz2
…or if you have already got a copy on your USB then you can now plug it in and mount it…
mount /dev/ps3da1 /mnt/gentoo
mount /dev/sda1 /mnt/keydev
cp /mnt/keydev/stage3-ppc-2009-6-7.tar.bz2 /mnt/gentoo/.
cd /mnt/gentoo
tar xjvf stage3-ppc-2009-6-7.tar.bz2
chroot to new install environment
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
# cp /etc/resolv.conf /mnt/gentoo/etc
# chroot /mnt/gentoo/ /bin/bash
# env-update && source /etc/profile
# export PS1="(chroot) $PS1"
Install a kernel
There are two options here, roll your own kernel (see below) or copy the kernel from the install CD. I initially opted for the later to get things up and running quickly.
exit
cp /mnt/cdrom/boot/ps3 /mnt/gentoo/boot/livecd
cp -r /mnt/cdrom/lib/modules/linux-2.6.23-r1 /mnt/gentoo/lib/modules/.
Chroot back into the install and make an entry in /etc/kboot.conf
for the kernel
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile
Before adding your entry to /etc/kboot.conf you can define the resolution of your monitor using ps3-video-mode
. This is part of the app-misc/ps3pf_utils
package so you will need to emerge that first. After its emerged you invoke the command and it will report the mode that your monitor supports. Invoke with the -h
flag and you will be shown what the refresh rates and maximum resolutions are for that mode.
emerge -av ps3pf_utils
ps3-video-mode
4
ps3-video-mode -h
ps3-video-mode (ps3-utils) 2.3
SYNOPSIS
ps3-video-mode [-m, --mode mode-id] [-r, --rgb] [-f, --full-screen]
[-g, --full-range] [-d, --dither] [-h, --help]
[-V, --version]
OPTIONS
-m, --mode mode-id
Set the system video mode to mode-id.
AUTO Detect Mode:
0: auto (480i/576i if not HDMI)
60 Hz Broadcast Modes:
1: 480i (576 x 384)
2: 480p (576 x 384)
3: 720p (1124 x 644)
4: 1080i (1688 x 964)
5: 1080p (1688 x 964)
50 Hz Broadcast Modes:
6: 576i (576 x 460)
7: 576p (576 x 460)
8: 720p (1124 x 644)
9: 1080i (1688 x 964)
10: 1080p (1688 x 964)
VESA Modes:
11: wxga (1280 x 768)
12: sxga (1280 x 1024)
13: wuxga (1920 x 1200)
60 Hz Full Screen Broadcast Modes:
129: 480if (720 x 480)
130: 480pf (720 x 480)
131: 720pf (1280 x 720)
132: 1080if (1920 x 1080)
133: 1080pf (1920 x 1080)
50 Hz Full Screen Broadcast Modes:
134: 576if (720 x 576)
135: 576pf (720 x 576)
136: 720pf (1280 x 720)
137: 1080if (1920 x 1080)
138: 1080pf (1920 x 1080)
-r, --rgb
Use RGB color space mode.
-f, --full-screen
Use full screen mode.
-g, --full-range
Use full range mode.
-d, --dither
Use dither mode.
-h, --help
Print a help message.
-V, --version
Display the program version number.
In this instance I have a 1080i TV that is connected by HDMI.
Write your /etc/kboot.conf
Using the information on your TV/Monitor from the above step you are now ready to write your /etc/kboot.conf
default=livecd
livecd='ps3da1:/boot/ps3 initrd=ps3da1:/boot/initrd root=/dev/ram0 real_root=/dev/ps3da1 init=/linuxrc video=ps3fb:mode:4 rhgb'
Configuring Gentoo
You will want to customise your /etc/make.conf
here is what I did to mine.
(chroot) livecd # nano /etc/make.conf
## Mirrors used in the UK
GENTOO_MIRRORS="http://gentoo.virginmedia.com http://www.mirrorservice.org/sites/www.ibiblio.org/ge
ntoo/"
#SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
## Define USE flags
USE="alsa bash-completion cups dbus div4linux emacs hal geoip gtk gtk2 glx ipod jpeg -kde -mozilla mpd nptl nptlonly mp3 ogg opengl oss perl postgres png qt scanner real tiff usb win32codecs X xulrunner"
## Define Portage Overlay directory
#PORTDIR_OVERLAY="/usr/portage/local/"
## Default options for emerge
EMERGE_DEFAULT_OPTS="--verbose --keep-going"
## Synaptics input device
INPUT_DEVICES="evdev keyboard mouse synaptics"
## Add layman support
source /usr/portage/local/layman/make.conf
## Features that are required
FEATURES="nodoc parallel-fetch"
## Linguas flags
LINGUAS="en_GB"
Also you'll want to enable remote access and start the network device on boot. You need to edit /etc/hosts.deny
and /etc/hosts.allow
to ensure secure access, then add the services to the default runlevels. Assuming your home network is on 192.168.1.*
echo 'ALL:ALL' > /etc/hosts.deny
echo 'ALL EXCEPT in.ftpd:192.168.1.*' > /etc/hosts.allow
rc-update add sshd default
rc-update add net.eth0 default
Emerge useful stuff
I wanted to get things up and running as quickly as possible and since I already run two Gentoo systems I had a pretty good idea of what I wanted to install. Rather than explicitly emerge-ing everything I opted to install a few things that would pull lots in as dependencies (e.g. xfce-base/xfce4
will pull in X and lots of other things). I also wanted to be able to mount my network drives early on so opted to emerge nfs-utils
, there are various different system tools that are useful (gentoolkit
).
emerge --sync
emerge autounmask
autounmask -n xfce-base/xfce4
emerge -av nfs-utils eix openssh wireless-tools xfce-base/xfce4 gentoolkit nm-applet wireless-tools portage-utils eselect ccache mplayer wpa_supplicant mozilla-firefox logrotate anacron texlive-latex texlive-latexextra texlive-latexrecommended ps3pf_utils keychain gdm
update-eix -q &
Set your Timezone
Set your timezone by editing /etc/conf.d/clock
Adding to runlevels
Once installed you will want to make sure various different services are started on booting.
rc-update add netmount default
rc-update add sshd default
rc-update add net.eth0 default
Bluetooth
I figured it would be handy to have a bluetooth manager so I could use the keyboard and mouse that I bought to go with the PS3. This required making a copy of the most recent blueman ebuild
mkdir -p /usr/portage/local/net-wireless/blueman
sed 's/~x86/~x86 ~ppc/' /usr/portage/net-wireless/blueman/blueman-1.10.ebuild > /usr/portage/local/net-wireless/blueman/blueman-1.10-r1.ebuild
autounmask -n net-wireless/blueman-1.10-r1
emerge -av blueman
Compiz Eye Candy
Compiz provides lots of beautiful eye candy for your desktop.
autounmask -n x11-wm/compiz-0.8.2-r1
autounmask -n x11-plugins/compiz-plugins-main-0.8.2
autounmask -n x11-plugins/compiz-plugins-extra-0.8.2
echo 'x11-libs/cairo-1.8.6-r1 glitz svg xcb' >> /etc/portage/package.use
echo 'x11-libs/libX11 xcb' >> /etc/portage/package.use
emerge -1 cairo && emerge -av compiz-plugins-extra
Bricked PS3?
If you make a mistake and think you have bricked your PS3 fear not, you can reboot into the system OS by holding down the power button for five-ten seconds until a beep is heard when first switching the unit on. You'll have lost any display settings but these are easy to restore.
Stuck Disc
My first attempt at booting the Live Gentoo CD dropped me into the petitboot
command prompt but didn't seem to let me boot from the CD. Unfortunately I could no longer eject the disc either. Not from within the Linux shell, nor on returning to the Playstation OS. Advice on the net suggested that holding down the eject button for 10 seconds forced a hard eject, but this didn't work for me, not at any point in time. I tried when the power was just switched on, when the unit was in stand-by, after it had been on for a while. It just did not want to eject, and I suspect its because the eject button is faulty. The disc wasn't even listed under the menuing system so I could eject it from the software side.
Eventually I noticed that after starting a demo that I'd downloaded (Watchmen) if I hit the Playstation button on the remote which brings up the Playstation XMB menuing system the CD-R was listed, however, it wouldn't eject and selecting it forced exiting from the game and returned me to the XMB menu, where the CD-R, was no longer listed!!! On a random chance I decided to try the same with another demo, Tony Hawks Proving Ground which I had downloaded, but not installed. After installing it, and starting it up I hit the Playstation button and the menu appearaed with the CD-R listed as it had under Watchmen, only this time, the menu system allowed me to eject the disc! Success, a call to Sony customer Services ensued, and they replaced the PS3 with one that has a working Eject button within a couple of days (I couldn't be at home the next day which they said they could deliver on!).
Links