Why need fsck




















The options are d ays, w eeks, or m onths. Let's say that you want fsck to run any time that you boot if there hasn't been a check in a week. You could use -i to specify the interval and the command would look like this. You can always turn to the man-pages for more information. Just use man fsck in the terminal. I hope you learned something new about the fsck command. If you have any comments or questions, please leave them below.

Please enter at least 3 characters 0 results found. Christopher Murray. Linux systems come with a command line utility fsck to check for file system errors.

Learn how to use it. Table of Contents. Sometimes bad things happen to good systems. Introduction to the fsck command The fsck command follows a pattern similar to most Linux commands. You will need to run the command either as root user or use it with sudo. Understanding exit codes for the fsck command This is a list of the codes that may be returned from fsck after inspecting a disk. Practical usage of the fsck command Now that you are a tad bit familiar with the fsck command, let's see practical use cases of this command.

Repair the root file system You cannot unmount the root partition while the system is active. Most modern Linux versions feature a tool called tune2fs. Do not run fsck on a mounted filesystem!

If you run fsck on a filesystem that is currently mounted, at best you receive an error message, and at worst corrupt your filesystem data. If you're going to check your filesystem with fsck , drop into single-user mode and make sure the filesystem is unmounted before you proceed.

These instructions should help you bring your Linux system into single-user mode and unmount any filesystems you want to check with fsck. First, initiate runlevel 1 single-user mode with the init command:. Now unmount the filesystem using umount. Make sure to run umount for any filesystem you want to check with fsck. Check all configured filesystems. Systems with a pass value of 0 are skipped; the system with a pass value of 1 is listed first, and remaining systems are checked in ascending order of their pass value.

View all filesystems that can be checked with fsck. Filesystems appear as extensions to the fsck. Normally, fsck skips parts of the filesystem marked as "clean" — meaning all pending writes were successfully made. The -f "force" option specifies that fsck should check parts of the filesystem even if they are not "dirty".

The result is a less efficient, but a more thorough check. Home Help Linux. Description Syntax Examples Related commands Linux commands help. Warning Do not run fsck on a mounted filesystem! Was this page useful? Lock the whole-disk device by an exclusive flock. This option can be used with one device only this means that -A and -l are mutually exclusive.

This option is recommended when more fsck instances are executed in the same time. The option is ignored when used for multiple devices or for non-rotating disks. Serialize fsck operations. This is a good idea if you are checking multiple filesystems and the checkers are in an interactive mode. Note: e2fsck runs in an interactive mode by default.

To make e2fsck run in a non-interactive mode, you must specify the -p or -a option, if you want for errors to be corrected automatically, or the -n option if you do not. Before you begin with using the command, make sure you are working on an unmounted partition. To unmount a partition and then run fsck on it type :. In that case, you may choose one of the following methods.

This is probably the best way to run fsck. It provides a rich set of familiar tools like fdisk. Use this tutorial to create a live Ubuntu USB. However, for the purpose of this article, the name of the partition is sufficient. Another way to use the fsck command is while in the intramfs mode. To get into initramfs. The partitions are not mounted in initramfs, so performing fsck would be safe.

Also, you need the name of the partition. Initramfs, however, provides a bare minimum of utilities. You can list the partitions using the cat command as shown below:.



0コメント

  • 1000 / 1000