Debian GNU/Linux on Origin 200 HOWTO ------------------------------------ by Andrew Clausen Copyright (C) 2003 Silicon Graphics, Inc. This document may be modified and/or distributed without restriction. 1. Introduction 2. Booting 3. Partitioning and creating a root device 4. Installing a base distribution 5. Installing a kernel 1. INTRODUCTION You can find this document at http://members.optusnet.com.au/clausen/sgi Debian GNU/Linux on the Origin 200 (and in theory, Origin 2000, etc.) is quite similar to Debian GNU/Linux running on 32-bit machines such as the Indy. It runs the same 32-bit userland, and is 100% binary compatible. The main difference is the kernel must be 64-bit. In principle, it should be possible to have a single Debian GNU/Linux CD that supports both 32-bit and 64-bit MIPS (including Indy and Origin 200s) out of the box. Unfortunately, there are a few problems, and installing on Origin 200s will be a bit more painful until these are resolved. Installation itself is quite painful, but once you are up-and-running, everything seems to be quite smooth and easy to maintain via apt and dpkg. 2. BOOTING Unfortunately, this is quite complicated since the ip27 PROM (firmware) has a bug which means it's only possible to load kernels from xfs partitions... not directly from the volume header. It might be possible to install over the network with tftp, but there are rumoured to be bugs and SGI-isms that in practice make this impossible, unless you use SGI Irix tftp and dhcp servers. I haven't verified this. (1) You must have an SGI partition table (volume header), that contains an xfs partition with a linux kernel. I have written some shell scripts (at http://members.optusnet.com.au/clausen/sgi/gen-mips-cd) for putting these on ISO images. (There are comments in the scripts describing the gory details, if you're interested) You'll want to attach an initrd to your kernel... probably Debian's root.bin. If you're compiling your own kernel, make sure you make the ramdisks big enough to hold the initrd! (2) To enter the PROM command line, hit "Escape" and "5" on bootup. (3) To list the devices, type "hinv". (4) To find which device has your kernel, try typing "ls dksc(1,2,3)" (inserting random numbers). The first number is the controller number. The second is the unit number. The third is the partition number (counting from zero). The output from (3) should give you some hints. (5) Once you've found your kernel (on my CD drive, it's "dksc(2,5,4)/linux"), you can boot it like this: boot -f dksc(2,5,4)/linux root=/dev/ram0 You can pass other kernel parameters, for example: boot -f dksc(2,5,4)/linux root=/dev/ram0 init=/bin/ash 3. PARTITIONING AND CREATING A ROOT DEVICE Once you've booted a basic Linux miniroot off a CD, you'll want to create partitions and file systems. You can either use fdisk + e2fsprogs or GNU Parted 1.6.x (optionially with e2fsprogs). These tools are well documented elsewhere. You need to create: (1) an SGI Partition table (2) a root partition (probably ext2, although other file systems should work if you have a kernel compiled with support...) (3) a boot partition. This will contain a kernel embedded in an xfs partition. (4) a swap partition (not 100% necessary) 4. INSTALLING A BASE DISTRIBUTION There are three options: (1) Try the Debian installer. I have been able to get this to semi-work... I keep running into lots of bugs... still lots more to fix! :( If you do run until problems, remember that you can drop to a shell from the installer (near the bottom of the list), and can examine the log by typing "cat /var/log/messages". There are three approaches for using the Debian installer: (a) if you're lucky, it might just work out of the box. Try this at the PROM: "boot -f [your-cd's-partition]/linux root=/dev/ram0" (b) if that crashes (it probably will... my fixes probably haven't been applied yet), then try this at the PROM: "boot -f [your-cd's-partition]/linux root=/dev/ram0 init=/bin/ash" And then type this at the shell: # /etc/init.d/rcS # /sbin/dbootstrap That will get you into the installer. Once you've partitioned your hard disk and initialized your root partition, skip straight to "installing a base system". (You'll need to scroll down the list). I got odd problems with this, but it gets sufficiently far to do most of the work before trying method (3). (c) Get a shell via the same method as in (b) and follow the instructions and follow the instructions here: http://www.debian.org/releases/stable/mips/ch-preparing.en.html#s-linux-upgrade (2) Copy an image across. Very reliable, but you need an image to start with! This is as simple as booting up with a shell, and doing: # cp source target-partition [I have such images locally, but I'm not sure how I should distribute them] (3) Pretend to be the Debian installer. Just because the Debian installer crashes doesn't mean you can't do the same process on the command line :) This is how I installed the first time, and then I did (2) afterwards. Here's how you do it: 1. Mount your root partition (eg: "mkdir /root; mnt /dev/sda3 /root") 2. Untar the debian miniroot onto the root partition (eg: "cd /root; tar zcf root.tar.gz") 3. Reboot (or chroot) to your new root device. Rebooting is probably less thinking, but chrooting is quicker: (eg: "chroot /root /bin/bash") The problem with chroot is you now can't access your cd drive directly. You can mount it again, though... 4. I'll write the rest as a shell script with comments. You actually want to type this line-by-line though. export PATH=/bin:/sbin:/usr/bin:/usr/sbin /etc/init.d/rcS # manually create /etc/fstab # mount your cd, if you have one # Install the data of the base debian packages. You need to have # these copied this onto your base image, or have them # on your CD, or something. These files are found in the # basedebs.tar.gz file included in Debian. cd /path/to/base/debian/packages for i in *; do ar -p $i data.tar.gz | gunzip | (cd /; tar x) done # a function for finalizing the install of Debian packages... dpkg-install() { ar -p $1 control.tar.gz | gunzip | (cd /tmp; tar x) /tmp/preinst /tmp/postinst rm -rf /tmp/* } # setup base-files: dpkg-install base-files* # setup base-config: dpkg-install base-config* # setup dpkg: dpkg-install dpkg* # may need to repeat that for other things, like info? # install properly now, with debconf stuff, and the dpkg database # being maintained properly now. Note: may need to create empty # files that dpkg complains about being missing dpkg -i * # repeat lots # setup networking: /etc/interfaces, /etc/resolv.conf # setup inittab - hack up /etc/inittab.install # serial console (ttyS0). Kill tty1-6, and just use ttyS0 at # 9600 baud # setup apt, and install to your heart's content :) 5. INSTALLING A KERNEL This is a bit painful. You need to put it on an XFS partition, but there isn't much chance of getting XFS working on linux-mips64 (unless you're feeling inspired and want to fix all the inevitable Issues...). The easiest thing to do is re-use the kernel from the boot cd. Just copy it into another partition, and that's it :) (e.g. cp xfs.img /dev/sda2) Or, you can create xfs file systems on another machine. Hint: use loopback! Something like: dd if=/dev/zero of=xfs.img bs=10M count=1 /sbin/mkfs.xfs \ -b size=4096 \ -d file,name=xfs.img,size=10m \ -n version=2 \ -l internal,size=4096b \ -L linux mkdir xfs-mnt mount -o loop xfs.img xfs-mnt cp vmlinux.64 xfs-mnt/linux umount xfs-mnt