⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lsg18.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 4 页
字号:




<LI>Illegal entries in the i-node tables







<BR>







<BR>







<LI>Inconsistencies between i-node table size values and the disk space used by a file







<BR>







<BR>







<LI>Illegal values in files







<BR>







<BR>







<LI>Lost files that don't appear in the i-node table







<BR>







<BR>







</UL>







<P>The entire process occurs quickly, so there is no reason not to run fsck regularly. If fsck does report errors, shut down the system to superuser mode only and rerun fsck. The problem may have occurred because of a user application; this step identifies that type of problem. If the disk still has problems, you can correct them in superuser mode.







<BR>







<BLOCKQUOTE>







<BLOCKQUOTE>







<HR ALIGN=CENTER>







<BR>







<NOTE>In most cases, fsck runs only on unmounted filesystems (except root). If you want to check a filesystem, unmount it, and then run fsck. To check root, switch the system to single-user mode, and then run fsck. Although some versions of Linux don't require these steps, they are good safety precautions to prevent accidental changes to the disk or i-node tables.</NOTE>







<BR>







<HR ALIGN=CENTER>







</BLOCKQUOTE></BLOCKQUOTE>







<P>The fsck command takes the name of either the device or the mount point of the filesystem you want to check. For example, both of these command lines invoke fsck properly:







<BR>







<PRE>







<FONT COLOR="#000080">fsck /dev/sda1







fsck /usr</FONT></PRE>







<P>If fsck is working on several disk drives (because of mounting), it tries to work in parallel whenever possible to reduce the amount of time required for the disk checking.







<BR>







<P>A number of options are useful with fsck or its filesystem-specific versions. The options supported by most Linux systems that are commonly used by system administrators are as follows:







<BR>















<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-a







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option automatically repairs the filesystem without prompting you(use this option with care).</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-r







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option interactively repairs the filesystem (the system asks for instructions). Use it only when checking a single filesystem.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-t &lt;type&gt;







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option specifies the type of filesystems to check. If type is preceded by no, only the other types of filesystems are checked. This option uses the filesystem types from the /etc/fstab file.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-v







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







The option provides verbose output.</FONT>







</TABLE><P>Many other options are supported by fsck and its versions (like e2fsck), but a system administrator seldom (if ever) needs these other options. The fsck man page summarizes all the available options for you.







<BR>







<P>Get in the habit of running fsck occasionally, just to check the filesystem integrity. If you reboot often, the automated fsck checks the filesystem for you. But if you ever get disk error messages, fsck is the first place to turn.







<BR>







<BR>







<A NAME="E69E133"></A>







<H4 ALIGN=CENTER>







<CENTER>







<FONT SIZE=4 COLOR="#FF0000"><B>Displaying Filesystem Statistics</B></FONT></CENTER></H4>







<BR>







<P>Two commands are frequently used to check filesystem statistics (such as space used, space available, and so on). They are df (disk filesystem) and du (disk usage). Both commands are included with practically all versions of Linux.







<BR>







<P>The df command is the most widely used statistics generator for filesystems. It displays information about all the filesystems on the system, their total capacities, the amount of free space available on each, and the current mount locations. The following is an example of output from a df command:







<BR>







<PRE>







<FONT COLOR="#000080">merlin$ df







Filesystem 1024-blocks Used Available Capacity Mounted on







/dev/sda3 478792 94598 359465 21% /







/dev/sda1 511712 44288 467424 9% /dos







/dev/scd0 663516 663516 0 100% /cdrom</FONT></PRE>







<P>This system has a single SCSI hard disk with two partitions, one Linux and one DOS. The Linux partition /dev/sda3 has 478,792K total on the disk, of which 94,590K are used. The amount of disk space available is 359,465K. The Linux partition is 21 percent used. (Remember that a kilobyte is 1,024 bytes, so the numbers shown in the output are kilobytes.) Similarly, the DOS partition /dev/sda1 has only 9 percent of its 511,712K capacity used. The CD-ROM has 100 percent of its 663,516K used. It's mounted as /cdrom.







<BR>







<P>This command shows you a handy display of the capacity of all the Linux partitions on your system and their usage. If you are handy with utilities like awk, you can total the capacities and used space by adding the columns, which makes a handy single shell language utility. Some system administrators like to run this type of summary command in background every day and post the information to themselves through mail or a broadcast when they log in.







<BR>







<BLOCKQUOTE>







<BLOCKQUOTE>







<HR ALIGN=CENTER>







<BR>







<NOTE>You may occasionally see disk capacities in excess of 100 percent. This is caused by Linux holding back about 10 percent of the disk for the superuser's use exclusively, which means about 110 percent of the displayed capacity is available to root. Whenever the capacity approaches 100 percent, though, it's time to clear off the disk!</NOTE>







<BR>







<HR ALIGN=CENTER>







</BLOCKQUOTE></BLOCKQUOTE>







<P>A handy option of the df command shows similar information about the i-node tables:







<BR>







<PRE>







<FONT COLOR="#000080">merlin$ df -i







Filesystem Inodes IUsed IFree %IUsed Mounted on







/dev/sda3 123952 8224 115728 7% /







/dev/sda1 0 0 0 0% /dos







/dev/scd0 0 0 0 0% /cdrom</FONT></PRE>







<P>This display, from the same system as the df output above, shows the number of i-nodes available, how many are used, the number that remain free, and the percentage used. No correlation exists between disk space usage and i-node table usage, so you should display both sets of information. An i-node is used every time a file is used. If many small files are saved, the i-node table can fill up, but you may still have plenty of disk space for new files. Check both disk space usage and i-node table usage for maximum information.







<BR>







<P>The df command ignores any filesystems that have zero blocks in them unless you specify the -a or -all option. Filesystems with zero blocks are used occasionally for special purposes such as automounting particular devices. The df command also ignores any filesystems that have the filesystem options set to ignore in the /dev/fstab file (usually only swap files have this setting). By default, the df command displays all filesystems mounted on the system, unless you specify one particular filesystem, as in the following example:







<BR>







<PRE>







<FONT COLOR="#000080">merlin$ df







Filesystem 1024-blocks Used Available Capacity Mounted on







/dev/sda3 478792 94598 359465 21% /</FONT></PRE>







<BLOCKQUOTE>







<BLOCKQUOTE>







<HR ALIGN=CENTER>







<BR>







<NOTE>The df utility displays disk space in 1K blocks unless you set the environment variable POSIXLY_CORRECT in the system startup files. If this variable is set, 512-byte blocks are used to report information. This setting is helpful if you use an older filesystem type that uses disk sectors of 512 bytes.</NOTE>







<BR>







<HR ALIGN=CENTER>







</BLOCKQUOTE></BLOCKQUOTE>







<P>The df command provides a number of command-line options, most of which are supported in all Linux versions. The available options for df are in the following list:







<BR>















<TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-a, -all







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option includes all filesystems with zero blocks (usually special filesystems).</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-help







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option displays help information.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-i, -inode







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option displays i-node information.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-k, -kilobyte







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option displays disk space in 1K increments. (This option is used to override the environment variable set to 512 bytes blocks; see preceding note).</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-p







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option uses POSIX format to display all information of a filesystem on one line with no wrapping. If a filesystem name is longer than 20 characters, this option forces the columns to be misaligned.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-T







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option displays the type of filesystem in addition to disk usage information.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-t&lt;type&gt;







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option displays only filesystems whose type matches the one you specify.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-v







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option displays the version number.</FONT>







<TR>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







-x&lt;type&gt;







</FONT>







<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>







This option displays all filesystems not of the type you list.</FONT>







</TABLE><P>You can use most of these options in combination as you need them. You can embed the most frequently run commands in a shell script to be run whenever you want.







<BR>







<P>The du command also displays useful disk usage statistics. When run by itself, the du command displays the amount of disk space used by all files and subdirectories under any specified directory or the current directory if none other is listed (these excerpts have been edited to reduce space):







<BR>







<PRE>







<FONT COLOR="#000080">merlin$ du







125 /info/a_temp







4 /info/data







265 /info/data/book







726 /info/data/book/chap_1







2 /info/zookeeper







...







273263 /info







merlin$ du /usr/tparker







35 /usr/tparker/bin







2736 /usr/tparker/book







3 /usr/tparker/source







...







7326 /usr/tparker</FONT></PRE>







<P>The output from du shows each directory's disk usage in blocks in the first column and name of the directory in the second. You can usually convert the blocks in the first column directly to kilobytes used because most Linux filesystems use 1K blocks. (As with df, the du utility displays disk space in 1K blocks unless you set the environment variable POSIXLY_CORRECT in the system startup files.)







<BR>





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -