Purpose
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.
Problem
- 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.
- 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.
Choices
There are few ways this problem can be solved.
- Overlay ISO9660 filesystem with SGI disklabel with kernel
and other needed things.
- Make kernel see CD-ROM as partitionable device, and create
layout that ARCS will be happy with.
- 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.
Solutions
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.
Prerequisites
- GNU parted
- fdisk capable of dealing with SGI disklabels.
- dvhtool.
Can be also obtained from linux-mips.org CVS
Preparing the kernel
- Get the sources from linux-mips.org CVS
- 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.
-
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.
- Build your kernel (make vmlinux, or make vmlinux.64)
Voila - your kernel is ready.
Preparing your CD image
Now for the fun part.
- Create empty image file
dd if=/dev/zero of=SGI.img bs=1M count=650
- 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
mkpart
Type: extended
Start: 1
End: 100
rm 1
....
rm 8
resize 9
Start: 0
End: 100
mkpart
Type: primary
File System: [ext2]
Start:100
End:650
- Use fdisk to change data partition type from "raw" to Linux
- 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).
- 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 propperly aligned. Need to investigate more.
- 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).
- (unneded if you used mkisofs) Mount it:
mount /dev/loop0 /mnt/SGIimage
- (unneded if you used mkisofs) Copy everything
you need on root partition there
- (unneded if you used mkisofs) Unmount
- Detach from loop:
losetup -d /dev/loop0
- Put your kernel into volume header of this image:
dvhtool -d SGI.img --unix-to-vh /usr/src/linux-mips/vmlinux.64 linux.64
- (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
- Go into PROM monitor
boot -f dks(0,4,8)/linux.64 root=/dev/sdb1 ro
Install CDs for SGI machines
I discovered while plaing 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.
Script
Finally, to reward you for reading all the way through, here is
a script that I made that does
all of above.
TODO
- Figure out how to hook it all up together with ArcBoot
- Make hitting "Install System Software" in PROM
work with Linux like with IRIX.