![]() |
|
||||
LynxOS User's Guide |
Disk Space Management
This chapter describes managing disk space under LynxOS, and procedures for backing up and restoring data with the tar (tape archive) utility.
Formatting Media
LynxOS supplies the following two utilities for low-level media formatting:
Usually, low-level formatting is needed for floppies only - it is almost never needed for SCSI disks.
LynxOS does not provide any low-level formatting-specific utilities for IDE disks. The mkfs utility, which creates a file system on a targeted medium, also formats media by performing the following tasks:
Low-level formatting of media is generally necessary only after read/write access to it has failed. A typical test of read/write accessibility for a medium is to attempt running mkfs.
Formatting Floppy Disks
Formatting floppy disks with fmtflop overwrites all old data.
Additionally, the fmtflop command can be used to specify the interleave factor and an initial filler value of a floppy using the following syntax:
The interleave factor dictates the physical spacing between each block. Optimally, the interleave is 1. The filler value - any value in the range
0 - 255 - is written into every byte of each block. Default values for interleave and filler are 1 and 0xf6.The filler is a pattern that is used to catch various errors on the medium as it is formatted. The filler occupies every byte of the medium as it is formatted. In the verification phase of formatting, the medium is checked for the filler value. If it does not match the filler value specified, an error is printed. Choosing different fillers and formatting the floppy multiple times ensures integrity.
Usually, the interleave factor is not specified. Larger interleave factors are useful on very slow machines, which take so much time to process each block read from the floppy that they must wait a full rotational delay to read the next block. Placing the next block further away from the current block gives a slow machine the time it needs to process data and avoids the rotational delay penalty.
Typically, fmtflop operates silently. The -v (verbose) option instructs the program to print each track number as it is formatted.
Formatting SCSI Disks
When the fmtscsi command is run on a SCSI disk, the SCSI disk might simply ignore the command; if the command is ignored, fmtscsi immediately returns. Nevertheless, LynxOS provides the fmtscsi command syntax:
As with floppy disks, interleave should almost always be 1 (the default). fmtscsi requires two confirmations before it actually issues the formatting command to the driver.
Configuring Disk Space
Making File Systems
The mkfs (make file system) command creates a new file system on a disk or diskette.
![]()
For this reason, only superusers should be allowed to use this command.
The syntax for mkfs is as follows:
Setting Block Size
The -b option sets the block size of the new file system in number of bytes. The default block size is 512 bytes. The block size is set by entering a value representing the desired number of bytes (number_bytes above) as an argument to the -b option. Accepted values are 512, 1024, 2048, 4096, 8192, 16384, and 32768.
The installation utility installit uses -b 2048 when making a file system.
A large number of bytes per block may be appropriate when the majority of files are large. Choose 512 or 1024 if the disk contains mostly small files. This optimizes file storage on the disk. The values 2048 and 4096 are good general purpose values.
For example, the following command creates a 2048 byte block size file system on partition c of an Adaptec 2940 SCSI device 0, where device_name is sd2940.0c:
Setting Inodes
The inodes argument allows the total number of inodes for a file system to be specified. If inodes is not specified, mkfs creates one inode for every 16
512-byte block on the device. If the file system is expected to have many small files, a larger value for inodes should be specified. For example, the following command creates a file system with 8000 inodes on partition b of an Adaptec 2940 SCSI device 2, where device_name is sd2940:For floppy disks, however, the space used for unnecessary inodes can be important; it may be preferable to choose fewer inodes, as follows:
After it has been created, the file system's parameters can be examined with the df command, for example, as follows:
df shows the number of free blocks available for data after taking into account the blocks used for the inode table and the super block. Once a file system has been created, the device containing it can be mounted with the mount command.
Organizing Files
The primary means of organizing files in a LynxOS file system is through a hierarchical directory structure. A directory is a file that records pairs of file names and inode numbers. Additional directories can be included among the files recorded in a directory.
Creating Directories
Upon initial LynxOS installation, the mkfs utility is used to establish a root directory. Additional directories are then created below the root directory to establish a working root file system.
The mkdir command creates directories with the following command syntax:
LynxOS creates each directory with the two special entries: dot (.) and dot dot (..), which represent the inode of the directory itself and the inode of its parent directory, respectively.
In addition to system operation, directories must also be created for software development or applications. Typically, a directory is created for each individual who has an account on the system, either directly beneath the root, or in some subdirectory (/usr is commonly used for this purpose.).
Additional directories owned by the superuser or by any other users can be added as needed while the system is being used.
Removing Directories
Directories can be removed with the following commands:
These commands are available to all LynxOS users, not just the superuser. The permissions on certain directories can be set to prevent regular users from removing them.
The rmdir command removes a specified directory:
To remove a directory and its contents - files and subdirectories - recursively, use the rm -r command:
The -r argument instructs rm to recursively remove the entire hierarchy beneath directory, including directory itself.
Managing Disk Space Usage
Although LynxOS provides no disk space quota mechanism, administrators can arbitrarily exercise tight control over resource consumption by periodically checking each user's space usage.
The du Command
The du command reports space consumed under a particular directory. Assuming user accounts are all established with home directories in the /usr directory, the following du command reports consumption per user:
The values reported by du are in terms of kilobytes (KB). Note that du can be applied to any portion of the directory hierarchy, not just user-owned directories. The total amount of space available in a file system is stored in the super block.
Using df Command
The df command reads the super block and reports the free disk space, and, optionally, the number of free inodes.
df reports free space for each file system listed recursively within a super block. Specific file systems can also be specified on the command line.
Using the find Command to Determine File Usage
When disk space usage is over 90 percent, users should delete or back-up any unused files in order to increase storage resources. To determine which files might be eligible for deletion or back-up, use the find command to list files that have not been accessed within a specified amount of time. The find command uses the syntax below:
The expressions atime +30 and mtime +30 in the example above tell the find command to report all files not read or modified in more than 30 days. The atime value can be set by the user to any number of days.
With a similar command, users can first print a list of files to screen, then remove them using the find and rm commands as follows:
Backing Up the System
Regardless of the physical reliability of hard disks, many opportunities exist for data loss due to software errors. For example, executing the find command could potentially globally delete critical files. Therefore, a backup system is highly recommended. LynuxWorks recommends the standard UNIX tar (tape archive) utility.
The tar Command
To back up data on the system, use the tar command. This command gathers subtrees of the directory structure (or even the entire directory tree) into one file, usually onto some removable device.
Creating the tar Backup File
Once a tar backup file has been created, users can examine the file and selectively extract portions of the saved directory tree with tar.
For example, to copy the entire contents of the /usr/ directory subtree to a system's tape drive, the following command would be used:
The -cv argument directs tar to create (c) a new output file, rather than skip to the end of an existing file, and to display a verbose (v), file-by-file listing of files copied.
As no output file is specified in this example, the /dev/tar.default file is used; normally, a system is configured so that the file /dev/tar.default is linked to the device name of the tape drive. If tar detects that it has run out of space on the output device, it requests that another storage medium be inserted. For tar to be able to detect the end of storage on a medium, the raw device interface must be used.
In the example above, the /usr/ directory was referred to using an absolute path name. The file names in the headers in the tar file reflect the absolute path names. This implies that when files are later extracted, they are forced into the exact position in the overall directory tree they originally had. If, on the other hand, the original tar had been performed as shown below, by first changing the working directory to /usr and then giving tar the path name .(period), the files are written with a relative instead of absolute path name:
The files can then be extracted from the backup file and placed anywhere in the directory structure.
Restoring Backups
Once users have created a tar backup on a tape, another hard disk, or floppy disk, they can restore the saved information in case of data loss using the following command syntax:
The x option means "extract." All files in the backup volume are copied to the main file system based on the path names in the headers. As each file is extracted, its name and other statistics are printed on screen. Individual files can be extracted by listing the desired path names after the key, as in this example:
Each file name header that matches any requested name is restored.
Creating Backup Policies and Procedures
All computer systems need the data on their disks to be backed up. However, the frequency of backups depends on each specific system's requirements. Before installing a new version of LynxOS, create a backup on the system. Files can be backed up to the following types of media:
Users can use the find and tar commands to locate files and write to backup media. For example, all files that have been modified in the last week can be backed up with the following commands:
Where device is the device node for an IDE, SCSI or floppy device. See "LynxOS Device Node Naming Conventions".
LynuxWorks recommends that the following system configuration files be backed up on a regular basis:
![]() LynuxWorks, Inc. 855 Branham Lane East San Jose, CA 95138 http://www.lynuxworks.com 1.800.255.5969 |
![]() |
![]() |
![]() |
![]() |