Adding a new workstation disk

Condition: You have a shiny new disk you want to hook up

  1. If this is an internal disk, prepare the file system for diskless operation by booting it off the network. See the separate procedure for this.

    If this is an external disk, you just need to go to single user mode.

  2. Make sure you are using an unassigned SCSI ID for the devices on the machine. SCSI IDs 5 and 6 are typically assigned to SCSI CD-ROMs or tapes. Use numbers in the range 0-4 for disks.

    The Sun default is to boot from the disk with SCSI ID 3, so if you are replacing your internal disk, life is simpler if you do this. If you don't, you will have to change the boot PROM parameters to arrange the system to boot from an alternate SCSI device. See "man eeprom" for details.

    Assign an appropriate ID, either by switching the thumbwheel on the back of the housing of an external disk, or by changing the jumper blocks to assign the desired SCSI ID on an internal disk.

  3. Hook your disk up to the system and power it on. Before rebooting, use the PROM monitor to issue a "probe-scsi" command (available in the new PROM monitor mode only). This will check to make sure that you didn't assign duplicate SCSI ID numbers. (You can also use it to figure out what SCSI IDs are assigned, too). The field labeled "lun" is the SCSI ID.
  4. Go to single user mode by booting up the system single-user or by booting over the network. To boot from a disk, say
    b sd(0,3,0)vmunix -s               (with the old prom monitor)
    boot disk vmunix -s                (with the old prom monitor)
    and to boot from the network, say
    b le() vmunix -s                   (with the old prom monitor)
    boot net vmunix -s                 (with the old prom monitor)
  5. You now should be running as super-user in a single user system. First check out your new disk to see that it responds to basic SCSI commands:
    /usr/etc/scsiinfo -p
    You should see the device listed in the output, much like "probe-scsi" did earlier. Next, try to get disk geometry information about the disk:
    /usr/etc/scsiinfo -r /dev/sdXc
    where the X gets replaced by 0, 1, 2, 3, or 4 as is appropriate for the SCSI ID. Put this output into a file for later use with the format program later on by saying,
    /usr/etc/scsiinfo -F /dev/sdXc > /tmp/disk.dat
    which puts the info into a temporary file.
  6. Run /usr/etc/format to format the disk. You need to do two things: 1) erase and format the disk; 2) define a partition table for the disk. The first is a hardware operation. The second puts information onto the disk for the Unix file system to use.

    To erase and format the disk, you need to know about the device geometry (e.g. how big it is, how many heads it has, how many platters on the spindle, etc.) and get this information into the table of formatting information that format uses. If format doesn't know what the disk is, then interrupt format and add a new entry to the /etc/format.dat file. With your favorite editor, edit /etc/format.dat and include the information in /tmp/disk.dat. There are two parts: 1) the geometry information; 2) a default partition table. These get put into two separate parts of the file (geometry comes first). See the file for information. Then put the partition info towards the end.

    After you have /etc/format.dat built right, now format the disk. After the initial device selection (make sure you select the right disk - you will erase whatever you select), type

    After a wait for a variable amount of time, the disk will be formatted.

    The next step will be to build up a partition table.

  7. Run /usr/etc/format again to build a partition table.

    Unix views a disk as having a bunch of individual little disks in it. This partitioning gets defined by the partition table, which is put into the label on a disk. So you must first build a partition table, then write the label (with the partition table) to the disk.

    Use the "partition" command in format to define a partition table. Partitions are named a through h, corresponding to the device names sdXa-sdXh. Partitions have special meanings, so certain conventions apply. At Bristol Geology:

        a        is the root partition
        b        is swap (not used by the file system, but by the Unix kernel)
        c        is the whole disk (only used if the disk isn't a boot disk, and
    		 then this is the *only* partition used, otherwise not used
    		 by the file system)
        d-f      local storage: /export, /ld0, /ld1, etc.
        g        is the /usr partition
        h        is the /tmp partition
    The partitions you need to define are (a), (b), (g), (h), and possibly (b) and (d)-(f).

    Making partitions the right size is something that experience gives. You are trying to make the partition big enough to hold the required information, yet small enough not to waste disk space. The best tactic is to go to a similarly-configured system and copy the partition table from it. Use these general guidelines:

    a - / (root)
    usually small, 10 megabytes or so
    b - swap
    you want this about 4-8 times the available memory size on the workstation, or about 240 Mb.
    g - /usr
    this contains the system binaries which are presently about 200 Mb. Make this about 25% larger for system expansion purposes - programs only get bigger, after all.
    h - /tmp
    this contains temporary files. You generally want about 50-100 Mb of temporary space.

    Partitions must begin on cylinder boundaries. Use the syntax 'N//' with format to indicate an integral number of cylinders (in this case N). Round up whenever necessary. Get the number of megabytes per cylinder by dividing the number of (512 byte) blocks per cylinder by 2048 and then figuring out how many cylinders are needed.

    Watch out that you don't overlap cylinders. You have to give a starting cylinder and ending cylinder for each partition. The only one that should overlap is the c partition, which describes the whole disk (begins with 0, ends with the number of cylinders on the disk).

    After defining your partition table, print it out ("print"), verify it, and then write the label with the "label" command. Then quit format.

  8. Build new file systems in each partition. Use the newfs command to do this. About the only thing that newfs can't figure out is how fast the disk is spinning (get this info from scsiinfo) and use the -r option to specify it. Suppose you want to build file systems on the a, g and h partitions. If your disk spins at 4500 rpm, you would say,
        newfs -r 4500 sd0a
        newfs -r 4500 sd0g
        newfs -r 4500 sd0h
    Note you don't have to build a file system on the swap partition because the kernel just does low-level disk i/o.

    After using newfs, each partition will have a pristine Unix file system on it.

  9. Refresh the data (if any) in the partitions.

    You might need to do this if you are replacing an internal system disk with boot information and system information or data on it. Otherwise, skip it.

    If you need to build a new system on the disk, copy a system to it partition-by-partition. Do this by taking one from a similar system, e.g. the one called "apatite." For each partition (a - / - and g - /usr), do the following

        mount /dev/sdXa /mnt
        cd /mnt
        rsh apatite 'dump 0f - /dev/rsdYa | restore rf -
        umount /mnt
    where "X" and "Y" represent the SCSI disk name you want to reconstruct locally (X) and on the foreign donor system (Y).

    You need to do this for each of the partitions you want to copy. Ones like swap (b) skip, and ones like h (/tmp) ignore - you want it blank anyway.

  10. Reinstall boot blocks (if needed) in the root partition.

    You only need to do this if you are building a disk you will be booting from. Remember, you got here by booting the system over the network, so you need to be able to boot from the new disk under normal circumstances.

    First mount the root partition on /mnt and prepare to install the boot program on it:

        mount /dev/sdXa /mnt
        cd /usr/kvm/mdec
    Note that you are going to put a boot program on the disk mounted on /mnt, but the code you are going to run is on your running system, not the disk. Use installboot to put the boot program on the new disk:
        ./installboot -vlt /mnt/boot bootsd /dev/rsdXa
    The /mnt/boot indicates you're putting the boot program, bootsd, in the file called /mnt/boot on /dev/rsdXa. Don't be puzzled - /mnt/boot will be /boot when that disk is booted from, because when you boot it your boot detice will be known as /. It is only called /mnt/boot here when you're using the system you booted over the network.
  11. Change the system name (if needed) in the root partition.

    You only need to do this if you are building a disk you will be booting from. Remember, you got here by booting the system over the network, so you need to be able to boot from the new disk under normal circumstances. You also copied the root file system from another system, which means that it will wake up with that other system's identity - this will be catastrophic.

    First mount the root partition on /mnt:

        mount /dev/sdXa /mnt
        cd /mnt/etc
    Now edit the file "hostname.le0" which contains the system name, and make this the appropriate new name for the system to be booted. Rewrite this file.
  12. Unmount the disk, halt the system, and reboot and apply the finishing touches:
        cd /
        umount /mnt
        boot disk vmunix -s              (new prom monitor)
        b sd(0,3,0)vmunix -s             (old prom monitor)

    When you come up in single-user mode, edit /etc/fstab and make sure the disks are mounted like they should be.