Skip to content

Instantly share code, notes, and snippets.

@ABelliqueux
Last active May 13, 2024 01:56
Show Gist options
  • Save ABelliqueux/8c3602fcbe1e0a7e44a0d0b0fc107f96 to your computer and use it in GitHub Desktop.
Save ABelliqueux/8c3602fcbe1e0a7e44a0d0b0fc107f96 to your computer and use it in GitHub Desktop.
How to install Linux on the Playstation 2

Adapted to gist from https://unix.stackexchange.com/questions/344225/how-to-install-linux-on-the-playstation-2
Credits to Alison E.E.

Preambule

Looking to learn about game development? Are you a Linux enthusiast looking to test the claim that "Linux runs on everything"? Perhaps you are a software developer who is looking to release for multiple architectures, and you don't have another MIPS Little Endian machine on-hand for testing your programme. Whatever your situation there are a surprising number of reasons to install Linux on a Playstation 2, even sixteen years after it's release (boy do I feel old all of a sudden.), yet an equally surprising lack of documentation about it or how to install it.

Now don't get me wrong, if you want to use the original Sony Linux Kit, or one of it's updated open source releases on a fat PS2 with a network adapter and an IDE hard disk you can find plenty of info. However this requires the acquisition of several things, and can be quite expensive, especially when it comes to the Sony Linux Kit itself. This guide will cover some basics about the PS2's native hardware, and it's hardware compatibility, and then we'll move on to how to install Linux on a wider variety of PS2.

What CPU does the PS2 use?

The PS2 uses a single core "Emotion Engine" CPU, clocked at 295MHz in the original fat models, and 299MHz in newer slim models. The Emotion Engine is a 64-bit MIPS Little Endian CPU, with support for 128-bit addresses.

How much RAM does the PS2 have?

It has 32MB RDRAM and 4MB of eDRAM.

What kind of GPU does it have?

The PS2 uses the "Graphics Synthesizer" GPU clocked at 147.4MHz, and is capable of outputting up to 1920x1080 graphics at 60Hz in 32-bit color.

What external storage does it support?

An unmodified PS2 supports Audio-CD, Video-DVD, and up to two memory cards of up to 128MB in size for game saves. A PS2 modified with a software exploit also supports two memory cards of up to 128MB for general file management and storage, and browsing files on data-CD/DVDs via a 3rd party file manager such as uLaunchELF, as well as some USB 1.1 disks, with support for USB 2.0 disks being available on newer slim models via software support. A PS2 modified with a modchip has added support for data-CDs and DVDs without a 3rd party programme.

Linux setup

Now on to the Linux installation.

Live distro

A quick side note, if you just want to test or play around with Linux on your PS2, you can simply burn the image found here: link to a DVD and run this programme link via uLaunchELF from a flash drive or memory card with no setup required. Now on with the Linux!)

Full install

First of all there are several prerequisites for installing Linux on your PS2, please note that this guide is aimed at installation on a slim PS2, if you have a fat PS2 you should download and install the copy of Sony's PS2 Linux here: link Also note that the machine used to test this guide was a PS2 model SCPH-79001 (silver special edition) and thus it is safe to assume this should work on any model of PS2 lower than SCPH-90000 (the model SCPH-90000 and later cannot be softmodded, and thus you will not be able to launch a Linux bootloader.)

Pre-requisites

Now, to install Linux on your PS2 you will require:

  • A software mod for your PS2, such as the FreeMCBoot OS, or a modchip, as you will need a way to launch your bootloader.

  • A memory card of at least 8MB, but preferably 16MB, 32MB or 128MB to ensure you have ample space. This MC will permanently hold your boot loader configuration, Linux kernel, and RamDisk. Since your FreeMCBoot installation will take up approx. 4.5MB on it's respective MC, plus the Kernel, RamDisk, and config file together will take up at least 7MB (up to 9.5MB if you choose to include the generic RamDisk as well) and you only have two MC slots, unless you are willing to use a MC port expansion you will likely need the extra space provided by an above-average size MC to store your saved games.

  • A USB disk of at least 8GB (either a USB flash drive or external IDE/SATA HDD/SSD will work)

  • Access to an existing install of a Debian based system (while making this guide I used Debian 8), if you are on a macOS or Windows system I recommend using VirtualBox, but make sure you install the guest additions to more easily transfer the required files.

  • A USB 1.1 or 2.0 keyboard. While Sony's PS2 Linux, and the BlackRhino Linux live DVD come with an on screen keyboard, this installation will use Debian 5, which requires a proper physical keyboard.

Installation steps

Once you've met these prerequisites go ahead and proceed with the installation steps as follows:

  1. Download these files:
  • vmlinux_v11.gz and the modules package link
  • initrd.usb2.gz link
  • kloader3.0.elf link
  • The Debian 5 installation files link
  1. Copy the files vmlinux_v11.gz, initrd.usb2.gz, and kloader3.0.elf to a flash drive formatted as FAT32, plug it into your PS2, and copy them to a folder named kloader on your MC of choice (must have at least 7MB free). If there isn't enough space you can copy kloader3.0.elf to a second MC, but I recommend keeping the files together if possible.
  2. Connect the USB disk you have selected for Linux installation to your existing Debian machine. Create an MS-DOS partition table on the disk.
  3. Open a terminal, start a root shell (sudo -i, or su). Run fdisk /dev/sdX where X is your USB disk's identifier. Delete all existing partitions on the USB disk, create one new primary partition that leaves 1GB of free space left of the disk (i.e. if you have an 8GB disk, you should use +7168M as the end cylinder option). Create a secondary partition of 1GB (+1024M as the end cylinder option), and change it's type to swap (t, followed by 2, and finally 82). Then use w to write changes to disk.
  4. Run mkswap /dev/sdX2 where X is your USB disk's identifier. Then run mkfs.ext2 -I 128 /dev/sdX1. Be sure to include the -I 128 option, it is required.
  5. Once the filesystems have been created, mount your USB disk's first partition under /media/usb/. Create a directory called install in the directory you just mounted the disk on.
  6. Create a folder named debian on your Debian machine, and place all of the files you downloaded in step 1 into it. The next several steps will be commands for ease of writing.
  7. cp -R /path/to/folder/debian/* /media/usb/install/
  8. cd /media/usb/
  9. tar -xzf install/debian-lenny-mipsel-v1.tgz
  10. cp install/vmlinux_v11.gz boot/; cp install/initrd.usb2.gz boot/
  11. bunzip2 install/linux-2.6.35.4-mipsel-ps2-modules-v11.tar.bz2
  12. tar -xf install/linux-2.6.35.4-mipsel-ps2-modules-v11.tar
  13. nano etc/fstab and change ext3 to ext2. Save the file and exit (ctrl-x, y, enter)
  14. Unmount your USB disk with umount /dev/sdX1
  15. Unplug your USB disk. Turn on your PS2, plug your USB keyboard in to USB port 2, and start uLaunchELF. NOTE: do not plug in your USB disk yet, as the PS2 cannot natively read ext2 disks, and it will cause PS2 to hang on boot.
  16. In uLaunchELF, navigate to mc0:/kloader/ or mc1:/kloader/ if you placed the boot loader on your second MC in step 2. Run kloader3.0.elf, watch the bottom of the screen, and when Autobooting in 3... appears, press a button on your controller, or a key on the USB keyboard. A boot configuration menu should appear.
  17. Go to the bottom of the menu using the arrow keys on your USB keyboard, and select Advanced Menu. Go to Select Kernel>Memory Card X>kloader>vmlinux_v11.gz then Select Init RAM disk>Memory Card X>kloader>initrd.usb2.gz. Turn Autoboot off.
  18. Go to Configuration Menu at the bottom of the current page, make sure Use SBIOS from TGE, TGE for SBIOS New Modules, Enable hard disk and network, Patch libsd (enable USB) are all enabled, and Enable IOP debug output is disabled.
  19. Go to Module List and make sure that rom0:LIBSD is enabled.
  20. Go back to the Configuration Menu and select Edit Kernel Parameter and add the line newroot=/dev/sda1 (NOTE: pressing enter will save change and return to the Configuration Menu, so use a space after the existing line instead, and press enter once you have added this line.)
  21. Go back to Advanced Menu, and then Boot Menu, Select Save Config on MC0.
  22. Insert your USB disk into your PS2's USB port 1, go to Advanced Menu, and select Boot Current Config.
  23. Debian should boot now, when you reach the login screen use root as the login. The root user does not have a password by default, and there are no other users, so now you need to fix both. Run adduser yourusername and enter the needed info (omit personal details if you want), and a user will automatically be created.
  24. Type exit, and login as your new user with the login info you set. Run su to enter a root shell, then run passwd root and set a password for the root account. Make sure it is something you can remember! This version of Debian doesn't come with sudo preinstalled, you will need access to the root account until you can change that.
  25. Finally, while you are still in a root shell, run nano /etc/apt/sources.list and change the existing source to deb archive.debian.org/debian lenny main so that you can install packages via a network if needed.
  26. Networking will not function by default, to enable it add :
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

to the file /etc/network/interfaces, plug in an ethernet cable, and reboot the PS2 into Linux again. 28. Now that networking is up and running, you should install sudo for improved security when performing administrative tasks. This is Debian so log in to your user, drop to a root shell and run apt-get update && apt-get upgrade && apt-get install sudo (There will be several packages needing updates so be sure not to omit those commands.). 29. You have sudo installed now, but you aren't in the sudoers file, so while in the root shell run visudo /etc/sudoers, and under

##
## User privilege specification
##
root ALL=(ALL) ALL

add the line : yourusername ALL=(ALL) ALL

Save your changes to the sudoers file, log out, and log back in.

Conclusion

The base installation is now complete. Any other customization you want to make can be done as you would with any other Linux distro. If you want to install the PS2SDK for developing PS2 specific software you can find the source here: link If you try to compile it on the PS2 it will run out of memory and hang, so make sure to set up the build environment on your main machine, and copy files to the Debian USB manually or via a network in order to get them on the PS2 for testing. The PS2 controller will not work as a mouse, so I recommend a USB hub for both the mouse and keyboard (if that is not an option mousekeys can be activated as usual with Alt+Shift+Num Lock). Thanks for reading, and I hope this helped someone looking to install Linux on their PS2. I had tried for months to get this working, and have very recently done so, thus decided to try and make it easier for others wanting to do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment