ChorusOS 5.0 System Administrator's Guide

Chapter 5 Setting Up File Systems on the Target

This chapter explains how to set up file systems on devices physically attached to the target system, such as Flash memory, IDE disks, RAM disks and SCSI disks. If your target is an NFS client only (all its files are physically located on another system such as the host), you do not need to read this chapter.

Before you can perform the procedures in this chapter, you must first configure the system image. See "Configuration Options" and Chapter 4, Configuring the System Image with File System Support for details.

You must also boot the new system image on the target, and mount the root file system where many of the useful actors reside. This usually involves mounting a file system located on the host workstation where you built the system image. See "Mounting an NFS File System" for details.

Setting up file systems on the target involves:

  1. Preparing the media on which you will use file systems.

    If the media used is flash memory, you must first format(1M) the flash device.

    You must label the media using the disklabel(1M) utility, which writes partition information onto the media based on entries in the disktab(4CC) file.

  2. Creating file systems on the media.

    The newfs(1M) and newfs_msdos(1M) utilities let you create an MS-DOS file system.

    The utility lets you create a UFS file system.

  3. Checking file system integrity.

    The fsck_msdos(1M)utility lets you check an MS-DOS file system.

    Thefsck(1M) utility lets you check a UFS file system.

Formatting a Flash Memory Device

You must format flash memory before you can label it. If your target does not have flash memory, you do not need to read this section.


Caution - Caution -

The following procedure initializes the Flash memory device, erasing all existing data. Be sure to back up existing data on the device before proceeding.


Formatting a Flash Memory Device
  1. Make sure that you have configured your system image with the FLASH feature set to true:


    host% cd build_dir
    host% configurator -list features | grep FLASH
    FLASH bool 'true'
  2. Reboot the target system with a system image that supports Flash memory and includes the special files needed to access it.

  3. Format the Flash memory using the format(1M) command:


    host% rsh target format /dev/rflash0a
    

Labeling a Disk

This section describes how to label a disk using information in /etc/disktab and the disklabel utility.

Labeling consists of writing specific information, such as disk geometry in terms of cylinders, heads, sectors per track and partition overlays, at particular locations on the disk. Disk drivers use labeling information to access different areas of the disk, called partitions.

You can also use the fsck(1M) utility on PC/AT platforms to create 'slices' (DOS partition) if you want to share the disk with other operating systems. In this case disklabel partitions are created within those slices. See also fsck_dos(1M) and fsck_msdos(1M).

Setting Up Information About Disk Geometry

Information about disk geometry is found in /etc/disktab, which disklabel reads before writing a label to a drive. The ChorusOS operating system provides a sample /etc/disktab that contains several useful examples. The following key to the abbreviations used in /etc/disktab is included at the top of the file:

#
# Disk geometry and partition layout tables. 
# Key:
#
#   dt      controller type
#   ty      type of disk (fixed, removeable, simulated)
#   d[0-4]  drive-type-dependent parameters
#   ns      #sectors/track
#   nt      #tracks/cylinder
#   nc      #cylinders/disk
#   sc      #sectors/cylinder, ns*nt default
#   su      #sectors/unit, sc*nc default
#   se      sector size, DEV_BSIZE default
#   rm      rpm, 3600 default
#   sf      supports bad144-style bad sector forwarding
#   sk      sector skew per track, default 0
#   cs      sector skew per cylinder, default 0
#   hs      headswitch time, default 0
#   ts      one-cylinder seek time, default 0
#   il      sector interleave (n:1), 1 default
#   bs      boot block size, default BBSIZE
#   sb      superblock size, default SBSIZE
#   o[a-h]  partition offsets in sectors
#   p[a-h]  partition sizes in sectors
#   b[a-h]  partition block sizes in bytes
#   f[a-h]  partition fragment sizes in bytes
#   t[a-h]  partition types (file system, swap, etc)
#
# All partition sizes reserve space for bad sector tables.
# 5 cylinders are needed for maintenance including
# replacement sectors.
#
...

Entries in /etc/disktab consist of fields separated by colons (":") and follow the form:

label:option[=value|#value]...

Where label is a string identifier up to eight characters long with no whitespace, option is an option from the list of abbreviations above, and value is the value assigned to an option.

For detailed examples, see the root/etc/disktab file generated using make root in the build_dir directory where you build system images. Note that build_dir/root is normally the directory exported for use as the target root directory. See "Mounting an NFS File System" for details.

If you are unable to complete the disk geometry fields, boot the ChorusOS system image on the target system, and read the output concerning the disk driver displayed on the system console at boot time.

Using disklabel to Label a Disk

Once you have correctly specified disk information in /etc/disktab, you are ready to use disklabel.


Caution - Caution -

The following procedure initializes the local disk, erasing all existing data. Be sure to back up existing data before proceeding.


  1. Boot the target system with a system image that supports the hardware you want to label and that includes the special files needed to access that hardware.

  2. Update the disk label on the device, using disklabel as follows:


    host% rsh target disklabel -w -r device label name
    

    where device is an abbreviated form of the device name such as da0, label is the label found in /etc/disktab and name is an optional string identifier up to sixteen characters long with no whitespace.

  3. Check that the disk label is correctly updated, using disklabel as follows:


    host% rsh target disklabel -r device
    

    where device is an abbreviated form of the device name such as da0.

Another way of using disklabel is with a protofile. A protofile is a text file describing one single disk and has the same format as the output of a simple disklabel disk.

For instance, to create a single partition on a new disk, you can type the following :


rsh target disklabel device > root/tmp/device_proto  
rsh target disklabel -R -r device /tmp/device_proto         

If device is da0, for instance, this will create a single partition da0c that can be used with newfs:


rsh target newfs /dev/da0c

Of course, you can edit and modify the device_proto file between both of these operations to create additional partitions.

Creating a File System

This section explains how to create a file system on a disk. If you plan to use the disk partitions in raw mode and do not need a file system, you do not need to read this section.

Once the disk has been labelled, you can write a UFS or MS-DOS file system structure to any partition you have defined for the disk, except partition c.

Creating a UFS File System

    Create the file system using the newfs command as follows:


    host% rsh target newfs raw_device
    

    where raw_device is a raw mode special file indicating a partition such as /dev/rda0a.

Creating an MS-DOS File System

    Create the file system using the newfs_msdos command as follows:


    host% rsh target newfs_msdos raw_device
    

    where raw_device is a raw mode special file indicating a partition such as /dev/rhd0a.


Example 5-1 Creating a File System on a RAM Disk

You can pass extra parameters to newfs or newfs_msdos when creating a file system on a RAM disk in order to maximize available space. The following command could be used (on BSD type file systems only) to maximize space available on a 1 MB RAM disk:


host% rsh target newfs -o space -c 26 -m 0 /dev/rd0a


Note -

See "Activating a Swap Partition" for details on activating a swap partition.


Checking File System Integrity

This section explains how to check existing file systems for errors.


Note -

Before mounting a local file system with read-write access or as the root file system, and after any system crash, it is strongly recommended that you check the file systems you plan to mount.


Checking a UFS File System

    Check the file system using the fsck command as follows:


    host% rsh target fsck raw_device
    

    where raw_device is a raw mode special file indicating a partition such as /dev/rda0a.

Checking an MS-DOS File System

    Check the file system using the fsck command as follows:


    host% rsh target fsck_msdos raw_device
    

    where raw_device is a raw mode special file indicating a partition such as /dev/rhd0a.

If no errors are found, both fsck and fsck_msdos display information on the file system in use. In case of errors, both fsck and fsck_msdos attempt a recovery procedure, optionally requiring confirmation. If you want to run either command in non-interactive mode, use the -y option.