home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / alt_os / mint / mfs6011 / source / docs / fsck.doc < prev    next >
Text File  |  1995-01-01  |  8KB  |  151 lines

  1. Fsck is a File System Consistency checKer. It checks Minixfs filesystems for
  2. consistency and optionally repairs them too. It is important that a Minixfs
  3. filesystem is checked for errors when, for example, the system crashes or a
  4. lock up forces a reboot when programs are using the filesystems. This will
  5. occasionally mean that fsck will perform minor repairs which will cause no
  6. damage at all. Using a damaged filesystems can result in much more serious
  7. damage occuring at a later date which require more destructive repairs to
  8. fix.
  9.  
  10. ADVICE ON USE OF FSCK
  11.  
  12. fsck cannot perform miracles; a severely damaged filesystem (such as if a lot
  13. of sectors get wiped somehow) may have very little salvageable. However, don't
  14. be overwhelmed by the options available. In practice only fsck -n or fsck on
  15. its own are used, the -p option is useful in shell scripts where non-interactive
  16. repair is needed, but you dont want any attempted destructive repair.
  17.  
  18. If fsck -n does produce what appear like a lot of serious errors then it might
  19. be an idea to attempt to backup the data before trying repairs; of course if
  20. you have a full backup (you do make regular backups don't you?) available it
  21. might be best to forget about repair altogether and just reinitialize the
  22. filesystem (with minit) and restore from backup.
  23.  
  24. USING FSCK
  25.  
  26. Fsck can be used in interactive or non-interactive mode. In interactive mode
  27. you are prompted before each fix. In non-interactive mode, repairs are carried
  28. out automatically or not at all. The option '-y' carries out all repairs that
  29. fsck would suggest, the '-p' (preen) option carries out all repairs if the
  30. Minixfs filesystems is only slighlty damaged and can be repaired without
  31. destroying data, the '-n' option only prints out the damage: it does not
  32. repair anything. The '-y' option is not recommended, unless you are sure it
  33. is what you want.
  34.  
  35. The options are followed by the drive letter of the partition you want to
  36. check for example,
  37. fsck -p D:
  38.  
  39. REPAIRS CARRIED OUT
  40.  
  41. In order to know precisely what repairs are carried out you must know a litle
  42. about the internal structure of a Minixfs filesystem. Each filesystem is
  43. divided into blocks or zones, these are always 1K in size.
  44.  
  45. Each directory/file/symbolic link has an inode associated with it. This is
  46. a small part of a disk sector which carries all information about a file
  47. except its name. It contains the file access modes (including what kind of
  48. entity the inode refers to) as well as it's size and a list of sectors where
  49. the file can be found. If this list is not large enough then an 'indirection
  50. block' which is a disk block containing a list of further blocks belonging to
  51. the file is used (and recorded in the inode). If this is not enough then a
  52. 'double indirection block' is used containing a list of further indirection
  53. blocks. With this information, all the data in a file can be accessed.
  54.  
  55. A directory is basically identical to a file except it has a different mode
  56. number. The 'data' in this file is a list of 'entries' (or links) each entry
  57. contains a filename and an inode number where that name can be found. The root
  58. directory is always contained in inode 1. A field in the inode called it's
  59. 'link count' gives a count of the number directory entries that refer to it.
  60. Every directory has two filenames '.' which refers to itself and '..' which
  61. refers to the parent directory. The only exception is the root directory where
  62. '..' refers to itself as well.
  63.  
  64. Each used inode/block is referenced in a bitmap. If the filesystem crashes
  65. before this can be written out to disk then it will be inaccurate. Fortunately
  66. fsck can rebuild the bitmaps from the data contained in inodes. This is what
  67. the prompts asking about bitmap repair mean. They are harmless and it is
  68. strongly advised that any bitmap repairs suggested are made.
  69.  
  70. If you use the filesystem and some used blocks do not have their bits set in
  71. the bitmap then other files can use them, overwriting the original data. These
  72. are called 'multiply allocated blocks'. fsck will give a list of these blocks
  73. and (optionally) allow you to decide which inode is the valid block. Usually
  74. the valid data is contained in the file with the latest modify time: the '-y'
  75. option removes all of the references. By finding the files the inodes
  76. refer to (e.g. with the -i option) you can look to see which file
  77. contains the valid data and then interactively remove the other references.
  78. The other files where the references are removed then have 'holes' in them,
  79. you may want to try to recover them or just delete them after 'fsck' has done
  80. its work. This is why it is important that the bitmaps are accurate and should
  81. be checked regularly.
  82.  
  83. This is the 'best case' scenario of multiply allocated blocks. If the block
  84. overwritten belongs to a directory then much more trouble is caused. After
  85. deleting the overwritten reference in a directory lots of inodes may no
  86. longer be referenced in a directory, these are called 'orphaned' inodes (they
  87. have no parent directory). fsck has no way of knowing their original names,
  88. but the data is recoverable. fsck makes entries for these inodes in a
  89. directory called lost+found . The name chosen is simply the inode number. You 
  90. can then analyse the files/directories in lost+found and delete, rename or move 
  91. them to where they were originally.
  92.  
  93. The worst case is if an indirection block is overwritten. This can cause lots
  94. of spurious messages about bad zone numbers and other multiply allocated blocks.
  95. fsck cannot currently help much under such circumstances: if a certain inode
  96. contains lots of multiple block number or bad zone numbers then it's best to
  97. delete all multiply allocated blocks in that inode; either with fsck or finding
  98. the inode on the disk and deleting the associated file.
  99.  
  100. Here is a summary of the possible repairs fsck performs:
  101.  
  102. 1. Scan all inodes, allow deletion of multiply allocated blocks, inodes with
  103. bad modes, truncation of inodes which reference too many zones.
  104.  
  105. 2. Scan all directories, check for valid names and the existance of '.' and
  106. '..' entries and allow fixing.
  107.  
  108. 3. Check filesystem conectivity (that each inode has a directory entry) and
  109. allow repair of any problems and reconnection of orphaned inodes.
  110.  
  111. 4. Check bitmaps and repair; check inode link counts and allow repair.
  112.  
  113. MISCELLANEOUS OPTIONS
  114.  
  115. If the root directory gets destroyed it must be handled separately because the
  116. lost+found directory will be killed also. If this is the case then the '-R'
  117. option will reform the root directory. Unfortunately the directory increment
  118. is determined from the root directory, so you must manually tell fsck the
  119. directory increment with the '-d' option followed by the increment. If you
  120. get this wrong then a large number of errors about directory entries will
  121. be erroneously reported.
  122.     If for some reason the root inode is no longer a directory Minixfs
  123. may get confused and not  recognise the filesystem anymore. By asking fsck to
  124. continue it will still check the root inode as though it were a directory: if
  125. it looks OK fsck allows you to make it a directory again. However you will
  126. have to reboot before the filesystem will be recognised by Minixfs again.
  127.  
  128.     The '-i' option followed by a comma separated list of numbers will
  129. print out the pathnames of the corresponding inodes. E.g. fsck -i 1,2,3 D:
  130. This will print out *all* the possible names so e.g. fsck -i 1 d: may
  131. give something like:
  132.  
  133. \.
  134. \..
  135. \dir\..
  136. \dir2\..
  137. etc.
  138.  
  139.     The '-z' option allows an inode to be zeroed if for example it is
  140. severely trashed and fixing would do more harm than good (e.g. if an
  141. indirection block has been overwritten). -z may be followed by a comma
  142. separated list of inodes to zero. NB use this option with extreme caution,
  143. the data the inode refers to will be effectively deleted (it will still be
  144. on the disk but no longer accessible directly). Using this option will also
  145. cause related "errors" to appear (though all can be fixed) such as inode
  146. and bitmap errors and links a free inode.
  147.  
  148.     The '-e' option tries to find out the filesystem size by reading
  149. as far as it can through a partition: this is an experimental option and
  150. isn't too useful at present.
  151.