5   Examples

5.1   Adding a new Disk to a Serengeti Machine

  1. Add a SCSI Disk Component

    First create a file in [workspace]/targets/serengeti/ called abisko-disk.simics. In this file add the following contents:

    script-branch {
        wait-for-variable machine_defined
        local $disk = (create-std-scsi-disk size = 4256972800)
        connect-components $scsi_bus scsi-slot-2 $disk scsi-bus
    run-command-file abisko-common.simics

    This will run a script branch that first waits for the machine to be defined by the machine configuration script (included from abisko-common.simics). Once the $machine_defined variable has triggered, a SCSI disk component, representing a 4GB disk, will be created that on the following line is connected to the SCSI bus component on connector scsi-slot-2.

  2. Prepare the Boot

    Start Simics, but do not start the simulation. Before booting, the disk needs an empty partition table for Solaris to recognize the disk. The partition table must contain a geometry that matches the size of the disk. Also add a large partition that covers the full disk.

    simics> sd1.create-sun-vtoc-header 5470 19 80
    simics> sd1.create-sun-vtoc-partition number = 0 start-block = 0 num-blocks = ((5470 - 2) * 19 * 80) flag = RW tag = root

    Note: Configuring partitions can also be done using the Solaris format command once the simulated machine has booted.

    The partition table should now look something like:

    Partition Table:
    Number   Tag             Flag                 Start        End       Size
      0      2 (root)        0 (RW)                   0    8311359    8311360
      2      5 (backup)      1 (unmountable)          0    8311359    8311360
    Before booting, tell Solaris that new hardware has been added, by adding the -r argument to the OBP boot command variable:
    simics> system_cmp0.set-prom-env boot-command "boot disk -rv"
  3. Configure Solaris

    Start the simulation and wait for the simulated machine to reach the prompt. A file system has to be created on the new disk, this is done using the Solaris newfs command. At the same time, also add a mount point, and an entry in the file-system table. This way Solaris will automatically mount the disk on the next boot.

    # newfs /dev/dsk/c0t2d0s0
    newfs: construct a new file system /dev/rdsk/c0t2d0s0: (y/n)? y
    <output from newfs here>
    # mkdir /disk
    # cat >> /etc/vfstab
    /dev/dsk/c0t2d0s0    /dev/rdsk/c0t2d0s0   /disk ufs  2    yes    -
    # mount /disk
    The disk can now be accessed as /disk/ in the file-system.
  4. Save the Changes

    To save the changes to the new disk, shut down the simulated machine and save the modifications. Issue:

    # init 0
    then wait for Solaris to shut down, stop the simulation and save the all modifications using the save-persistent-state command. But first remove -r from the boot command, or it will be for the next boot as well, making the boot slower.
    simics> system_cmp0.set-prom-env boot-command "boot disk -v"
    simics> save-persistent-state new-disk1.state
    Now exit Simics, and restart the abisko-disk.simics script. Before running, load the disk modifications saved earlier:
    simics> load-persistent-state new-disk1.state
    Now boot the machine again. The new disk will be mounted as /disk/.