📄 proc.txt
字号:
This subdirectory contains specific file system, file handle, inode, dentryand quota information.Currently, these files are in /proc/sys/fs:dentry-state------------Status of the directory cache. Since directory entries are dynamicallyallocated and deallocated, this file indicates the current status. It holdssix values, in which the last two are not used and are always zero. The othersare listed in table 2-1.Table 2-1: Status files of the directory cache .............................................................................. File Content nr_dentry Almost always zero nr_unused Number of unused cache entries age_limit in seconds after the entry may be reclaimed, when memory is short want_pages internally ..............................................................................dquot-nr and dquot-max----------------------The file dquot-max shows the maximum number of cached disk quota entries.The file dquot-nr shows the number of allocated disk quota entries and thenumber of free disk quota entries.If the number of available cached disk quotas is very low and you have a largenumber of simultaneous system users, you might want to raise the limit.file-nr and file-max--------------------The kernel allocates file handles dynamically, but doesn't free them again atthis time.The value in file-max denotes the maximum number of file handles that theLinux kernel will allocate. When you get a lot of error messages about runningout of file handles, you might want to raise this limit. The default value is4096. To change it, just write the new number into the file: # cat /proc/sys/fs/file-max 4096 # echo 8192 > /proc/sys/fs/file-max # cat /proc/sys/fs/file-max 8192 This method of revision is useful for all customizable parameters of thekernel - simply echo the new value to the corresponding file.The three values in file-nr denote the number of allocated file handles, thenumber of used file handles, and the maximum number of file handles. When theallocated file handles come close to the maximum, but the number of actuallyused ones is far behind, you've encountered a peak in your usage of filehandles and you don't need to increase the maximum.inode-state, inode-nr and inode-max-----------------------------------As with file handles, the kernel allocates the inode structures dynamically,but can't free them yet.The value in inode-max denotes the maximum number of inode handlers. Thisvalue should be 3 to 4 times larger than the value in file-max, since stdin,stdout, and network sockets also need an inode struct to handle them. If youregularly run out of inodes, you should increase this value.The file inode-nr contains the first two items from inode-state, so we'll skipto that file...inode-state contains three actual numbers and four dummy values. The numbersare nr_inodes, nr_free_inodes, and preshrink (in order of appearance).nr_inodes~~~~~~~~~Denotes the number of inodes the system has allocated. This can be slightlymore than inode-max because Linux allocates them one pageful at a time.nr_free_inodes--------------Represents the number of free inodes and preshrink is nonzero when nr_inodesis greater than inode-max and the system needs to prune the inode list insteadof allocating more.super-nr and super-max----------------------Again, super block structures are allocated by the kernel, but not freed. Thefile super-max contains the maximum number of super block handlers, wheresuper-nr shows the number of currently allocated ones.Every mounted file system needs a super block, so if you plan to mount lots offile systems, you may want to increase these numbers.2.2 /proc/sys/fs/binfmt_misc - Miscellaneous binary formats-----------------------------------------------------------Besides these files, there is the subdirectory /proc/sys/fs/binfmt_misc. Thishandles the kernel support for miscellaneous binary formats.Binfmt_misc provides the ability to register additional binary formats to theKernel without compiling an additional module/kernel. Therefore, binfmt_miscneeds to know magic numbers at the beginning or the filename extension of thebinary.It works by maintaining a linked list of structs that contain a description ofa binary format, including a magic with size (or the filename extension),offset and mask, and the interpreter name. On request it invokes the giveninterpreter with the original program as argument, as binfmt_java andbinfmt_em86 and binfmt_mz do. Since binfmt_misc does not define any defaultbinary-formats, you have to register an additional binary-format.There are two general files in binfmt_misc and one file per registered format.The two general files are register and status.Registering a new binary format-------------------------------To register a new binary format you have to issue the command echo :name:type:offset:magic:mask:interpreter: > /proc/sys/fs/binfmt_misc/register with appropriate name (the name for the /proc-dir entry), offset (defaults to0, if omitted), magic, mask (which can be omitted, defaults to all 0xff) andlast but not least, the interpreter that is to be invoked (for example andtesting /bin/echo). Type can be M for usual magic matching or E for filenameextension matching (give extension in place of magic).Check or reset the status of the binary format handler------------------------------------------------------If you do a cat on the file /proc/sys/fs/binfmt_misc/status, you will get thecurrent status (enabled/disabled) of binfmt_misc. Change the status by echoing0 (disables) or 1 (enables) or -1 (caution: this clears all previouslyregistered binary formats) to status. For example echo 0 > status to disablebinfmt_misc (temporarily).Status of a single handler--------------------------Each registered handler has an entry in /proc/sys/fs/binfmt_misc. These filesperform the same function as status, but their scope is limited to the actualbinary format. By cating this file, you also receive all related informationabout the interpreter/magic of the binfmt.Example usage of binfmt_misc (emulate binfmt_java)-------------------------------------------------- cd /proc/sys/fs/binfmt_misc echo ':Java:M::\xca\xfe\xba\xbe::/usr/local/java/bin/javawrapper:' > register echo ':HTML:E::html::/usr/local/java/bin/appletviewer:' > register echo ':Applet:M::<!--applet::/usr/local/java/bin/appletviewer:' > register echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register These four lines add support for Java executables and Java applets (likebinfmt_java, additionally recognizing the .html extension with no need to put<!--applet> to every applet file). You have to install the JDK and theshell-script /usr/local/java/bin/javawrapper too. It works around thebrokenness of the Java filename handling. To add a Java binary, just create alink to the class-file somewhere in the path.2.3 /proc/sys/kernel - general kernel parameters------------------------------------------------This directory reflects general kernel behaviors. As I've said before, thecontents depend on your configuration. Here you'll find the most importantfiles, along with descriptions of what they mean and how to use them.acct----The file contains three values; highwater, lowwater, and frequency.It exists only when BSD-style process accounting is enabled. These valuescontrol its behavior. If the free space on the file system where the log livesgoes below lowwater percentage, accounting suspends. If it goes abovehighwater percentage, accounting resumes. Frequency determines how often youcheck the amount of free space (value is in seconds). Default settings are: 4,2, and 30. That is, suspend accounting if there is less than 2 percent free;resume it if we have a value of 3 or more percent; consider information aboutthe amount of free space valid for 30 secondsctrl-alt-del------------When the value in this file is 0, ctrl-alt-del is trapped and sent to the initprogram to handle a graceful restart. However, when the value is greater thatzero, Linux's reaction to this key combination will be an immediate reboot,without syncing its dirty buffers.[NOTE] When a program (like dosemu) has the keyboard in raw mode, the ctrl-alt-del is intercepted by the program before it ever reaches the kernel tty layer, and it is up to the program to decide what to do with it.domainname and hostname-----------------------These files can be controlled to set the NIS domainname and hostname of yourbox. For the classic darkstar.frop.org a simple: # echo "darkstar" > /proc/sys/kernel/hostname # echo "frop.org" > /proc/sys/kernel/domainname would suffice to set your hostname and NIS domainname.osrelease, ostype and version-----------------------------The names make it pretty obvious what these fields contain: > cat /proc/sys/kernel/osrelease 2.2.12 > cat /proc/sys/kernel/ostype Linux > cat /proc/sys/kernel/version #4 Fri Oct 1 12:41:14 PDT 1999 The files osrelease and ostype should be clear enough. Version needs a littlemore clarification. The #4 means that this is the 4th kernel built from thissource base and the date after it indicates the time the kernel was built. Theonly way to tune these values is to rebuild the kernel.panic-----The value in this file represents the number of seconds the kernel waitsbefore rebooting on a panic. When you use the software watchdog, therecommended setting is 60. If set to 0, the auto reboot after a kernel panicis disabled, which is the default setting.printk------The four values in printk denote* console_loglevel,* default_message_loglevel,* minimum_console_level and* default_console_loglevelrespectively.These values influence printk() behavior when printing or logging errormessages, which come from inside the kernel. See syslog(2) for moreinformation on the different log levels.console_loglevel----------------Messages with a higher priority than this will be printed to the console.default_message_level---------------------Messages without an explicit priority will be printed with this priority.minimum_console_loglevel------------------------Minimum (highest) value to which the console_loglevel can be set.default_console_loglevel------------------------Default value for console_loglevel.sg-big-buff-----------This file shows the size of the generic SCSI (sg) buffer. At this point, youcan't tune it yet, but you can change it at compile time by editinginclude/scsi/sg.h and changing the value of SG_BIG_BUFF.If you use a scanner with SANE (Scanner Access Now Easy) you might want to setthis to a higher value. Refer to the SANE documentation on this issue.modprobe--------The location where the modprobe binary is located. The kernel uses thisprogram to load modules on demand.2.4 /proc/sys/vm - The virtual memory subsystem-----------------------------------------------The files in this directory can be used to tune the operation of the virtualmemory (VM) subsystem of the Linux kernel. In addition, one of the files(bdflush) has some influence on disk usage.bdflush-------This file controls the operation of the bdflush kernel daemon. It currentlycontains nine integer values, six of which are actually used by the kernel.They are listed in table 2-2.Table 2-2: Parameters in /proc/sys/vm/bdflush .............................................................................. Value Meaning nfract Percentage of buffer cache dirty to activate bdflush ndirty Maximum number of dirty blocks to write out per wake-cycle nrefill Number of clean buffers to try to obtain each time we call refill nref_dirt buffer threshold for activating bdflush when trying to refill buffers. dummy Unused age_buffer Time for normal buffer to age before we flush it age_super Time for superblock to age before we flush it
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -