{"id":385,"date":"2011-06-02T14:26:49","date_gmt":"2011-06-02T19:26:49","guid":{"rendered":"http:\/\/www.serverprontouniversity.com\/?p=385"},"modified":"2018-11-06T01:43:46","modified_gmt":"2018-11-06T06:43:46","slug":"run-file-system-check-in-linux-unix","status":"publish","type":"post","link":"https:\/\/www.serverpronto.com\/spu\/2011\/06\/run-file-system-check-in-linux-unix\/","title":{"rendered":"Run File System Check in Linux \/ UNIX"},"content":{"rendered":"<pre># fsck<\/pre>\n<div id=\"abw\">\n<div id=\"abm\">\n<div id=\"abc\">\n<div id=\"articlebody\"><strong>fsck<\/strong> is used to check and optionally repair one or more Linux file systems.<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"abw\">\n<div id=\"abm\">\n<div id=\"abc\">\n<div id=\"articlebody\">\n<p>If no filesystems are specified on the command line, and the&nbsp;<strong>-A <\/strong>option is not specified,&nbsp;<strong>fsck <\/strong>will default to checking filesystems in&nbsp;<strong>\/etc\/fstab<\/strong> serial. This is equivalent to the&nbsp;<strong>-As <\/strong>options.<\/p>\n<p>The exit code returned by&nbsp;<strong>fsck<\/strong> is the sum of the following conditions:<br \/>\n0 &#8211; No errors<br \/>\n1 &#8211; File system errors corrected<br \/>\n2 &#8211; System should be rebooted<br \/>\n4 &#8211; File system errors left uncorrected<br \/>\n8 &#8211; Operational error<br \/>\n16 &#8211; Usage or syntax error<br \/>\n32 &#8211; Fsck canceled by user request<br \/>\n128 &#8211; Shared library error<br \/>\nThe exit code returned when multiple file systems are checked is the bit-wise OR of the exit codes for each file system that is checked.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Options<\/strong><\/span>:<\/p>\n<div id=\"abw\">\n<div id=\"abm\">\n<div id=\"abc\">\n<div id=\"articlebody\">\n<dl>\n<dt><strong>-s<\/strong><\/dt>\n<dd>Serialize&nbsp;<strong>fsck <\/strong>operations. This is a good idea if you are checking multiple filesystems and the checkers are in an interactive mode. (Note:&nbsp;<strong><a href=\"http:\/\/linux.about.com\/library\/cmd\/blcmdl8_e2fsck.htm\">e2fsck<\/a><\/strong>(8) runs in an interactive mode by default. To make&nbsp;<strong><a href=\"http:\/\/linux.about.com\/library\/cmd\/blcmdl8_e2fsck.htm\">e2fsck<\/a><\/strong>(8) run in a non-interactive mode, you must either specify the&nbsp;<strong>-p<\/strong> or&nbsp;<strong>-a<\/strong> option, if you wish for errors to be corrected automatically, or the <strong>n<\/strong> option if you do not.)<\/dd>\n<dt><strong>-t<\/strong><em> fslist<\/em><\/dt>\n<dd>Specifies the type(s) of the file system to be checked. When the&nbsp;<strong>-A <\/strong>flag is specified, only filesystems that match&nbsp;<em>fslist<\/em> are checked. The&nbsp;<em>fslist<\/em> parameter is a comma-separated list of filesystems and options specifiers. All of the filesystems in this comma-separated list may be prefixed by a negation operator &#8216;<strong>no<\/strong>&#8216; or &#8216;<strong>!<\/strong>&#8216;, which requests that only those filesystems not listed in&nbsp;<em>fslist<\/em> will be checked. If all of the filesystems in<em>fslist<\/em> are not prefixed by a negation operator, then only those filesystems listed in<em>fslist<\/em> will be checked. Options specifiers may be included in the comma-separated&nbsp;<em>fslist<\/em>. They must have the format&nbsp;<strong>opts=<\/strong><em>fs-option<\/em>. If an options specifier is present, then only filesystems which contain&nbsp;<em>fs-option<\/em> in their mount options field of&nbsp;<strong>\/etc\/fstab<\/strong> will be checked. If the options specifier is prefixed by a negation operator, then only those filesystems that do not have&nbsp;<em>fs-option<\/em> in their mount options field of&nbsp;<strong>\/etc\/fstab <\/strong>will be checked.<\/p>\n<p>For example, if&nbsp;<strong>opts=ro<\/strong> appears in&nbsp;<em>fslist<\/em>, then only filesystems listed in&nbsp;<strong>\/etc\/fstab<\/strong>with the&nbsp;<strong>ro<\/strong> option will be checked.<\/p>\n<p>For compatibility with Mandrake distributions whose boot scripts depend upon an unauthorized UI change to the&nbsp;<strong>fsck<\/strong> program, if a filesystem type of&nbsp;<strong>loop<\/strong> is found in<em>fslist<\/em>, it is treated as if&nbsp;<strong>opts=loop<\/strong> were specified as an argument to the&nbsp;<strong>-t<\/strong> option.<\/p>\n<p>Normally, the filesystem type is deduced by searching for&nbsp;<em>filesys<\/em> in the&nbsp;<em>\/etc\/fstab <\/em>file and using the corresponding entry. If the type can not be deduced, and there is only a single filesystem given as an argument to the&nbsp;<strong>-t <\/strong>option,&nbsp;<strong>fsck<\/strong> will use the specified filesystem type. If this type is not available, then the default file system type (currently ext2) is used.<\/dd>\n<dt><strong>-A<\/strong><\/dt>\n<dd>Walk through the&nbsp;<em>\/etc\/fstab<\/em> file and try to check all file systems in one run. This option is typically used from the&nbsp;<em>\/etc\/rc<\/em> system initialization file, instead of multiple commands for checking a single file system. The root filesystem will be checked first unless the&nbsp;<strong>-P<\/strong> option is specified (see below). After that, filesystems will be checked in the order specified by the&nbsp;<em>fs_passno <\/em>(the sixth) field in the&nbsp;<em>\/etc\/fstab<\/em> file. Filesystems with a&nbsp;<em>fs_passno<\/em> value of 0 are skipped and are not checked at all. Filesystems with a&nbsp;<em>fs_passno<\/em> value of greater than zero will be checked in order, with filesystems with the lowest&nbsp;<em>fs_passno <\/em>number being checked first. If there are multiple filesystems with the same pass number, fsck will attempt to check them in parallel, although it will avoid running multiple filesystem checks on the same physical disk.<\/p>\n<p>Hence, a very common configuration in&nbsp;<em>\/etc\/fstab<\/em> files is to set the root filesystem to have a&nbsp;<em>fs_passno<\/em> value of 1 and to set all filesystems to have a&nbsp;<em>fs_passno<\/em> value of 2. This will allow&nbsp;<strong>fsck<\/strong> to automatically run filesystem checkers in parallel if it is advantageous to do so. System administrators might choose not to use this configuration if they need to avoid multiple filesystem checks running in parallel for some reason &#8212; for example, if the machine in question is short on memory so that excessive paging is a concern.<\/dd>\n<dt><strong>-C<\/strong><\/dt>\n<dd>Display completion\/progress bars for those filesystems checkers (currently only for ext2) which support them. Fsck will manage the filesystem checkers so that only one of them will display a progress bar at a time.<\/dd>\n<dt><strong>-N<\/strong><\/dt>\n<dd>Don&#8217;t execute, just show what would be done.<\/dd>\n<dt><strong>-P<\/strong><\/dt>\n<dd>When the&nbsp;<strong>-A<\/strong> flag is set, check the root filesystem in parallel with the other filesystems. This is not the safest thing in the world to do since if the root filesystem is in doubt things like the&nbsp;<strong>e2fsck <\/strong>(8) executable might be corrupted! This option is mainly provided for those sysadmins who don&#8217;t want to repartition the root filesystem to be small and compact (which is really the right solution).<\/dd>\n<dt><strong>-R<\/strong><\/dt>\n<dd>When checking all file systems with the&nbsp;<strong>-A<\/strong> flag, skip the root file system (in case it&#8217;s already mounted read-write).<\/dd>\n<dt><strong>-T<\/strong><\/dt>\n<dd>Don&#8217;t show the title on startup.<\/dd>\n<dt><strong>-V<\/strong><\/dt>\n<dd>Produce verbose output, including all file system-specific commands that are executed.<\/dd>\n<dd><\/dd>\n<dd><\/dd>\n<dd><em>For more information visit: <a href=\"http:\/\/linux.about.com\/od\/commands\/l\/blcmdl8_fsck_.htm\">http:\/\/linux.about.com\/od\/commands\/l\/blcmdl8_fsck_.htm<\/a><\/em><\/dd>\n<dd><a href=\"https:\/\/www.serverpronto.com\">ServerPronto<\/a> offers the best affordable and secure hosting service in all dedicated server packages.<\/dd>\n<\/dl>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p># fsck fsck is used to check and optionally repair one or more Linux file systems. If no filesystems are specified on the command line, and the&nbsp;-A option is not specified,&nbsp;fsck will default to checking filesystems in&nbsp;\/etc\/fstab serial. This is equivalent to the&nbsp;-As options. The exit code returned by&nbsp;fsck is the sum of the following<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[123,17,112,22,18],"class_list":["post-385","post","type-post","status-publish","format-standard","category-support-of-the-day","tag-cloud","tag-dedicated-server","tag-hosting","tag-server","tag-web-hosting"],"_links":{"self":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts\/385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/comments?post=385"}],"version-history":[{"count":6,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts\/385\/revisions"}],"predecessor-version":[{"id":3094,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/posts\/385\/revisions\/3094"}],"wp:attachment":[{"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/media?parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/categories?post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serverpronto.com\/spu\/wp-json\/wp\/v2\/tags?post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}