Total Knowledge: SGI O2 BootCD HOW-TO


Home Projects Jobs Clientele Publishing Contact


This document describes steps you need to go through in order to make CD-ROM for booting SGI MIPS-based machines. It was developed with SGI O2 in mind, but will most likely apply to Indy, Indigo2, and possibly Origin as well. Success/failure reports are welcome.


  1. SGI firmware (ARCS or ARCS64 prom monitor) doesn't understand ISO9660 file system. Instead, in order to boot, it expects a disk with SGI disklabel, and kernel either on EFS partition, or in volume header.
  2. Linux, on the other hand, does not treat CD-ROM as partitionable device.
These two things together make it rather difficult to make Linux bootable CDs for SGI machines.


There are few ways this problem can be solved.

  1. Overlay ISO9660 filesystem with SGI disklabel with kernel and other needed things.
  2. Make kernel see CD-ROM as partitionable device, and create layout that ARCS will be happy with.
  3. Hybrid approach - create partitioned CD-ROM, then use initrd and loop device to offset into /dev/sr0 to the start of regular ISO9660 partition.
First approach requires some magic, but allows you to use any suitable kernel as-is. Second approach is rather straightforward, but needs kernel patch. Third approach requires some trickery in init scripts.


First solution was done by Andrew Clausen, and can be found on his page. I am not going to address this method here. Instead I'm going to describe second one. Maybe I will explore third option later - it seems like the best way to solve the problem, but I am too far down the way of doing it second way at this moment.


Preparing the kernel

  1. Get the sources from CVS
  2. Apply the patch to make Linux treat SCSI CD drive as disk, not as CD-ROM. This allows you to treat it as partitionable device, and mount your root partition on it later on. Rumour has it that latest 2.6 kernels support partitioned IDE CDs out of the box now.
  3. Configure kernel for platform you want. Make sure you enable SCSI disk support, support for your SCSI controller, and disable SCSI CD-ROM support. I didn't try to leave it enabled with the patch above, but suspect that disk driver will not be happy.
  4. Build your kernel (make vmlinux, or make vmlinux.64)

Voila - your kernel is ready.

Preparing your CD image

Now for the fun part.

  1. Create empty image file dd if=/dev/zero of=SGI.img bs=1M count=650
  2. Create SGI disklabel and partitioning in this image using parted. Unfortunately parted doesn't allow you to specify partition number, as you create partitions, and volhdr has to be #9 for dvhtool to work. Probably that is also what PROM expects. Thus, you'll have to create 8 small "primary" partitions, then create "extended" partition that will become your volume header, then delete all your primaries, resize volume header to include 0th sector, and only then create your data partition.
    parted ./SGI.img
    mklabel dvh
    mkpart            <-------- This has to be repeated 8 times
        Type: primary
        Start: 1
        End: 1
        Type: extended
        Start: 1
        End: 100
    rm 1
    rm 8
    resize 9
        Start: 0
        End: 100
        Type: primary
        File System: [ext2]
  3. Use fdisk to change data partition type from "raw" to Linux
  4. Now find where exactly your data partition landed. For that you'll need to know exact geometry of this CD seen by Linux at run time. I do not know how exactly that is determined, so I just had do make a coaster. I booted O2, put the partitioned CD in, run fdisk, and got following:
    o2 root # fdisk /dev/sdb                                                                                        
    Note: sector size is 2048 (not 512)                                                                             
    Command (m for help): p                                                                                         
    Disk /dev/sdb (SGI disk label): 20 heads, 61 sectors, 251 cylinders
    Units = cylinders of 1220 * 512 bytes
    ----- partitions -----
    Pt#     Device  Info     Start       End   Sectors  Id  System
     2:  /dev/sdb1  boot       168      1007   1023744  83  Linux native
     9:  /dev/sdb2               0       167    204928   0  SGI volhdr
    11:  /dev/sdb3               0      1007   1228800   6  SGI volume
    ----- Bootinfo -----
    ----- Directory Entries -----
    That is with 600M image. Placing IRIX install CD gave different numbers. Again - don't ask me why.
    If you use precisely 650M image you will probably get away with these values. Also, you need to ensure your partitions land on 2048 sector boundary (not just 512).
  5. Bind that partition to loopback device: losetup -o $((168*1220*512)) /dev/loop0 SGI.img
    As you have guessed, 168 - start of data partition 1220*512 - cylinder size as reported by fdisk
    Later note: seems it doesn't matter. Your partitions will land in the same place if properly aligned. Need to investigate more.
  6. Make filesystem on your partition: mke2fs -b 4096 -i 4096 -vm0 -L CDBOOT /dev/loop0
    Instead you may create ISO-9660 filesystem in there:
    mkisofs -o /dev/loop0 -lLR .
    If you can figure out how to make this work with other file systems, let me know (mkfs.xfs docs right now explicitly say only supported sector size is 512).
  7. (unneeded if you used mkisofs) Mount it: mount /dev/loop0 /mnt/SGIimage
  8. (unneeded if you used mkisofs) Copy everything you need on root partition there
  9. (unneeded if you used mkisofs) Unmount
  10. Detach from loop: losetup -d /dev/loop0
  11. Put your kernel into volume header of this image: dvhtool -d SGI.img --unix-to-vh /usr/src/linux-mips/vmlinux.64 linux.64
  12. (Optional) Put arcboot into volume header as well. See below for more info on making CDs that can actually be used for starting install by hitting "2" in PROM monitor (or "Install System Software" button, if user is on graphics system).
And this is it - your image is ready. Now just burn it with your favorite burning program.

Booting from your CD

  1. Go into PROM monitor
  2. boot -f dks(0,4,8)/linux.64 root=/dev/sdb1 ro

Install CDs for SGI machines

I discovered while playing with my O2 that when When you hit "Install System Software" (ISS from now on ;-), firmware sets parameter (not environment variable) OSLoadOptions to "mini" and runs sashARCS from chosen device volume header(CD-ROM). Nothing else special. I still haven't figured out what exactly is relationship between miniroot and PROM is, but I suspect that it is sashARCS that loads miniroot, not PROM itself, so we probably don't have to worry about it at all. What we do have to worry about however, is loading correct kernel. To that end I modified arcboot to try to load <label><arch><CPU>, if that fails, <label><arch>, and only then just <label>. <arch> is ip22/ip27/ip32, etc. (note lower case). CPU is r5k, r10k, and more will probably be added. For now R10000 and R12000 are both r10k, as they would use same kernel. Maybe it is better lo leave it alone, though - it's more flexible to add two entries in arcboot.conf. I also modified arcboot to try to infer config partition from device where it was booted from (rather then from OSLoadPartition) first. Modified version will go to OSLoadPartition, only if that fails. OTOH, for installation purposes, it would probably be easier to forget about OSLoadPartition alltogether.


Finally, to reward you for reading all the way through, here is a script that I made that does all of above.


Authoright © Total Knowledge: 1999-2013