ChorusOS 5.0 System Administrator's Guide

Chapter 8 Further File System Administration Examples

This chapter builds on the file system administration examples provided in the previous chapters and offers a series of progressive, detailed worked examples showing you how to

Making a RAM Disk the Main System Disk

You can use RAM to house the root file system, as shown by this example. It is assumed that you have already been able to mount a root directory through NFS. See "Mounting a Root File System over NFS" for details.

Before you get started, you must add RAM disk support to your system image. The following commands add that support, build the system image, copy the image to the download directory and reboot the ChorusOS system running on an x86 target:


$ cd build_dir
$ configurator -c conf/ChorusOS.xml -set RAM_DISK=true
$ configurator -c conf/ChorusOS.xml -set iom.ramdisk0.size=0x1600000
$ configurator -c conf/ChorusOS.xml -set iom.ramdisk.sizeMax=0x1600000
$ make chorus
$ cp chorus.bmon /tftpboot
$ rsh target reboot

In order to use RAM to house the root file system, you must first label part of the available space using disklabel(1M). disklabel uses entries in disktab(4CC) to label the disk. The following disktab entry serves to label a 4 megabyte area of RAM as a disk:

# This label can be used for a 4 megabyte RAM disk. The corresponding
# newfs command to be used with this RAM disk is:
# rsh target newfs -o space -c 26 -m 0 /dev/rd0a

rd4MegBSD:\
	:ns#32:nt#1:nc#256 \
	:pa#8192:oa#0:ta=4.2BSD:ba#8192:fa#8192 \
	:pc#8192:oc#0:tc=unused:

The default system initialization file, sysadm.ini(4CC), creates special files to access the RAM, so you probably do not need to create them yourself. The entries to create special files may appear as follows in sysadm.ini:

# Create special files for RAM disk
mknod /dev/rrd0a c 13 0
mknod /dev/rrd0b c 13 1
mknod /dev/rrd0c c 13 2
mknod /dev/rd0a  b 13 0
mknod /dev/rd0b  b 13 1
mknod /dev/rd0c  b 13 2

The above example creates both raw and block mode special files for two user-accessible partitions, a and b, and one partition, c, for use by the system only.

Assuming the special files exist, you can proceed to label the disk and so forth. The following commands label the disk, read the label, create a file system on the disk and check the file system:


$ rsh target disklabel -w -r rd0 rd4MegBSD
$ rsh target disklabel -r rd0
# /dev/rrd0c:
type: unknown
disk: rd16Meg
label: 
flags:
bytes/sector: 512
sectors/track: 4
tracks/cylinder: 4
sectors/cylinder: 16
cylinders: 32768
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0		# milliseconds
track-to-track seek: 0	# milliseconds
drivedata: 0 

3 partitions:
#      size  offset fstype   [fsize bsize   cpg]
a:    32768    0    4.2BSD      0     0     0 	# (Cyl.    0 - 2047)
c:    32768    0    unused      0     0       	# (Cyl.    0 - 2047)
$ rsh target newfs /dev/rd0a
/dev/rrd0a:	32768 sectors in 8 cylinders of 1 tracks, 4096 sectors
	16MB in 1 cyl groups (16 c/g, 32MB/g, 7680 i/g)
super-block backups (for fsck -b #) at:
 32,
$ rsh target fsck -y /dev/rd0a
** /dev/rrd0a
** Last Mounted on 
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
1 files, 1 used, 15390 free (14 frags, 1922 blocks, 0.1% fragmentation)

Once you have checked the new file system and it is ready to use, mount it in the current file system hierarchy. As the current root file system is located on the host workstation, create the mount point on the host and then mount the RAM file system there:


$ cd target_root_dir
$ mkdir ram
$ rsh target mount -t ufs /dev/rd0a /ram
/dev/rd0a on /ram

Next, populate the RAM file system with the contents of all file systems except the /dev, /image, /tmp and /ram directories. Create mount points for the /dev, /image and /tmp file systems:


$ rsh target  cp -R bin etc lib ram/
$ rsh target  mkdir /ram/dev
$ rsh target  mkdir /ram/image
$ rsh target  mkdir /ram/tmp

The RAM file system, mounted under the /ram directory, now contains everything needed to serve as the main system disk. Take advantage of the fact that the mount command is built into the C_INIT system actor.

Unmount the root file system.

The following commands unmount the root file system on the target and remount the RAM file system in its place:


$ rsh target umount /ram
$ rsh target umount /
$ rsh target mount -t ufs /dev/rd0a /
$ rsh target fsck /dev/rrd0a
$ rsh target mount -t ufs -o update /dev/rd0a /

The target is now independent of the host, using the RAM disk as the main disk:


$ rsh target ls
bin             dev             etc             image           lib
tmp

Note that the ls actor used above is located in the RAM disk file system.

The following script is meant to run on the host workstation (or other system) and summarizes the above scenario:

#! /sh

#
# Reboot the target and give it some time to come up.
#
rsh target reboot
sleep 60
# 
# While the host 'sleeps', the target downloads the system image, and
# executes system initialization commands in sysadm.ini, mounting
# the root file system through NFS.
#

#
# Label the RAM disk, then create the file system and check it.
#
rsh target  disklabel -w -r rd0 rd16Meg MyRamDisk
rsh target  newfs /dev/rrd0a
rsh target  fsck -y /dev/rrd0a

#
# Mount the RAM file system and populate it with the rest of the root
# directory.
#
rsh target mount -t ufs /dev/rd0a /ram
rsh target cp -R bin etc lib ram/
rsh target mkdir /ram/dev
rsh target mkdir /ram/image
rsh target mkdir /ram/tmp

#
# Unmount everything, then mount the RAM file system at the root.
#
rsh target umount /ram
rsh target umount /
rsh target mount -t ufs /dev/rd0a /
rsh target fsck /dev/rrd0a
rsh target mount -t ufs -o update /dev/rd0a /

After adapting the above script for your environment, run it to make your ChorusOS target self-sufficient.

Creating a File System on a Target System Hard Disk

If your ChorusOS system has a hard disk drive that you want to use to support a local file system, you can use the ChorusOS system utilities to prepare the disk, and create and populate a local file system. It is assumed that you have already been able to mount a root directory through NFS. See "Mounting a Root File System over NFS" for details. It is also assumed that no valuable data has been written to the disk. If you have important data on the hard disk, you must back it up before trying this example.

Before you can prepare the disk, you must be able to access it. Set the appropriate feature or features, depending on whether the hard disk is an IDE or SCSI disk and depending on what file system type you plan to use (see Step 2 for details), build the new system image that supports a hard disk and reboot the target system with the new system image. For example, if you are using TFTP to download onto a target with an IDE disk, then you might do so as follows:


$ cd build_dir
$ configurator -c conf/ChorusOS.xml -set IDE_DISK=true
$ configurator -c conf/ChorusOS.xml -set UFS=true
$ make chorus
$ cp chorus.bmon /tftpboot
$ rsh target reboot

The default sysadm.ini(4CC) system initialization file contains commands that create special files for both IDE and SCSI disks, so you probably do not need to create any special files at this point.

In order to label the disk, you first need an appropriate entry in disktab(4CC). The following example disktab fragment could be used with an ST34311A IDE disk to create two partitions, one small and one large:

ST34311A:\
        :dt=ST506:ty=fixed:se#512:nt#15:ns#63:nc#8944:sf \
        :pa#60480:oa#0:ta=4.4LFS: \
        :pb#8391600:ob#60480:tb=4.4LFS: \
        :pc#8452080:oc#0:tc=unused:

Caution - Caution -

The following step in this example initializes the disk, erasing all existing data. Be sure to back up existing data on the disk before proceeding.


Once the disktab file contains the entry describing the disk geometry, you can proceed to label the disk. For example:


$ rsh target disklabel -w -r hd0 ST34311A

After the disk is labelled, you can create file systems on the disk partitions:


$ rsh target newfs /dev/hd0a
$ rsh target newfs /dev/hd0b

Finally, before using the file systems, you should check them:


$ rsh target fsck -y /dev/hd0a
$ rsh target fsck -y /dev/hd0b

After you have checked the file systems you created, you can mount them into your existing file system hierarchy and use them.

Setting Up an NFS Server on the Target System

If your ChorusOS system has a local file system, you may want to export part of it through NFS to share files with other systems on the network. For the following example, it is assumed that you want to export file systems and that you have already been able to create a local file system in RAM. See "Making a RAM Disk the Main System Disk" for details.

Before you can use the ChorusOS system as an NFS server, you must set the appropriate features and tunables. For example, if you are using TFTP to download onto the target, then you can do this:


$ cd build_dir
$ configurator -c conf/ChorusOS.xml -set NFS_CLIENT=true
$ configurator -c conf/ChorusOS.xml -set UFS=true
$ configurator -c conf/ChorusOS.xml -set NFS_SERVER=true
$ configurator -c conf/ChorusOS.xml -set iom.kmemsize=0x80000
$ configurator -c conf/ChorusOS.xml -set iom.nbuf=8
$ make chorus
$ cp chorus.bmon /tftpboot
$ rsh target reboot

Note that you can export only UFS file systems through NFS.

Once the ChorusOS system has support for NFS, you must configure at least /etc/exports for the target system:

#
# Export everything to everyone.
#
/ 	-alldirs -maproot=0:1

Note -

The directory you export must be local to the ChorusOS system. From this point on, it is assumed that you have already populated a local device file system. Again, see "Making a RAM Disk the Main System Disk" for an example of how to prepare a local RAM disk file system for use as the root file system.


The following commands enable name services, portmapping, the mountd daemon and three NFS servers for UDP and TCP clients. The name service is optional, but useful. The other services are required to provide NFS services.


$ rsh target  inetNShost&
$ rsh target  sbin/rpcbind&
$ rsh target  sbin/mountd&
$ rsh target  sbin/nfsd -ut -n 3&

At this point, you can mount the target system root directory on another system, such as the host workstation or another target. The following commands mount the file system on the host workstation:


$ su
Password: root_password
# mount target:/ /mnt

You may also choose to mount the exported ChorusOS system directories from other target systems, for example.

Creating and Activating a Swap Partition

The following example sets up a swap partition on a local IDE disk. This example builds on "Activating a Swap Partition". It is assumed that you have already successfully completed "Creating a File System on a Target System Hard Disk" and that your system is properly configured to support UFS file systems on the hard disk. It is also assumed that no valuable data has been written to the disk. If you have important data on the hard disk, you must back it up before trying this example.

Before you can activate swap on the disk, you must configure the system image to support the virtual memory. Following "Creating a File System on a Target System Hard Disk", you can do so as follows:


$ cd build_dir
$ configurator -c conf/ChorusOS.xml -set ON_DEMAND_PAGING=true
$ configurator -c conf/ChorusOS.xml -set VIRTUAL_ADDRESS_SPACE=true
$ configurator -c conf/ChorusOS.xml -set FS_MAPPER=true
$ make chorus
$ cp chorus.bmon /tftpboot
$ rsh target reboot

For the purposes of this example, it is assumed that the hard disk is bare and that you need to start by labeling the disk. In order to label the disk, you must first create an appropriate entry in disktab(4CC). The following example disktab fragment can be used with an ST34311A IDE disk to create two partitions, one small swap partition and one large partition to house a UFS file system:

ST34311A_S:\
        :dt=ST506:ty=fixed:se#512:nt#15:ns#63:nc#8944:sf \
        :pa#60480:oa#0:ta=swap: \
        :pb#8391600:ob#60480:tb=4.4LFS: \
        :pc#8452080:oc#0:tc=unused:

Once the disktab file contains the entry describing the disk geometry, you can proceed to label the disk. For example:


$ rsh target  disklabel -w -r hd0 ST34311A_S

After the disk is labelled, create a mount point for the swap partition, mount the partition as type swap and activate it:


$ cd target_root_dir
$ mkdir swap
$ rsh target mount -t swap /dev/hd0a /swap
$ rsh target swapon /swap

The swap partition is now active.