5   Examples

5.1   Adding a SCSI Disk to an x86-440bx Machine

The following section described how to add a SCSI controller and a single empty SCSI disk to the Enterprise machine. Adding a disk to other simulated machines is done in a similar way.

  1. Add SCSI Controller and Disk Components

    First create a file in [workspace]/targets/x86-440bx/ called enterprise-disk.simics. In this file add the following contents:

    script-branch {
        wait-for-variable machine_defined
        local $sym = (create-pci-sym53c810)
        local $scsi_bus = (create-std-scsi-bus)
        local $scsi_disk = (create-std-scsi-disk scsi_id = 0 size = 4256972800)
        $nb.connect pci-slot2 $sym
        $scsi_bus.connect $sym
        $scsi_bus.connect $scsi_disk
    run-command-file enterprise-common.simics

    This will run a script branch that first waits for the machine to be defined by the machine configuration script (included from enterprise-common.simics). Once the $machine_defined variable has triggered, a SCSI controller, SCSI bus and a SCSI disk component representing a 4GB disk, will be created. On the last lines the controller is connected to the north-bridge (the $nb variable) in PCI slot 2, and to the SCSI bus. The disk is also connected to the SCSI bus.

    The SCSI id must be specified for attached SCSI devices, and we choose to use id 0 for the disk. We do not have to specify an id for the sym53c810 controller since it always uses id 7.

  2. Prepare the Boot

    Start Simics, but do not start the simulation. Before booting, it is a good idea to enable real-time mode in Simics by issuing the command enable-real-time-mode. The reason for this is that the Linux hardware configurator program (kudzu) will detect the SCSI controller and ask if it should be configured. Kudzu then waits for 30 seconds for input, but this wait will run much faster than in reality since Simics optimizes the idle loop.

    When kudzu has detected the SCSI controller, choose the option of configuring it. After this point the real-time mode can be disabled again in Simics. If the kudzu times out before it receives any user input, it can be run from the Linux command line manually once the machine has booted. (/sbin/kudzu).

  3. Configure Linux

    Once Linux has booted, and detected the SCSI controller, run fdisk to create a partition on the new disk. At the menu, select n to create a new partition, then p for primary partition and 1 for the first partition.

    # fdisk /dev/sda
    ncr53c8xx: setting PCI_COMMAND_MASTER...(fix-up)
    ncr53c8xx: changing PCI_LATENCY_TIMER from 0 to 32.
      Vendor: Vtech     Model: Turbo_Disk(tm)    Rev: 0001
      Type:   Direct-Access                      ANSI SCSI revision: 02
    Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
    SCSI device sda: 8314400 512-byte hdwr sectors (4257 MB)
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF diskla
    Building a new DOS disklabel. Changes will remain in memory only,
    until you decide to write them. After that, of course, the previous
    content won't be recoverable. 
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    Partition number (1-4): 1
    Next use the default options for cylinder, by simply pressing return on each line. Finally select the w command to write the partition table to the new disk.
    First cylinder (1-1023, default 1):
    Using default value 1 
    Last cylinder or +size or +sizeM or +sizeK (1-1023, default 1023):
    Using default value 1023
    Command (m for help): w
    The partition table has been altered!
    Calling ioctl() to re-read partition table.
    SCSI device sda: 8314400 512-byte hdwr sectors (4257 MB)
    SCSI device sda: 8314400 512-byte hdwr sectors (4257 MB)
    Syncing disks.

    A file system now has to be created on the new partition using the mkfs command. At the same time, also add a mount point, and an entry in the file-system table. This way Linux will automatically mount the disk on the next boot.

    # mkfs /dev/sda1
    <output from mkfs here>
    # mkdir /disk
    # cat >> /etc/fstab
    /dev/sda1       /disk       ext2    defaults  1 2
    # 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 Linux to shut down, stop the simulation and save the all modifications using the save-persistent-state command.
    simics> save-persistent-state new-disk1.state
    Now exit Simics, and restart the enterprise-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/.