📄 unx35.htm
字号:
<BR></P>
<P>UNIX supports several file system types, and each of them has several tuning options. The steps in preparing a file system follow:
<BR></P>
<OL>
<LI>Choose the type of file system.
<BR>
<BR></LI>
<LI>Select the proper cluster size, block size, and number of inodes.
<BR>
<BR></LI>
<LI>Use mkfs or newfs to build the file system.
<BR>
<BR></LI></OL>
<H4 ALIGN="CENTER">
<CENTER><A ID="I22" NAME="I22">
<FONT SIZE=3><B>Choosing a File System Type</B>
<BR></FONT></A></CENTER></H4>
<P>Of the many types of file systems supported under UNIX, the first three listed here are normally used:
<BR></P>
<UL>
<LI>s5 The older System V file system. A low overhead file system useful for removable media.
<BR>
<BR></LI>
<LI>ufs The new name for the Berkeley Fast File System.
<BR>
<BR></LI>
<LI>vxfs The Veritas Extent-Based File System.
<BR>
<BR></LI>
<LI>pcfs MS-DOS FAT-based File System. Used to access DOS floppies and hard disk partitions. Although this file system type is compatible with DOS, it is not as robust as the UNIX formats and should be used only for exchange media with DOS systems.
<BR>
<BR></LI>
<LI>hsfs High Sierra File System. Used by ISO-9660 CD-ROMs. Often used with the Rock Ridge extensions to map UNIX filenaming conventions to the ISO-9660 standard layout.
<BR>
<BR></LI>
<LI>cfs Cached File System. A local storage area for caching an NFS file system. See Chapter 37 for further information on Network File Systems.
<BR>
<BR></LI>
<LI>bfs A very simplistic file system used to hold stand-alone boot images. It supports only contiguous files and is not intended for use beyond the system boot images.
<BR>
<BR></LI>
<LI>tmpfs A RAM-based file system used for the /tmp directory. It shares paging space with the swap partition. It is available on only a small number of UNIX systems.
<BR>
<BR></LI></UL>
<H5 ALIGN="CENTER">
<CENTER><A ID="I23" NAME="I23">
<FONT SIZE=3><B><I>s5</I></B><B>—The System V File System</B>
<BR></FONT></A></CENTER></H5>
<P>Before System V Release 4 adopted the ufs file system, this was the de facto standard for UNIX. It is a low overhead file system that supports only 14-character filenames and a restricted number of inodes (65536). In addition, it is prone to
fragmentation, which can slow down access to the disk. It is currently used when sharing removable media between older systems and current ones is desired, and for floppies where the overhead of ufs wastes too much space. Except for backward compatibility
uses, it should be limited to file systems of 2 MB or less.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I24" NAME="I24">
<FONT SIZE=3><B><I>ufs</I></B><B>—The UNIX File System (Formerly the Berkeley Fast File System)</B>
<BR></FONT></A></CENTER></H5>
<P>This file system is based on cylinder groups. It groups files together to reduce access times and reduce fragmentation. To achieve this, it extracts a 10—20 percent space overhead on the drive. It supports long filenames and is not restricted as to
the number of inodes. This is the default file system type on Solaris. The ufs file system is the only one that supports disk quotas, restricting the amount of disk space a user can use.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I25" NAME="I25">
<FONT SIZE=3><B><I>vxfs</I></B><B>—The Veritas Extent-Based File System</B>
<BR></FONT></A></CENTER></H5>
<P>s5 and ufs file systems rely on the full structural verification check in the fsck utility to recover from system failures. This takes several minutes per disk after a system crash. Normally not much is lost, usually just what was still in the file
system cache in RAM, but the delay on boot can be large. On a file server it can add over an hour to the boot time.
<BR></P>
<P>The vxfs file system provides recovery in seconds after a system failure by using a tracking feature called intent logging. The fsck utility scans this log and needs to check only those intents that were not yet completed. In addition, the vxfs uses
extent-based allocation to further reduce fragmentation.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>If the vxfs file system type is available, it is the file system type of choice except for some special conditions. Use a ufs file system in the following circumstances:
<BR>
<BR>The file system is going to consist of many small short-lived files.
<BR>
<BR>You are going to have a set of files that will be growing, causing many extents to be needed.
<BR>
<BR>You need to enforce quotas.
<BR>
<BR>The file system is static and read-only.
<BR>
<BR>Use an s5 file system in the following circumstances:
<BR>
<BR>Backward compatibility is required.
<BR>
<BR>The removable media is small and the overhead of vxfs and ufs use too much of the available space.
<BR></NOTE>
<HR ALIGN=CENTER>
<H4 ALIGN="CENTER">
<CENTER><A ID="I26" NAME="I26">
<FONT SIZE=3><B>Choosing File System Parameters</B>
<BR></FONT></A></CENTER></H4>
<P>Most of the time the default parameters chosen by disksetup or newfs are sufficient. This section will explain the meaning of these parameters in case you ever have to tune them. The most common ones to tune are
<BR></P>
<UL>
<LI>Number of inodes
<BR>
<BR></LI>
<LI>Number of cylinders per group (ufs only)
<BR>
<BR></LI></UL>
<H5 ALIGN="CENTER">
<CENTER><A ID="I27" NAME="I27">
<FONT SIZE=3><B>Number of Inodes</B>
<BR></FONT></A></CENTER></H5>
<P>Each file takes one inode. Each inode also takes space: 128 bytes. There is a trade-off between the number of inodes and the size of the partition. If your average file is many megabytes long, the default of 1 inode per 4 KB will generate many more
inodes than needed, wasting space on the file system. On the other hand, if the partition is full of small files, such as a USENET Network News partition, you might run out of inodes before you run out of space. If you know how many files to expect, you
can tune this parameter to wring more space out of the slice.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I28" NAME="I28">
<FONT SIZE=3><B>Block Size</B>
<BR></FONT></A></CENTER></H5>
<P>For ufs file systems, this should be the same as the page size of the memory management system: either 4 KB or 8 KB. There is little reason to change this. However, if a disk will be moved between systems with 4 KB and 8 KB page sizes, it is best to use
4 KB for the partition. The larger the block size, the large the amount of data per I/O. However, small files will also need more fragmentation space.
<BR></P>
<P>For s5 file systems, this is both the I/O block size and the file allocation increment. If the media is small, consider making this 512 bytes to squeeze as much as you can on the disk. The default value is tuned more toward performance at 2 KB.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I29" NAME="I29">
<FONT SIZE=3><B>Expected Fragmentation/Fragment Size</B>
<BR></FONT></A></CENTER></H5>
<P>On ufs file systems, the last block of the file is usually not full. Rather than wasting 4 KB or 8 KB for the last block, it places multiple fragments of files into one block. If you have a large number of very small files, make this parameter small to
avoid wasting so much space. It defaults to 1 KB but can be set as low as 512 bytes. The default of 1 KB is sufficient in almost all cases.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I30" NAME="I30">
<FONT SIZE=3><B>Cylinder Size</B>
<BR></FONT></A></CENTER></H5>
<P>In ufs file systems, files are grouped together into cylinder groups to reduce seeks. A cylinder group consists of 1 to 32 cylinders. If you set it to 1 cylinder, the file systems do very little seeking while reading a single file. The trade-off is
space overhead. Each cylinder group has a set of structures including a backup copy of the super-block in case the main one gets damaged. Increasing the number of cylinders reduces overhead but also increases seeks. It is the classic trade-off of space
versus performance. The default of 16 is normally adequate. It is usually changed only to wring the last bit of space out of a file system.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I31" NAME="I31">
<FONT SIZE=3><B>Rotational Delay</B>
<BR></FONT></A></CENTER></H5>
<P>To optimize disk performance, the system tries to slip the sector usage from cylinder to cylinder to compensate for the track-to-track seek time of the disk. By starting each cylinder on a different sector number, it can try to avoid a complete rotation
after a seek to an adjacent track. On modern SCSI disks, there is little or no correlation between block number and the actual layout of the disk. This is due to using a variable number of sectors per track to increase the storage capacity of the drive.
For SCSI disks, this parameter should be 0. For ESDI, MFM, and SMD disks, vary this parameter while writing a large file to try to achieve the optimum performance from the drive.
<BR></P>
<H4 ALIGN="CENTER">
<CENTER><A ID="I32" NAME="I32">
<FONT SIZE=3><B>Making File Systems with </B><B><I>newfs</I></B>
<BR></FONT></A></CENTER></H4>
<P>So you have decided on an appropriate file system type for the slice and have determined approximately what order of magnitude of inodes will be required. Now it is time to actually make the file systems. This task is controlled by the newfs utility on
Solaris. newfs uses the information in the label to choose appropriate defaults for the file system.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>Use the -Nv option of newfs to display what it is going to do first. Then you can tune the parameters. Once you like the results, just edit the command line and delete the N flag, and newfs will make
the file system, showing you what it did.
<BR></NOTE>
<HR ALIGN=CENTER>
<PRE># newfs -Nv /dev/rdsk/c0t3d0s7
/dev/rdsk/c0t3d0s7:</PRE>
<P>newfs reports the name of the partition you passed to it and its size from the label. It then passes the arguments to mkfs. Because it is computing all of the arguments, it passes them as a direct vector in a compact format. mkfs does allow a simpler
argument format if you have to run it yourself.
<BR></P>
<PRE>mkfs -F ufs -o N /dev/rdsk/c0t3d0s7 228816 72 14 8192 1024 16 10 90 2048 t 0 -1 8 -1
228816 sectors in 227 cylinders of 14 tracks, 72 sectors
111.7MB in 15 cyl groups (16 c/g, 7.88MB/g, 3776 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 16240, 32448, 48656, 64864, 81072, 97280, 113488, 129696,
145904, 162112, 178320, 194528, 210736, 226944,</PRE>
<P>See the next section on mkfs for the meaning of the output from mkfs.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="caution.gif" WIDTH = 37 HEIGHT = 35><B>CAUTION:</B> Keep a hard copy of the output from the newfs command in a safe place. One of the times you run it with the -N flag, redirect the output to the printer. You will need the information if you ever
have a disk failure or severe system crash where you need to use the alternate super-block list for recovery. In addition, you will have a record of the parameters you used if you decide to rebuild the file system later to tune the number of inodes.
<BR></NOTE>
<HR ALIGN=CENTER>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="imp.gif" WIDTH = 68 HEIGHT = 35><B>TIP: </B>To tune the number of inodes, you cannot directly enter the number but must vary the number of bytes per inode using the -i parameter. The default value is 2048. This is a good value for file systems
with many small files and a few big ones. If the file system has a large number of symbolic links or very small files, you might want to drop this a bit. If it has mostly larger files, increase it.
<BR></NOTE>
<HR ALIGN=CENTER>
<H4 ALIGN="CENTER">
<CENTER><A ID="I33" NAME="I33">
<FONT SIZE=3><B>Making File Systems with </B><B><I>mkfs</I></B>
<BR></FONT></A></CENTER></H4>
<P>Unixware does not use the newfs command; it was a Berkeley-derived command. It requires you to directly invoke mkfs. This isn't as bad as it seems because most of the parameters shown in the prior section on newfs would have been computed by default by
mkfs anyway.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I34" NAME="I34">
<FONT SIZE=3><B>Making </B><B><I>ufs</I></B><B> File Systems</B>
<BR></FONT></A></CENTER></H5>
<P>The only required options to mkfs are the file system type, character special device name, and the size in sectors of the file system to be built. The remaining options will all default. However, these defaults do not come from the label. Running the
same partition through mkfs with default values yields the following:
<BR></P>
<PRE># mkfs -F ufs -o N /dev/rdsk/c0t3d0s7 228816
Warning: 48 sector(s) in last cylinder unallocated
/dev/rdsk/c0t3d0s7:
228816 sectors in 447 cylinders of 16 tracks, 32 sectors
111.7MB in 28 cyl groups (16 c/g, 4.00MB/g, 1920 i/g)</PRE>
<P>Notice that it chose the default values of 16 tracks per cylinder (heads) and 32 sectors per track. To make the layout optimum for the disk, use the parameters nsect and ntrack.
<BR></P>
<PRE># mkfs -F ufs -o N,nsect=72,ntrack=14 /dev/rdsk/c0t3d0s7 228816
/dev/rdsk/c0t3d0s7:
228816 sectors in 227 cylinders of 14 tracks, 72 sectors
111.7MB in 15 cyl groups (16 c/g, 7.88MB/g, 3776 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 16240, 32448, 48656, 64864, 81072, 97280, 113488, 129696,
145904, 162112, 178320, 194528, 210736, 226944,</PRE>
<P>This produces the same output as the newfs command.
<BR></P>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="caution.gif" WIDTH = 37 HEIGHT = 35><B>CAUTION:</B> As mentioned earlier under newfs, keep a hard copy of the output from the mkfs command in a safe place. One of the times you run it with the -N flag, redirect the output to the printer. You will
need the information if you ever have a disk failure or severe system crash where you need to use the alternate super-block list for recovery. In addition, you will have a record of the parameters you used if you decide to rebuild the file system later to
tune the number of inodes.
<BR></NOTE>
<HR ALIGN=CENTER>
<P>As the caution states, one of the important pieces of output produced by mkfs is the list of backup super-blocks. If some disk error destroys or
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -