How to Fix fsck File System errors in Ubuntu?
Last Updated :
27 Sep, 2024
Experiencing file system errors on Ubuntu can be frustrating, but the fsck command in Ubuntu is a powerful tool that helps you fix these issues. If you're looking to fix fsck file system errors in Ubuntu, this guide will walk you through the steps of running fsck file system check and how to use it effectively to resolve file system errors in Ubuntu. By following these instructions, you can ensure that your system remains stable and your data is safe from corruption.
Prerequisites to fix fsck File System errors in Ubuntu
What is fsck in Ubuntu?
The fsck (file system consistency check) is a type of Linux utility that is used to check for filesystems for various types of errors and issues that may be present. The tool is mainly used for fixing errors and generating the reports for it. So in this article, we will understand this utility and its various commands.
How to Check and Repair File system?
to check and repair filesystem, First let's understand the basic syntax that is used for the fsck utility, following is the basic syntax for the fsck utility:
fsck <options> <filesystem>
There are various methods to check and fix errors in the Ubuntu system using the fsck utility lets understand each one by one.
Method 1: View Mounted Disks and Partitions
First, we will have to check whether the disks are mounted or not, for this we will have to run the following command:
df -h
This will give the following output:
Df -h command.To avoid this issue we will use the following command which will unmount the partition:
umount /dev/sdb
Note: This will not return anything but it will unmount the partition.
Understand the fsck Exit codes
Every time we run the fsck it will return an exit code so it is important to know the exit codes to have an understanding of what the return says, following are the exit codes with their description used in fsck:
Code | Description |
---|
0 | No errors. |
---|
1 | Filesystem errors corrected. |
---|
2 | The system should be rebooted. |
---|
4 | Filesystem errors were left uncorrected. |
---|
8 | Operational error. |
---|
16 | Usage or some type of syntax error. |
---|
32 | Checking canceled by the user through request. |
---|
128 | Shared-library error. |
---|
Running fsck for Checking Errors
Sometimes we may have to run the fsck on the partition which is also root in the system, since we can't run any of the fsck commands when the partition is mounted then we can use one of the following methods:
- Method 1: Force the fsck to the system root.
- Method 2: Run the fsck in the rescue mode.
Let's understand each of these methods one by one:
Method 1: Force the fsck to the system root
This is very easy as compared to the other method, in this we only have to create a file named “forcefsck” inside of the root partition of our system, for this, we will use the following command:
touch /forcefsck
This will give us the following output:
Touch/force fsck.Now you can use the various commands in the fsck to fix errors.
Method 2: Run the fsck in the rescue mode
This is a much lengthy process as compared to the 1st method, but still, let's understand how we can use this method to run the fsck tool:
Step 1: Run Reboot Command
- First, you need to reboot the system using the following command: reboot
Step 2: Open Advanced options
- Now once it's in boot you will have to hold the shift key until the GNU GRUB menu shows and then we will have to select the “Advanced options” from the menu.
Advanced options for Ubuntu.Step 3: Select Recovery Mode
- From this menu, we will have to select the recovery mode as you can see in the image below:
Recovery Mode in GNU GRUB.- Now from this recovery menu, you will have to select the fsck option.
fsck option.Step 5: Select the “Yes” option
- Now you will have to select the yes option from the option menu.
Select the “Yes” option.- This will lead us to the following menu, if you see a similar menu as well then you are not facing any errors.
fsck from util-linux.Fix the Detected Error Automatically
Now we will have to run the fsck command to check for errors, for this, we will use the following command:
sudo fsck /dev/sda3
Fix Detected Errors Automatically with fsck
We can also fix any errors that occur automatically by using the following command:
sudo fsck -y /dev/sda3
This will give us the following output: understand LinuxunderstandLinux
Fix Detected Errors Automatically.How to Skip Fsck on any Mounted Filesystems
If you want to skip any fsck for a specific filesystem from checking, then you will have to add -t and then you will add “no” before any particular filesystem, let's understand with an example, if we want to skip ext3 filesystem then we can run the following command for this:
sudo fsck -AR -t noext3 -y
Note: This will not return something but instead it will automatically skip fsck checks on any mounted filesystems.
Conclusion
Using the fsck command in Ubuntu is an essential part of system maintenance, especially when dealing with file system errors. Whether you need to run fsck on Ubuntu boot or perform a manual repair, understanding how to utilize fsck for file system repair will help you keep your system running smoothly. Make sure to run these checks periodically to avoid potential data loss or corruption in the future.
Similar Reads
How to Fix File System Error - 805305975?
Sometimes, a Windows File System Error (-805305975) may be encountered, and usually, it is created the moment you try to access the file, folder, or application. Sometimes, it may prevent access to some essential files or programs. It might get frustrating sometimes when you do not have an idea how
6 min read
How to Fix File System Error (-1073741819) in Windows 10?
Experiencing the file system error -1073741819 in Windows 10 can be frustrating, especially when it prevents you from running certain applications or performing essential tasks. This error typically occurs due to issues with system permissions, corrupted system files, or third-party software conflic
6 min read
What is Utweb.exe and How to Fix its System Errors
The Windows operating system might be the most sophisticated & most widely used OS. However, it is not free from any errors. The Windows operating system is well known for some infamous errors. Some errors on Windows can cause issues with the network, while some create issues with audio. The UTW
5 min read
How to Fix Terminal in Ubuntu?
Encountering issues with the Terminal in Ubuntu can disrupt your workflow and productivity. Whether the Terminal is not opening, displaying errors, or behaving unexpectedly, these problems can be frustrating. This guide will walk you through the most common solutions to fix Terminal issues in Ubuntu
3 min read
How to fix broken package in Ubuntu?
It can be very annoying when your package is broken in Ubuntu. But relax, itâs simple to fix with a few commands. For any Ubuntu user, having the ability to resolve package issues is an important skill in troubleshooting. You will quickly get your system back up and running if you take the time to l
5 min read
How to Fix System Errors in Windows Safe Mode?
If you're facing persistent system issues, using Windows Safe Mode is one of the most effective ways to fix system errors in Windows Safe Mode. Safe Mode is a diagnostic tool that starts your computer with minimal drivers and programs, allowing you to repair system issues in Safe Mode without interf
6 min read
How to Fix the "Too Many Open Files" Error in Linux
Encountering the "Too Many Open Files" error in Linux can be frustrating, especially when it disrupts your workflow or server operations. This error typically occurs when a process or system reaches its limit for open file descriptors, which are references to open files or resources such as sockets,
5 min read
Top 10 errors in R and how to fix them
R is a powerful language for statistical computing and graphics, but like any programming language, it comes with its own set of common errors that can trip up both novice and experienced users. Understanding these errors and knowing how to fix them can save a lot of time and frustration. Here are t
5 min read
How to fix GRUB Bootloader in Ubuntu?
The GRUB (Grand Unified Bootloader) bootloader is a crucial component of the Ubuntu operating system, responsible for loading the OS during the boot process. Encountering issues with the GRUB bootloader can prevent your system from starting correctly, leading to frustration and downtime. This guide
4 min read
How to Fix GRUB in Ubuntu?
One of the most important parts of Linux systems, including Ubuntu system software, is the GRUB (Grand Unified Bootloader), which controls the internal boot process. A live Linux distribution can be used to recover the overall Linux operating system if the GRUB bootloader has been corrupted or erase
4 min read