Introduction Show
The fsck (File System Consistency Check) Linux utility checks filesystems for errors or outstanding issues. The tool is used to fix potential errors and generate reports. This utility comes by default with Linux distributions. No specific steps or an installation procedure is required to use fsck. Once you load the terminal, you are ready to exploit the functionalities of the tool. Follow this guide to learn how to use fsck to check and repair filesystem on a Linux machine. The tutorial will list examples of how to use the tool and for which use cases. Prerequisites
When to Use fsck in LinuxThe fsck tool can be used in various situations:
Basic fsck SyntaxThe basic syntax for the fsck utility follows this pattern:
In the above example, There are a few steps to do before you check and repair your file system. You need to locate a device and unmount. View Mounted Disks and PartitionsTo view all mounted devices on your system and check disk location, use one of the available tools in Linux. One method to locate the disk you want to scan is to list the filesystem disks with the
The tool prints the data usage on your system and filesystems. Take note of the disk you want to check with the To view partitions for your first disk, for example, use the following command:
sda is how Linux refers to your first SCSI disk. If you have two, the second would be sdb, and so on. In our example, we got one result since there was only one partition on this virtual machine. You will get more results if you have more partitions. The disk name here is Unmount the DiskBefore you can run a disk check with Make sure to run the
Replace Note that you cannot unmount root filesystems. Hence, now Run fsck to Check for ErrorsNow that you unmounted the disk, you can run
The above example shows the output for a clean disk. If there are multiple issues on your disk, a prompt appears for each one where you have to confirm the action. The exit code the fsck utility returns is the sum of these states: Mount the DiskWhen you finish checking and repairing a device, mount the disk so you can use it again. In our case, we will remount the sdb disk:
Do a Dry Run with fsckBefore you perform a live check, you can do a test run with fsck. Pass the
The output prints what would happen but does not perform any actions. Fix Detected Errors Automatically with fsckTo try to fix potential problems without getting any prompts, pass the
This way, you say “yes, try to fix all detected errors” without being prompted every time. If no errors are found, the output looks the same as without the Skip Repair but Print fsck Errors in the OutputUse the We have a second drive sdb with some journaling errors. The
Force fsck to Do a Filesystem CheckWhen you perform a fsck on a clean device, the tool skips the filesystem check. If you want to force the filesystem check, use the For example:
The scan will perform all five checks to search for corruptions even when it thinks there are no issues. Run fsck on All Filesystems at OnceIf you want to perform a check on all filesystems with fsck in one go, pass the Since root filesystems can’t be unmounted on a running machine, add the
To avoid the prompts, add the Skip fsck on a Specific FilesystemIf you want fsck to skip
checking a filesystem, you need to add For example, to skip ext3 filesystem, run this command:
We added Skip Fsck on Mounted FilesystemsTo make sure you do not try to run fsck on a mounted filesystem, add the To show you the difference, we will run fsck on sdb while it is mounted, and then when we unmount it.
While sdb is mounted, the tool exits without running a check. Then, we
unmount sdb and run the same command again. This time, Note: To remove the first title line of the fsck tool “fsck from util-linux 2.31.1” use the Run fsck on Linux Root PartitionAs we already mentioned, fsck cannot check root partitions on a running machine since they are mounted and in use. However, even Linux root partitions can be checked if you boot into recovery mode and run the fsck check: 1. To do so, power on or reboot your machine through the GUI or by using the terminal:
2. Press and hold the shift key during boot-up. The GNU GRUB menu appears. 3. Select Advanced options for Ubuntu. 4. Then, select the entry with (recovery mode) at the end. Let the system load into the Recovery Menu. 5. Select fsck from the menu. 6. Confirm by selecting <Yes> at the prompt. 7. Once finished, select resume at the recovery menu to boot up the machine. What if fsck is Interrupted?You should not interrupt the fsck tool while it is in progress. However, if the process is interrupted, fsck will finish the ongoing check and then stop. In case the utility found an error while the check was in process, it will not try to fix anything if interrupted. You can rerun the check next time and let it finish. fsck Linux Command Options SummaryTo wrap up, below is the list of the options you can use with the fsck Linux utility.
Conclusion Now you know how to use fsck Linux command to check and repair filesystems. The guide provided examples of the tool’s functionalities and features. Make sure you have root permissions before running the listed commands. For a detailed description of all options, you can consult the man file of the tool or visit the fsck Linux man page. What command would you use if you wanted a computer to drop its current IP address?At the flashing cursor, type ipconfig /release. This will release your IP address. Type ipconfig /renew to get a new IP address. Type exit to exit the command prompt.
What is the first step you should take to troubleshoot the issue?Troubleshooting methodologies vary, but the following seven steps are often used.. Gather information. ... . Describe the problem. ... . Determine the most probable cause. ... . Create a plan of action and test a solution. ... . Implement the solution. ... . Analyze the results. ... . Document the process.. What is the first step in the CompTIA troubleshooting model?The CompTIA troubleshooting methodology:. Identify the problem.. Establish a theory of probable cause.. Test the theory to determine the cause.. Establish a plan of action to resolve the problem and implement the solution.. Verify full system functionality, and, if applicable, implement preventive measures.. What is the first step in the CompTIA troubleshooting model quizlet?What is the first step in the CompTIA troubleshooting model? Identify the problem by gathering information.
|