System Administration Guide: Devices and File Systems

Chapter 21 UFS File System (Reference)

This is a list of the reference information in this chapter.

Default Directories for root (/) and /usr File Systems

The /kernel directory contains only platform-independent objects, including a platform-independent kernel, genunix. For a description of /platform and /usr/platform, the platform-dependent directories, see Table 21–3.

The following table describes the directories that are contained in the root (/) file system.

Table 21–1 Default Directories in the root (/) File System

Directory 

Description 

/

Root of the overall file system name space 

/dev

Primary location for logical device files 

/dev/cfg

Symbolic links to physical ap_ids 

/dev/cua

Device files for uucp

/dev/dsk

Block disk devices 

/dev/fbs

Frame buffer device files 

/dev/fd

File descriptors 

/dev/md

Volume management device names 

/dev/printers

USB printer device files 

/dev/pts

pty slave devices

/dev/rdsk

Raw disk devices 

/dev/rmt

Raw tape devices 

/dev/sad

Entry points for the STREAMS Administrative Driver 

/dev/sound

Audio device and audio device control files 

/dev/swap

Default swap device 

/dev/term

Serial devices 

/devices

Physical device files 

/etc

Host-specific system administration configuration files and databases 

/etc/acct

Accounting configuration information 

/etc/apache

Apache configuration files 

/etc/cron.d

Configuration information for cron

/etc/default

Defaults information for various programs 

/etc/dfs

Configuration information for shared file systems 

/etc/dhcp

Dynamic Host Configuration Protocol (DHCP) configuration files 

/etc/dmi

Solstice Enterprise Agents configuration files 

/etc/fn

Federated Naming Service and x.500 support files 

/etc/fs

Binaries organized by file system types 

/etc/ftpd

ftpd configuration files

/etc/gss

Generic Security Service (GSS) Application Program Interface configuration files 

/etc/gtk

GNOME (GNU Network Object Model Environment) configuration files 

/etc/inet

Configuration files for Internet services 

/etc/init.d

Scripts for changing run levels 

/etc/iplanet

iPlanet configuration files 

/etc/krb5

Kerberos configuration files 

/etc/lib

Dynamic linking libraries that are needed when /usr is not available

/etc/llc2

Logical link control (llc2) driver configuration files

/etc/lp

Configuration information for the printer subsystem 

/etc/lu

Solaris Live Upgrade configuration files 

/etc/lvm

Solaris Volume Manager configuration files 

/etc/mail

Mail subsystem configuration information 

/etc/nca

Solaris Network Cache and Accelerator (NCA) configuration files 

/etc/net

Configuration information for TI (transport- independent) network services 

/etc/nfs

NFS server logging configuration file 

/etc/openwin

OpenWindows configuration files 

/etc/opt

Configuration information for optional packages 

/etc/ppp

Solaris PPP configuration files 

/etc/rc0.d

Scripts for entering or leaving run level 0 

/etc/rc1.d

Scripts for entering or leaving run level 1 

/etc/rc2.d

Scripts for entering or leaving run level 2 

/etc/rc3.d

Scripts for entering or leaving run level 3 

/etc/rcS.d

Scripts for bringing the system to single-user mode 

/etc/rcm

Directory for reconfiguration manager (RCM) custom scripts 

/etc/rpcsec

Might contain an NIS+ authentication configuration file 

/etc/saf

Service access facility files (including FIFOs) 

/etc/security

Basic Security Module (BSM) configuration files 

/etc/sfw

Samba configuration files 

/etc/skel

Default profile scripts for new user accounts 

/etc/smartcard

Solaris SmartCards configuration files 

/etc/snmp

Solstice Enterprise Agents configuration files 

/etc/ssh

Secure shell configuration files 

/etc/sysevent

syseventd configuration files

/etc/tm

Trademark files, whose contents are displayed at boot time 

/etc/usb

USB configuration information 

/etc/uucp

uucp configuration information

/etc/wrsm

WCI Remote Shared Memory (WRSM) configuration information 

/export

Default directory for users' home directories, client file systems, or other shared file systems 

/home

Default directory or mount point for a user's home directory on a standalone system. When AutoFS is running, you cannot create any new entries in this directory. 

/kernel

Directory of platform-independent loadable kernel modules that are required as part of the boot process. Includes the generic part of the core kernel that is platform-independent, /kernel/genunix. See Table 21–3 for the /platform and /usr/platform directory structure.

/mnt

Convenient, temporary mount point for file systems 

/opt

Default directory or mount point for add-on application packages 

/platform

Supported platform files. For more information, see Table 21–3.

/proc

Process information 

/sbin

Essential executables used in the booting process and in manual system failure recovery 

/tmp

Temporary files, whose contents are cleared during boot sequence 

/usr

Mount point for the /usr file system. For more information, see Table 21–2.

/var

Directory for varying files, which usually includes temporary files, logging files, or status files 

/var/adm

System logging files and accounting files 

/var/apache

Scripts, icons, logs, and cache pages for Apache web server 

/var/audit

Basic Security Module (BSM) audit files 

/var/crash

Default depository for kernel crash dumps 

/var/cron

cron's log file

/var/dmi

Solstice Enterprise Agents Desktop Management Interface (DMI) run-time components 

/var/dt

dtlogin configuration files

/var/inet

IPv6 router state files 

/var/krb5

Database and log files for Kerberos 

/var/ld

Configuration files for run-time linker 

/var/ldap

LDAP client configuration files 

/var/log

System log files 

/var/lp

Line printer subsystem logging information  

/var/mail

Directory where user mail is kept 

/var/news

Community service messages. These messages are not the same as USENET-style news. 

/var/nfs

NFS server log files 

/var/nis

NIS+ databases 

/var/ntp

Network Time Protocol (NTP) server state directory 

/var/opt

Root of a subtree for varying files that are associated with software packages 

/var/preserve

Backup files for vi and ex

/var/run

Temporary system files that are not needed across system reboots. A TMPFS-mounted directory. 

/var/sadm

Databases that are maintained by the software package management utilities 

/var/saf

saf (service access facility) logging files and accounting files

/var/samba

Log files and lock files for Samba 

/var/snmp

SNMP status and configuration information 

/var/spool

Directories for spooled temporary files 

/var/spool/clientmqueue

Sendmail client files 

/var/spool/cron

cron and at spool files

/var/spool/locks

Spooling lock files 

/var/spool/lp

Line printer spool files 

/var/spool/mqueue

Mail queued for delivery 

/var/spool/pkg

Spooled packages 

/var/spool/print

LP print service client-side request staging area 

/var/spool/samba

Samba print queue 

/var/spool/uucp

Queued uucp jobs

/var/spool/uucppublic

Files deposited by uucp

/var/statmon

Network status monitor files 

/var/tmp

Directory for temporary files that are not cleared during boot sequence 

/var/uucp

uucp log files and status files

/var/yp

NIS databases 

The following table describes the default directories in the /usr file system.

Table 21–2 Default Directories in the /usr File System

Directory 

Description 

4lib

SunOS 4.1 binary compatibility package libraries 

5bin

Symbolic link to the /usr/bin directory

X

Symbolic link to the /usr/openwin directory

adm

Symbolic link to the /var/adm directory

apache

Apache executables, loadable modules, and documentation 

aset

Directory for Automated Security Enhancement Tools (ASET) programs and files 

bin

Location for standard system commands 

ccs

C compilation programs and libraries 

demo

Demo programs and data 

dict

Symbolic link to the /usr/share/lib/dict directory, which contains the dictionary file used by the UNIX spell program

dt

Directory or mount point for CDE software 

games

An empty directory, which is a remnant of the SunOS 4.0-4.1 software 

include

Header files for C programs, and so on. 

iplanet

Directory server executables, loadable modules, and documentation 

j2se

Java 2 SDK executables, loadable modules, and documentation 

java*

Directories that contain Java programs and libraries 

kernel

Additional kernel modules 

kvm

Obsolete 

lib

Various program libraries, architecture-dependent databases, and binaries not invoked directly by the user 

local

Commands local to a site 

mail

Symbolic link to the /var/mail directory

man

Symbolic link to the /usr/share/man directory

net

Directory for network listener services 

news

Symbolic link to the /var/news directory

oasys

Files for the Form and Menu Language Interpreter (FMLI) execution environment 

old

Programs that are being phased out 

openwin

Directory or mount point for OpenWindows software 

perl5

Perl 5 programs and documentation 

platform

Supported platform files. For more information, see Table 21–3.

preserve

Symbolic link to the /var/preserve directory

proc

Directory for the proc tools

pub

Files for online man page and character processing 

sadm

Various files and directories related to system administration 

sbin

Executables for system administration 

sbin/install.d

Custom JumpStart scripts and executables 

sbin/static

Statically linked version of selected programs from /usr/bin and /usr/sbin

sbin/sparcv7 and sparcv9

32-bit and 64-bit versions of commands on SPARC systems 

sbin/i86

x86 architecture specific commands 

sfw

GNU and open source executables, libraries, and documentation 

share

Architecture-independent sharable files 

share/admserv5.1

iPlanet Console and Administration Server 5.0 documentation 

share/audio

Sample audio files 

share/ds5

iPlanet Directory Server 5.1 Documentation 

share/lib

Architecture-independent databases 

share/man

Solaris manual pages 

share/src

Source code for kernel, libraries, and utilities 

snadm

Programs and libraries related to system and network administration  

spool

Symbolic link to the /var/spool directory

src

Symbolic link to the share/src directory

tmp

Symbolic link to the var/tmp directory

ucb

Berkeley compatibility package binaries 

ucbinclude

Berkeley compatibility package header files 

ucblib

Berkeley compatibility package libraries 

vmsys

Directory for Framed Access Command Environment (FACE) programs 

xpg4

Directory for POSIX-compliant utilities 

The Platform-Dependent Directories

The following table describes the platform-dependent objects in the /platform and /usr/platform directories.

Table 21–3 The /platform and /usr/platform Directories

Directory 

Description 

/platform

Contains a series of directories, one directory per supported platform that needs to reside in the root (/) file system.

/platform/*/kernel

Contains platform-dependent kernel components, including the file unix, the core kernel that is platform–dependent. For more information, see kernel(1M).

/usr/platform

Contains platform-dependent objects that do not need to reside in the root (/) file system.

/usr/platform/*/lib

Contains platform-dependent objects similar to those objects found in the /usr/lib directory.

/usr/platform/*/sbin

Contains platform-dependent objects similar to those objects found in the /usr/sbin directory.

The Structure of Cylinder Groups for UFS File Systems

When you create a UFS file system, the disk slice is divided into cylinder groups, which is made up of one or more consecutive disk cylinders. The cylinder groups are then further divided into addressable blocks to control and organize the structure of the files within the cylinder group. Each type of block has a specific function in the file system. A UFS file system has these four types of blocks:

Block Type  

Type of Information Stored 

Boot block 

Information used when booting the system 

Superblock 

Detailed information about the file system 

Inode 

All information about a file 

Storage or data block 

Data for each file 

The following sections provide additional information about the organization and function of these blocks.

The Boot Block

The boot block stores objects that are used in booting the system. If a file system is not to be used for booting, the boot block is left blank. The boot block appears only in the first cylinder group (cylinder group 0) and is the first 8 Kbytes in a slice.

The Superblock

The superblock stores much of the information about the file system, which includes the following:

Because the superblock contains critical data, multiple superblocks are made when the file system is created.

A summary information block is kept within the superblock. The summary information block is not replicated, but is grouped with the primary superblock, usually in cylinder group 0. The summary block records changes that take place as the file system is used. In addition, the summary block lists the number of inodes, directories, fragments, and storage blocks within the file system.

Inodes

An inode contains all the information about a file except its name, which is kept in a directory. An inode is 128 bytes. The inode information is kept in the cylinder information block, and contains the following:

The array of 15 disk addresses (0 to 14) points to the data blocks that store the contents of the file. The first 12 are direct addresses. That is, they point directly to the first 12 logical storage blocks of the file contents. If the file is larger than 12 logical blocks, the 13th address points to an indirect block, which contains direct block addresses instead of file contents. The 14th address points to a double indirect block, which contains addresses of indirect blocks. The 15th address is for triple indirect addresses. The following figure shows this chaining of address blocks starting from the inode.

Figure 21–1 Address Chain for a UFS File System

Graphic of relationship between the address array of a UFS inode
and the indirect and double indirect pointers to a file's storage blocks.

Data Blocks

Data blocks, also called storage blocks, contain the rest of the space that is allocated to the file system. The size of these data blocks is determined at the time a file system is created. Data blocks are allocated, by default, in two sizes: an 8-Kbyte logical block size, and a 1-Kbyte fragment size.

For a regular file, the data blocks contain the contents of the file. For a directory, the data blocks contain entries that give the inode number and the file name of the files in the directory.

Free Blocks

Blocks that are not currently being used as inodes, as indirect address blocks, or as storage blocks are marked as free in the cylinder group map. This map also keeps track of fragments to prevent fragmentation from degrading disk performance.

To give you an idea of the appearance of a typical UFS file system, the following figure shows a series of cylinder groups in a generic UFS file system.

Figure 21–2 A Typical UFS File System

Graphic of UFS cylinder groups with boot blocks (8 Kbytes in
cylinder group 0 only), superblock, cylinder group map, inodes, and storage blocks.

Custom File System Parameters

Before you choose to alter the default file system parameters that are assigned by the newfs command, you need to understand them. This section describes each of these parameters:

Logical Block Size

The logical block size is the size of the blocks that the UNIX kernel uses to read or write files. The logical block size is usually different from the physical block size. The physical block size is usually 512 bytes, which is the size of the smallest block that the disk controller can read or write.

Logical block size is set to the page size of the system by default. The default logical block size is 8192 bytes (8 Kbytes) for UFS file systems. The UFS file system supports block sizes of 4096 or 8192 bytes (4 or 8 Kbytes). The recommended logical block size is 8 Kbytes.


SPARC only –

You can specify only the 8192-byte block size on the sun4u platform.


To choose the best logical block size for your system, consider both the performance desired and the available space. For most UFS systems, an 8-Kbyte file system provides the best performance, offering a good balance between disk performance and the use of space in primary memory and on disk.

As a general rule, to increase efficiency, use a larger logical block size for file systems where most of the files are very large. Use a smaller logical block size for file systems where most of the files are very small. You can use the quot -c file-system command on a file system to display a complete report on the distribution of files by block size.

However, the page size set when the file system is created is probably best in most cases.

Fragment Size

As files are created or expanded, they are allocated disk space in either full logical blocks or portions of logical blocks called fragments. When disk space is needed for a file, full blocks are allocated first, and then one or more fragments of a block are allocated for the remainder. For small files, allocation begins with fragments.

The ability to allocate fragments of blocks to files, rather than just whole blocks, saves space by reducing fragmentation of disk space that results from unused holes in blocks.

You define the fragment size when you create a UFS file system. The default fragment size is 1 Kbyte. Each block can be divided into 1, 2, 4, or 8 fragments, which results in fragment sizes from 8192 bytes to 512 bytes (for 4-Kbyte file systems only). The lower bound is actually tied to the disk sector size, typically 512 bytes.

For multiterabyte file systems, the fragment size must be equal to the file system block size.


Note –

The upper bound for the fragment is the logical block size, in which case the fragment is not a fragment at all. This configuration might be optimal for file systems with very large files when you are more concerned with speed than with space.


When choosing a fragment size, look at the trade-off between time and space: a small fragment size saves space, but requires more time to allocate. As a general rule, to increase storage efficiency, use a larger fragment size for file systems where most of the files are large. Use a smaller fragment size for file systems where most of the files are small.

Minimum Free Space

The minimum free space is the percentage of the total disk space that is held in reserve when you create the file system. The default reserve is ((64 Mbytes/partition size) * 100), rounded down to the nearest integer and limited between 1 percent and 10 percent, inclusively.

Free space is important because file access becomes less and less efficient as a file system gets full. As long as an adequate amount of free space exists, UFS file systems operate efficiently. When a file system becomes full, using up the available user space, only root can access the reserved free space.

Commands such as df report the percentage of space that is available to users, excluding the percentage allocated as the minimum free space. When the command reports that more than 100 percent of the disk space in the file system is in use, some of the reserve has been used by root.

If you impose quotas on users, the amount of space available to the users does not include the reserved free space. You can change the value of the minimum free space for an existing file system by using the tunefs command.

Rotational Delay

This parameter is obsolete. The value is always set to 0, regardless of the input value.

Optimization Type

The optimization type parameter is set to either space or time.

For more information, see tunefs(1M).

Number of Inodes (Files)

The number of bytes per inode specifies the density of inodes in the file system. The number is divided into the total size of the file system to determine the number of inodes to create. Once the inodes are allocated, you cannot change the number without re-creating the file system.

The default number of bytes per inode is 2048 bytes (2 Kbytes) if the file system is less than one Gbyte. If the file system is larger than one Gbyte, the following formula is used:

File System Size 

Number of Bytes Per Inode 

Less than or equal to 1 Gbyte 

2048 

Less than 2 Gbytes 

4096 

Less than 3 Gbytes 

6144 

3 Gbytes up to 1 Tbyte 

8192 

Greater than 1 Tbyte or created with -T option

1048576 

If you have a file system with many symbolic links, they can lower the average file size. If your file system is going to have many small files, you can give this parameter a lower value. Note, however, that having too many inodes is much better than running out of inodes. If you have too few inodes, you could reach the maximum number of files on a disk slice that is practically empty.

Maximum UFS File and File System Size

The maximum size of a UFS file system is approximately 16 terabytes of usable space, minus approximately one percent overhead. A sparse file can have a logical size of one terabyte. However, the actual amount of data that can be stored in a file is approximately one percent less than one terabyte because of the file system overhead.

Maximum Number of UFS Subdirectories

The maximum number of subdirectories per directory in a UFS file system is 32,767. This limit is predefined and cannot be changed.

Commands for Creating a Customized File System

This section describes the two commands that you use to create a customized file system:

The newfs Command Syntax, Options, and Arguments

The newfs command is a friendlier version of the mkfs command that is used to create file systems.

The syntax is as follows:


/usr/sbin/newfs [-NTv] [mkfs_options] raw_device

The following table describes the options and arguments for the newfs command.

Table 21–4 The newfs Command Options and Arguments

Option 

Description 

-N

Displays the file system parameters that would be used in creating the file system without actually creating it. This option does not display the parameters that were used to create an existing file system. 

-T

Set the parameters of the file system to allow eventual growth to over a terabyte in total file system size. This option sets fragsize to be the same as bsize, and sets nbpi to 1 Mbyte, unless the -i option is used to make it even larger. If you use the -f or -i options to specify a fragsize or nbpi that is incompatible with this option, the user-supplied value of fragsize or nbpi is ignored.

-v

Displays the parameters that are passed to the mkfs command.

mkfs-options

Use the options in this table, from -a apc to -t track, to set the mkfs parameters. Separate the options with spaces.

-a apc

The number of alternate sectors per disk cylinder to reserve for bad block placement for SCSI devices only. The default is 0. 

This option is not applicable for disks with EFI labels and is ignored. 

-b bsize

The logical block size of the file system, which is either 4096 or 8192 bytes. The default is 8192 bytes. The sun4u architecture does not support the 4096 block size. 

-c cgsize

The number of cylinders per cylinder group, which ranges from 16 to 256. The default value is calculated by dividing the number of sectors in the file system by the number of sectors in 1 Gbyte. Then, the result is multiplied by 32. The default value is always between 16 to 256. 

Use the mkfs command to override the default value.

This option is not applicable for disks with EFI labels and is ignored. 

-C maxcontig

The maximum number of logical blocks, belonging to one file, that are allocated contiguously. The default is calculated as follows: 

maxcontig = disk drive maximum transfer size / disk block size

If the disk drive maximum transfer size cannot be determined, the default value for maxcontig is calculated as follows:

If maxphys is less than ufs_maxmaxphys, which is typically 1 Mbyte, then maxcontig is set to maxphys. Otherwise, maxcontig is set to ufs_maxmaxphys.

You can set maxcontig to any positive integer value.

The actual value will be the lesser of what has been specified and what the hardware supports. 

You can subsequently change this parameter by using the tunefs command. For more information, seetunefs(1M).

-d gap

Rotational delay. This option is obsolete. The value is always set to 0, regardless of the input value. 

-f fragsize

The smallest amount of disk space in bytes that can be allocated to a file. fragsize must be a power of 2 divisor of bsize, where:

bsize / fragsize is 1, 2, 4, or 8.

This means that if the logical block size is 4096, legal values for fragsize are 512, 1024, 2048, and 4096. When the logical block size is 8192, legal values are 1024, 2048, 4096, and 8192. The default value is 1024.

For file systems greater than 1 terabyte or for file systems created with the -T option, fragsize is forced to match block size (bsize).

-i nbpi

The number of bytes per inode, which specifies the density of inodes in the file system. The number is divided into the total size of the file system to determine the number of inodes to create. 

This value should reflect the expected average size of files in the file system. If fewer inodes are needed, specify a larger number. To create more inodes, specify a smaller number. 

For the default values, see Number of Inodes (Files).

-m free

The minimum percentage of free space to maintain in the file system (between 0% and 99%, inclusively). This space is off– limits to regular users. Once the file system is filled to this threshold, only the superuser can continue writing to the file system. 

The default is ((64 Mbytes/partition size) * 100), rounded down to the nearest integer and limited between 1% and 10%, inclusively. 

This parameter can be modified after the file system is created by using the tunefs command.

-n nrpos

The number of different rotation positions in which to divide a cylinder group. The default is 8. 

This option is not applicable for disks with EFI labels and is ignored. 

-o opt

Optimization type, space or time. The file system can either be instructed to try to minimize the time spent allocating blocks, or to try to minimize the space fragmentation on the disk. The default is time.

-r rpm

The rotational speed of the disk in revolutions per minute. This setting is driver- or device-specific. 

This parameter is converted to revolutions per second before it is passed to the mkfs command.

This option is not applicable for disks with EFI labels and is ignored. 

-s size

The size of the file system in sectors. The default is to use the entire partition. 

-t ntrack

The number of tracks per cylinder on the disk. The default is taken from the disk label. 

This option is not applicable for disks with EFI labels and is ignored. 

raw_device

The name of a raw special device residing in the /dev directory (for example, /dev/rdsk/c0t0d0s6) on which to create the file system. This argument is required.


Example 21–1 newfs Command Options and Arguments

This example shows how to use the -N option to display file system information, including the backup superblocks.


# newfs -N /dev/rdsk/c0t0d0s0
/dev/rdsk/c0t0d0s0:  37260 sectors in 115 cylinders of 9 tracks, 36 sectors
        19.1MB in 8 cyl groups (16 c/g, 2.65MB/g, 1216 i/g)
superblock backups (for fsck -b #) at:
 32, 5264, 10496, 15728, 20960, 26192, 31424, 36656,
#

The Generic mkfs Command

The generic mkfs command calls a file system-specific mkfs command, which then creates a file system of a specified type on a specified disk slice. Although the mkfs command can support different types of file systems, in practice you would use it to create UFS, UDFS, or PCFS file systems. To make other types of file systems, you would have to write the software for the file system–specific versions of the mkfs command to use. Normally, you do not run the mkfs command directly. The mkfs command is called by the newfs command.

The generic mkfs command is located in the /usr/sbin directory. For a description of the arguments and options, see mkfs(1M).