Installing PS2 Linux Release 1.0 alongside game data ---------------------------------------------------- Author: Andrew Church NOTICE: This document is based on the author's own experience, and may not work as described under other environments. Use this document at your own risk; the author will not accept any responsibility for lost data or any other damage or unintended consequences. For the pedantic, in this document 1MB = 2^20 (1048576) bytes and 1GB = 2^30 (1073741824) bytes. ------------------------------------------------------------------------ Before starting, ensure that you have available a PC running Linux with at least 500MB of hard disk space free, and that can communicate with the PS2 via Ethernet (in the procedure below, the PC is assumed to have an IP address of 192.168.0.1). Procedure: 1. Start up the installer as usual. 2. At the "HDD Setup" screen, do not select either Disk Druid or fdisk yet. Instead, follow these steps to create a partition. (a) Switch to the second virtual console (which has a shell running) with Alt-F2. (b) Create a device file for the hard disk with "mknod /dev/hda b 3 0". (c) Start up fdisk in sector-unit mode with "fdisk -u /dev/hda". (d) Create a partition sized according to the PS2 filesystem specs (see table below). The PS2 uses a partitioning scheme in which each partition must be a multiple of 128MB, and the first 8 sectors of each partition are reserved. Partitions can be made out of several "sub-partitions" joined together; this is a necessity for partitions larger than 1GB, since a single sub-partition must be either 128, 256, 512, or 1024MB. In this case, 8 sectors are reserved at the start of each sub-partition. Size | Sectors || Size | Sectors || Size | Sectors ---------+----------++---------+----------++---------+---------- 128MB | 262136 || 5120MB | 10485720 || 21504MB | 44040024 256MB | 524280 || 6144MB | 12582864 || 22528MB | 46137168 384MB | 786416 || 7168MB | 14680008 || 23552MB | 48234312 512MB | 1048568 || 8192MB | 16777152 || 24576MB | 50331456 640MB | 1310704 || 9216MB | 18874296 || 25600MB | 52428600 768MB | 1572848 || 10240MB | 20971440 || 26624MB | 54525744 896MB | 1834984 || 11264MB | 23068584 || 27648MB | 56622888 1024MB | 2097144 || 12288MB | 25165728 || 28672MB | 58720032 1280MB | 2621424 || 13312MB | 27262872 || 29696MB | 60817176 1536MB | 3145712 || 14336MB | 29360016 || 30720MB | 62914320 1792MB | 3669992 || 15360MB | 31457160 || 31744MB | 65011464 2048MB | 4194288 || 16384MB | 33554304 || 32768MB | 67108608 2560MB | 5242856 || 17408MB | 35651448 || 34816MB | 71302896 3072MB | 6291432 || 18432MB | 37748592 || 36864MB | 75497184 3584MB | 7340000 || 19456MB | 39845736 || 38016MB | 77856464 4096MB | 8388576 || 20480MB | 41942880 || Illustrated example of creating a 4GB partition: Command (m for help): n (New partition) Command action e extended p primary partition (1-4) p (Create a primary partition) Partition number (1-4): 1 (Create partition number 1) First sector (63-78124094, default 63): (Press Enter) Using default value 63 Last sector or +size or +sizeM or +sizeK (63-78124094, default 78124094): +8388575 (Specify the last sector with a relative value; make sure to subtract 1 from the partition size) (e) If you check the size of the partition with the "p" command, the block count should be half the sector count you used above. You may see a "cylinder boundary" error as below, but it can be safely ignored. Device Boot Start End Blocks ID System /dev/hda1 63 8388638 4194288 83 Linux Partition 1 does not end on cylinder boundary: phys=(522,42,63) should be (522,254,63) (f) Write the partition table to disk with the "w" command. (g) Press Alt-F1 to return to the installer. (h) Select "fdisk" from the installer, then select "Done" on the following screen. (i) A list of partitions will be displayed; set the mount point of the partition you created in (d), then create a swap partition. (You can create the swap partition in (d) as well, but since the partition will not be copied, it is not necessary to conform to the PS2 partition sizes.) (j) Select "Done". 3. Finish the install as usual. 4. Reboot the PS2, and log in as root. 5. Download one of the initrd filesystems from http://achurch.org/ps2/ (choose either VGA or NTSC depending on your display type). 6. Mount your Linux memory card (mount /mnt/mc00). 7. Delete all of the files on the memory card (rm -f /mnt/mc00/*). WARNING: You will be unable to boot Linux after performing this operation, so do not reboot or shut down the PS2 until you complete the next step. 8. Untar the file you downloaded in step 5 into the memory card (e.g. tar Cxzvf /mnt/mc00 /tmp/ps2linux-boot-vga.tar.gz). 9. Reboot the PS2 and select "Initrd" from the boot menu. 10. Log in with any username, and use ifconfig to set the Ethernet IP address if needed (the default address is 192.168.0.3/24). 11. Transfer the PS2 Linux partition data to your PC. In the following sample command lines, "pc:~>" indicates commands to execute on the PC, and "ps2:~>" indicates commands to execute on the PS2. pc:~> nc -lp12345 | gzip -1 > ps2-hda1.gz ps2:~> dd bs=4M if=/dev/hda1 | nc 192.168.0.1 12345 Note that the transfer program "nc" will not exit even when the data finishes transferring; wait for the "### blocks out" message from the dd command, then press ^C on the PS2 side. Make certain you do not press ^C on the receiving (PC) side, or you may lose data! (Note: "nc" is a program that functions like "cat" over TCP/IP, and can be used to send data between machines on a network. An i386 version can be found at http://achurch.org/ps2/nc.gz.bin if you do not have it installed already.) The compressed partition data will usually fit into about 500MB, but if there is data already present on the hard disk when you install, the compression ratio will fall, resulting in a bigger compressed file; depending on your PC environment, you may even hit a file size limit at 2GB resulting in a failed transfer. In this case, mount the partition, then create a file containing only zeros (e.g. "cat /dev/zero >/mnt/temp1") to clear out the free space on the partition. Make sure you unmount the partition again before transferring it. Also note that recent PS2 models have been reported to lock up while transferring, due to a bug in the network driver. If this happens, try using the alternate driver (from playstation2-linux.com): ps2:~> /sbin/rmmod smap ps2:~> /sbin/insmod smap-alt ps2:~> /sbin/ifconfig eth0 192.168.0.3 netmask 255.255.255.0 12. Insert the HDD utility disc into the PS2, and reboot the PS2. 13. Use the HDD utility disc to initialize the HDD. 14. Re-insert the PS2 Linux boot disc, reboot the PS2, and boot the "Initrd" menu option (as in step 10). 15. Use the "ps2fdisk" command to create a Linux partition on the hard disk, with the same size as you selected in step 2. Ensure that the partition table is re-read successfully when you exit ps2fdisk; if an error is displayed, reboot the PS2 as in step 14. (Note: This ps2fdisk utility was developed by analyzing the format of PS2 HDD partitions, and shares no code with the ps2fdisk utility released by Sony with the beta version of the Linux kit. The source code is available as /root/ps2fdisk.c on the initrd filesystem, or from http://achurch.org/ps2/ .) 16. Transfer the Linux partition from the PC back to the PS2. Example: ps2:~> nc -lp12345 | reblock > /dev/hda1 pc:~> (zcat ps2-hda1.gz; echo >&2 done) | nc 192.168.0.3 12345 The "echo" command is included to indicate when the transfer has completed. As in step 11, press ^C on the sending side when the transfer is finished. (Note: The "reblock" command gathers incoming data into 4MB blocks and writes to the hard disk block by block, giving better than twice the performance of dd.) 17. Reboot the PS2, and select "Memory Card" from the boot menu. If Linux boots successfully, then the installation is complete. ------------------------------------------------------------------------ If you already have game data stored on your hard disk and want to preserve it across the Linux install, then you can transfer the entire disk image to your PC before starting the process, in the same way you transfer the Linux partition in step 11; later, instead of performing steps 12 and 13, transfer the image back to the PS2. However, if your PC environment does not allow the creation of files larger than 2GB, then you will need to split the HDD image into several parts (perhaps by transferring 4GB at a time, or by finding appropriate split points through trial and error). For example: # Transfer the first 4GB pc:~> nc -lp12345 | gzip -1 > ps2-hda.1.gz ps2:~> dd bs=4M count=1024 if=/dev/hda | nc 192.168.0.1 12345 # Transfer the next 16GB pc:~> nc -lp12345 | gzip -1 > ps2-hda.2.gz ps2:~> dd bs=4M skip=1024 count=4096 if=/dev/hda | nc 192.168.0.1 12345 # Transfer the remaining 17+GB pc:~> nc -lp12345 | gzip -1 > ps2-hda.3.gz ps2:~> dd bs=4M skip=5120 if=/dev/hda | nc 192.168.0.1 12345 # When restoring to the PS2, send it all at once ps2:~> nc -lp12345 | reblock > /dev/hda pc:~> zcat ps2-hda.[1-3].gz | nc 192.168.0.3 12345