Author: Jyrki Kuoppala (jkp@cs.hut.fi)
Last modified: Tue Sep  5 23:35:59 1989

This is a replacement for the Sony command /etc/setdinfo written by
Hannu Aronsson of Helsinki University of Technology.  A replacement
was needed because setdinfo has the disktypes hardcoded in it; also,
it doesn't have documentation (a manual page).

Nsetdinfo is used to write the partition table from /etc/disktab to a
hard disk.  It should be used whenever the disk is reformatted or the
newfs or mkfs is run on the a or c partitions of the disk because mkfs
destroys the first block of the disk.

At boot time, the Sony kernel (NEWS-OS version 3.2) wants to recognize
all the disks which are attached to the SCSI bus.  If it doesn't
recognize them, those can't be used.  This is silly, because even if
the disk isn't recognized it can be used if it has valid partition
table information on it.  We have succesfully used the following
kernel patch to be able to use the disks even if Sony has never heard
of them:

	batman.hut.fi# adb -w vmunix
	hdslave+3e?i
	_hdslave+3e:    bsr.b   _hdslave+86
	_hdslave+40:    addq.l  #8,a7
	_hdslave+42:    move.l  d0,(fffc,a6)
	_hdslave+46:    blt.b   _hdslave+64
	hdslave+46?w 0x4e71
	_hdslave+46:	6d1c	=	4e71
	?i
	_hdslave+46:	nop

This changes the code

  if ((getdiskret = getdisk (disk, a5)) >= 0) {
    retval = 1;
    disk->g = getdiskret;
    disk->c = hdrpartinfo (disk);
  } else
    disk->c = -1;
to
    
  getdiskret = getdisk (disk, a5);
  retval = 1;
  disk->g = getdiskret;
  disk->c = hdrpartinfo (disk);

or something like it (I'm guessing, since we don't have the source so
I had the use the RTFB method (read the friendly binary).

Be careful about the patch, it might or might not work for you.  We
can't take any responsibility, the fact that it worked for us may not
mean that it works for you even if the phase of the moon is right.

When you use a disk not recognized by the Sony kernel, do the
low-level format as usually (ie. with the standalone format program).
After that, edit /etc/disktab to have a suitable entry for the disk
with the partition tables you want to use.  To first get the kernel to
access the disk, you should copy the partition table there.  This is a
bit tricky, because you must do it with the ROM monitor and use a
temporary floppy.

One way to do this is to something like this:

Take a scratch floppy.  Put a working hard disk's first block to the
floppy with somthing like:

dd if=/dev/rhd0c of=/dev/fh0 count=1

This needs to be done to get the right magic cookies in the start of
the disk.  We don't know if the magic cookies are needed, but let's
play it safe.  After this, set the partititions to the floppy disk
with somehing like:

nsetdinfo /dev/fh0 harddisktype

This sets the partition table for the floppy disk so after all is done
it's probably wise to reformat the floppy.

After this, you need to go to the ROM monitor to copy the partition
table from the floppy to the hard disk.  If you're not 110% sure of
what you're doing, take a backup of your internal hard disk and others
you may have connected and disconnect them.  In the ROM monitor, the
following copies the partition table to the hard disk (let's assume
it's unit number 1).

cp fh 0:200 mm 10000
cp mm 10000:200 hd (1) 0

After this, boot the machine.  At boot time, there should show
something like this:

Sep  3 17:29:06 joker vmunix: hc1 at iop addr 1 intr 1
Sep  3 17:29:06 joker vmunix: hd1 at hc1 slave 0

If everything's weel, you can use the hard disk now.  Try ie.

dd if=/dev/rhd1c of=/dev/null count=500

You probably should also rerun nsetdinfo on the hard disk just to be
sure.  For example:

nsetdinfo hd1 hd586

assumbing you have the type hd586 described in /etc/disktab.

By the way, we don't have disk drives not recognized by Sony any more,
so this procedure is untested (I mean, we did all of it sometime but
this document was written afterwards so the document might have some
bugs in it).

Have fun and remember to take backups !  Please also report bugs and
improvents to jkp@cs.hut.fi and/or haa@hutcs.hut.fi.
