The newfs command will display information about the new file system as it operates. The first line printed by newfs describes the basic disk geometry. The second line of output from newfs describes the ufs file system created in this partition. Cylinder groups are a concept introduced in the Berkeley UNIX Fast File system. Cylinder groups provide a method by which file blocks are allocated close together on the disk to improve performance. TIP: Varying the size of the cylinder groups is one way to tune the performance of a ufs file system. The final two lines of newfs output list the locations of the superblock backups. The superblock is the head of the file index node or inode information used by the ufs file system. The inodes are “used” by routines in the Solaris kernel to allocate, read, write, and delete files. Backup copies of these superblocks are created in the event a system crash, power failure, or other problem leaves the main copy of the superblock damaged.
For most applications, a detailed knowledge of the mkfs parameters is unnecessary; newfs makes proper choices for the parameters it passes to mkfs . It is possible to build a file system tuned to store a large quantity of small, frequently changing files, such as those found in the Usenet net-news system. Such a file system would require more index nodes or inodes than are provided by the default options used by newfs .
Device to mount - Name of device to be mounted. Device to fsck - Raw device to be checked by the fsck utility. Mount point - Directory where the device should be added to the UNIX file tree. FS type - File system type. fsck pass - Number indicates the order which the file system will be checked. Mount at boot - Yes to cause file system to mount at boot. Mount options - Options to be passed to the mount command. Options are given as a comma-separated list following the -o flag (e.g., mount -o rw,quota ). Some of the more common options for the mount command are. Quota - Activates the user disk quota system when the file system is mounted Ro - Mounts the file system read-only -F fstype - Mounts a file system of fstype -a - Mounts all file systems with “mount at boot” (in the vfstab file) set to yes -o - Uses specific fstype options when mounting file system -p - Provides a list of mounted file systems in vfstab format -v - Provides verbose output when mounting file system(s) -O - Overlays the file system on an existing mount point -m - Mounts file system without making an entry in /etc/mnttab Nosuid - Disallows setUID execution for files in this file system
When df is invoked with a directory argument, the output format changes, as shown in the following. glenn% df / File system kbytes used avail capacity Mounted on /dev/dsk/c0t3d0s0 20664 14819 3785 80% / The most complete df listing is obtained by using the -g option glenn% df -g / / (/dev/dsk/c0t3d0s0): 8192 block size 1024 frag size 41328 total blocks 11690 free blocks 7570 available 11520 total files 9292 free files 8388632 filesys id ufs fstype 0x00000004 flag 255 file name length NOTE: It is important to remember the differences among the three block sizes discussed in this chapter. A disk block is the basic unit of storage on the physical medium. This unit is often 512 bytes long, but not always. An allocation block is the basic unit of space in a file system. It is either 8,192 or 4,096 bytes in length. A fragment, often 1,024 bytes in length, is a portion of an allocation block.
The first form of the umount command unmounts the file system referred to by “mount point.” For example, umount /scratch would unmount the /scratch file system. The second form of the umount command unmounts the file system on the referenced disk partition. For example, if the /scratch file system is on the c0t2d0s1 disk partition, the operator could unmount it with umount /dev/dsk/c0t2d0s1 . If you are uncertain about the effect unmounting a file system may have on the system, it is best to bring the system to the single-user state before invoking the umount command. In the case of a file server, unmounting a file system may also have an effect on nfs client machines on which the file system is mounted.
Other OSs handle this situation by providing utilities under the desktop manager toolkit (such as KDE under Linux), mediad under Irix, and autodiskmount under MacOS X. Under Solaris, automatic detection of the media is limited to the CD-ROM device. The Solaris File Manager accomplishes this with a combination of a daemon ( vold ) and a configuration file ( /etc/vold.conf ), which specifies the actions to be taken for various removable devices and file system types. For floppy disks, Volume Manager is unable to detect the presence of new disks and must be informed that a new disk is present. This is accomplished by invoking the /bin/volcheck command. Volume Manager always mounts floppy disks under the /floppy directory it controls. CD-ROMs are likewise mounted under the /cdrom directory.
The lines beginning with a pound sign (#) are considered comments and are used here to help delineate the various sections of the configuration information. The first two sections, beginning with the comments Database and Labels , describe the database routines and disk label types Volume Manager recognizes. These two sections should not be modified. “ Devices to use” Section The third section, marked by the comment Devices to use , lists the names and types of the removable media devices Volume Manager should monitor. Each line in this section starts with the keyword use , as follows. use cdrom drive /dev/dsk/c0t6 dev_cdrom.so cdrom0 The use keyword is followed by the type of device, either CD-ROM or floppy, and the keyword drive , as follows. use cdrom drive /dev/dsk/c0t6 dev_cdrom.so cdrom0 Following the device type is the OS name for the device. Note that the CD-ROM device name specifies only the first five characters of the full special device name. Because Volume Manager will monitor and mount all available slices it finds on a CD-ROM disk, the only information items needed are the specific controller and target portions of the device name. use cdrom drive /dev/dsk/c0t6 dev_cdrom.so cdrom0 Following the special device name is the name of the shared object used to manage the device. This must match the device type specified (e.g., if the device type is cdrom , the shared object must be dev_cdrom.so ). Finally, the symbolic name used in the /device directory is listed. The first device of a given type has a 0 (zero) appended to its name, whereas the second is appended with a 1, and so on. For instance, a second CD-ROM drive located at target 5 on the built-in SCSI controller would be placed under Volume Manager control by adding the following line to the devices section of the vold.conf file. use cdrom drive /dev/dsk/c0t5 dev_cdrom.so cdrom1 Actions Section The next section, which begins with the comment Actions , specifies the actions to be taken when certain events occur. The basic events are the insertion of media into a drive ( insert ), removal of media from a drive ( eject ), and notification of problems ( notify ). An example entry in the actions section follows. eject /vol*/dev/diskette[0-9]/* user=root /usr/sbin/rmmount Entry Content Each line lists an event followed by a regular expression. When an event occurs, each line that begins with the name of the event ( insert , eject , or notify ) is checked. If the volume on which the event occurs matches the regular expression, the remainder of the action line comes into play. The remainder of this line includes the name of the user or group identification to be used to run the listed command with the listed arguments. In the previous example line, when the eject event occurs and the volume matches the regular expression /vol*/dev/diskette[0-9]/* , the command /usr/sbin/rmmount would be run with the root user permissions.
Fsck is a multi-phase file system checker. Phase 1 checks that all of the right blocks are used (or unused) within the file system. This phase also checks that the size of the file (as recorded in the inode) agrees with the size of the data stored in the “used” blocks. Phase 2 of fsck checks to ensure that the directory and file name structure is coherent. Phase 3 of fsck checks to ensure that the directories are connected to the file system tree in the proper places, and that all links are properly referenced in the inode structure. Phase 4 checks to ensure that the link counts and reference counts are correct. Phase 5 checks individual cylinder group utilization, and reports file system statistics.
TIP: It is often faster (and easier) not to reconnect zero-length files. Zero-length files may occur if a program creates a temporary file, opens it, and then removes it while the file is still open. The result is a file that does not belong to any directory but is still available to be written and read by the program. Under normal operations the file is cleaned up when the program exits.
Linux provides support for the following journaling file systems: BeFS (BeOS File System), HTFS (SCO High Throughput file system), JFS (IBM journaling file system), NSS (Novel Storage Services), VxFS (Veritas File System), XFS (IRIX Extended File system), and the EXT3 file system. These are the most popular journaling file systems under Linux. The ext3 file system has become the standard on newer releases of Linux. The ext3 file system introduces several options for journaling that were not available under ext2. These options allow the sysadmin to tune the journal. The sysadmin can make the decision to tune the file system for performance (speed), or to tune the file system for reliability (data integrity). When tuning ext3 file systems for speed, the administrator can choose among the following modes.
A file fragment exists because the file did not contain enough information to completely fill a multiple of disk sectors. When this occurs, only a portion of at least one disk sector is filled by the file. Over time, the file may be altered, and the space consumed by these fragmented sectors begins to add up. Another cause of file system fragmentation is the removal of files. This operation leaves clusters of data sectors empty in a field of sectors in use for other files. The defragmentation operation cleans these fragmented sectors, and causes the files to occupy contiguous sectors (if possible).
NOTE: The repair option does not work with IDE disk drives. The IDE subsystem should handle bad-block mapping on its own.
TIP: Due to the performance characteristics of SCSI and IDE disk subsystems, it would be advisable to incorporate SCSI-based disk drives in any high-performance disk subsystems. The high-end SCSI drives typically outperform their IDE counterparts in such applications. NOTE: A growing number of modern SCSI disks are “smart” in that they have a sophisticated internal controller and memory buffer that hide certain performance characteristics. These disks provide high performance, but are not readily tunable. The internal controller and memory buffer mask the effects of selected adjustments such as rotational delay factors. TIP: It is always a good idea to verify that the file system has been backed up to tape before making changes. If something goes wrong, the backup medium could be used to reload the files once a new file system is created with the desired parameters.
NOTE: The space-versus-time storage strategy routines are automatically set by newfs, depending on the allocated minimum free space. The defaults are to use space optimization when the minimum free space is less than 10% of the disk blocks, and to use time optimization when the minimum free space is 10% or more of the disk blocks.
The [v]fstab file is used to mount file systems at boot time.
The “v” is bracketed, as some versions of UNIX call this file /etc/fstab (primarily BSD UNIX), other versions of UNIX call this file /etc/vfstab (primarily System V UNIX), and a few versions of UNIX call this file /etc/checktab (HP/UX).
This file is read by the /etc/mountall command when it is run as part of the system boot sequence.
A quick way to add items to [ v]fstab is to use the - p option to the mount command.
It is also possible to add new file systems by editing the [v]fstab file and entering the required information manually.
The [v]fstab file format may contain minor modifications on different variants of UNIX,.
The Volume Manager provides users with a means of mounting/unmounting removable media without granting system users root privileges typically required to mount/unmount a file system.
Under Linux, you can add the “user” option to the list of options for a file system. This allows any user to mount/unmount the file system (an operation that usually requires root access).
For example, the following fstab entry would allow any user to mount the /jaz file system located on the removable disk /dev/sda1 . The nosuid option disallows execution of suid programs from this medium.
The mount command allows the administrator to view which file systems are mounted, as well as providing a method of mounting file systems. When invoked without arguments, the mount command lists mounted file systems by their mount points, showing the device mounted at each mount point, the mount options used, and the time the file system was mounted.
/ on /dev/dsk/c0t3d0s0 read/write/setuid on Sat Apr 1 1:23:45 2000
/usr on /dev/dsk/c0t3d0s6 read/write/setuid on Sat Apr 1 1:23:45 2000
/proc on /proc read/write/setuid on Sat Apr 1 1:23:45 2000
/dev/fd on fd read/write/setuid on Sat Apr 1 1:23:45 2000
/tmp on swap read/write on Sat Apr 1 1:23:45 2000
/opt on /dev/dsk/c0t3d0s5 setuid/read/write on Sat Apr 1 1:23:45 2000
Adding entries to the Solaris vfstab file works well for hard disks but is not suitable for removable media such as floppies and CD-ROMs.
These devices tend to be mounted and unmounted much more frequently than hard disks, and the user performing this “mount” operation may not have the root privileges required to mount a normal file system.
To handle such situations, Solaris uses the Volume Manager.
Volume Manager is also able to handle file system types other than ufs .
For instance, inserting an MS-DOS-formatted floppy and using File Manager or the volcheck command results in the disk being mounted under the /floppy directory on a mount point that bears the floppy volume name.
Starting and Stopping Volume Manager
UNIX makes it possible to disable Volume Manager and work directly with the CD-ROM and/or floppy drive.
To disable Volume Manager, invoke the /etc/init.d/volmgt script with the stop option.
To restart Volume Manager, invoke the /etc/init.d/volmgt script with the start option.
Hard errors are typically caused by head crashes, cabling problems, or electronics failures
WARNING: Whenever a fatal disk error is reported, the administrator should be very concerned about the integrity of the files on the disk drive. Steps must be taken to rectify the problem immediately, or data may be destroyed.
Perform a full backup of the failing disk, or better yet, the entire system.
Reboot the system to determine if the failure is due to corrupted system information.
If the block number of a bad spot is known, use the system’s format utility to map out the spot on the drive.
If there are several bad spots on the drive, use the surface verification portion of the format utility to perform nondestructive surface analysis of the drive to search for and optionally repair bad spots.
Replace the drive with a known good drive. Copy all data to the new drive. Note that this option can be time consuming and expensive.
Optimize file systems across multiple spindles and controllers.
Optimize file system structures for the type of files to be stored on the file system.
The default newfs settings are good for general purpose file systems. But they are also very inefficient for certain types of applications.
File systems containing primarily large files require fewer inodes. This leads to a lot of lost space.
File systems containing primarily small files require more inodes. This leads to a problem where there is space left on the device, but no file system structures are available to address the unused space!
File system tuning can provide only limited performance improvements.
Performance tuning is critical to the first type (active files), and probably not very important for the archive server.
In most instances, disk farms are set up to provide high-speed access to important data. Typical applications include database systems, medical images, and other space-intensive information services.
In a few instances, the disk farm is used for long-term archival storage. Because the information on these systems is not accessed very often, high performance is not always the driving criterion in file system tuning.
Although tunefs is capable of changing many characteristics of the disk subsystem, it is not a do-all/save-all I/O subsystem fix-it tool.
The tunefs command allows you to “tune” file system parameters as you build a file system (more/less inodes, more/less free space, …).
Tuning for Special Disks and Disk Controllers
By default, newfs uses the information in the disk label to calculate several factors related to the ability of the disk, controller, and CPU to read or write information. As the disk rotates, each block in the track moves past the disk heads. If the controller and CPU are fast enough, blocks may be written or read in the order they come under the heads.
Slower controller/CPU combinations must skip one or more blocks between read/writes to keep up with the I/O demands of the system. The newfs and tunefs commands allow the rotational interleave aspect of the file system to be adjusted by calculating the required time for a single block read to be processed.
Some disk controllers are capable of writing or reading multiple blocks in a single operation due to high-speed buffer memory located in the controller.
Applications that consistently read and write very small (or very large) files can often benefit from file system tuning.
Large files are often split between cylinder groups. A cylinder group is a collection of cylinders used by the disk I/O routines in the kernel to improve disk performance by grouping a file’s data blocks close together on the disk.
When a large file is split over two or more cylinder groups, the file’s data blocks are spread across the disk. Consequently, extra seek time is required.
Adjusting the maximum number of blocks that can be allocated to a single file within a cylinder group may help reduce this problem.
It is also possible to adjust basic allocation block and fragment sizes on the file system.
Larger allocation block and fragment sizes favor large files by reducing the time required for file allocation at the expense of reduced space efficiency.
If an application stores small files (exclusively), a smaller allocation block will improve speed, and a smaller fragment size will improve space utilization efficiency by avoiding the allocation of blocks that are much larger than the data to be stored.
The disk storage routines in the UNIX kernel have two strategies available for disk allocation: time and space.
Time efficiency refers to the time required to allocate space and write files. Optimizing time is wasteful of space because transfers often result in gaps being created in lieu of long, continuous disk writes.
Space efficiency refers to the efficient use of scattered blocks on the disk. Optimizing space wastes time because a file is allocated to blocks scattered around the disk, and the disk heads must move more frequently to read or write a file.