📄 proc.txt
字号:
review the kernel documentation in the directory /usr/src/linux/Documentation.This chapter is heavily based on the documentation included in the pre 2.2kernels, and became part of it in version 2.2.1 of the Linux kernel.2.1 /proc/sys/fs - File system data-----------------------------------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 is10% of RAM in kilobytes. To change it, just write the new number into thefile: # 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.Historically, the three values in file-nr denoted the number of allocated filehandles, the number of allocated but unused file handles, and the maximumnumber of file handles. Linux 2.6 always reports 0 as the number of free filehandles -- this is not an error, it just means that the number of allocatedfile handles exactly matches the number of used file handles.Attempts to allocate more file descriptors than file-max are reported withprintk, look for "VFS: file-max limit <number> reached".inode-state and inode-nr------------------------The file inode-nr contains the first two items from inode-state, so we'll skipto that file...inode-state contains two actual numbers and five dummy values. The numbersare nr_inodes and nr_free_inodes (in order of appearance).nr_inodes~~~~~~~~~Denotes the number of inodes the system has allocated. This number willgrow and shrink dynamically.nr_free_inodes--------------Represents the number of free inodes. Ie. The number of inuse inodes is(nr_inodes - nr_free_inodes).aio-nr and aio-max-nr---------------------aio-nr is the running total of the number of events specified on theio_setup system call for all currently active aio contexts. If aio-nrreaches aio-max-nr then io_setup will fail with EAGAIN. Note thatraising aio-max-nr does not result in the pre-allocation or re-sizingof any kernel data structures.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 secondsaudit_argv_kb-------------The file contains a single value denoting the limit on the argv array sizefor execve (in KiB). This limit is only applied when system call auditing forexecve is enabled, otherwise the value is ignored.ctrl-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_loglevel 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--------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -