21.3 C
New York
Friday, June 24, 2022
HomeLinuxHow to Repair File System Errors in Debian Based Systems

How to Repair File System Errors in Debian Based Systems

In Linux, using heavy hardware components can be checked and recovered. Specifically, on Ubuntu and Debian systems, finding out the hard-disk bad sectors is easy. Once your hard disk or drive gets some bad sectors or gets corrupted, it gets spread day by day. On Ubuntu and other Debian Linux machines, you can use a few tools or commands to find out the file system errors and repair the errors. Not fixing errors or bad sectors might make your system boot slower and can also affect initialization. 

Repair File System Errors in Debian Based Systems


Repairing file system errors means we need to locate in which sector there are issues, and then we need to investigate what type of errors are. If the file system errors are repairable, then we will proceed with a few tools and commands on our Debian system. One of the best tools for repairing file system errors is fsck for Linux. In this post, we will see how to repair file system errors in Ubuntu and other Debian distributions. 

Method 1: Use FSCK Command for Checking Errors


In Ubuntu, you can use the fsck command in the command-line shell that can check the file system consistency. This tool comes pre-installed with the Debian distribution. Please execute the following fdisk command first to get an overall idea about your file system on the Debian system. 

sudo fdisk -l

sudo fdisk -l Repair File System Errors in Debian

You may now need to unmount the file system that you want to repair. Without unmounting, you cannot repair or execute operations to repair file system errors in Debian and other distributions as well. But no worries about repairing and fixing; you can again mount the file system where it was. 

If you do not run the FSCk operations without mounting the file system you want to repair, it will show you an error.

sudo fsck /dev/sdb

mount fsck command run dev on sdb Repair File System Errors in Debian

$ sudo umount /dev/sdb3

You can now run the fsck command on the terminal shell to repair file system errors. 

fsck -p -y 
sudo fsck -p /dev/sdb3

The above process might take a while to complete. After finishing, please remount the file system with the following command. 

$ sudo mount /dev/sdb3

If you have a multi-user Debian system, you can execute the following command to check which user is currently executing the fsck command.

fsck /usr

Method 2: Run File Checking and Repairing on Boot 


If you find the fsck command useful for you and your system still has some bad sectors, you can run the fsck tool on your system every time you boot the system. In Debian, the below-mentioned command will allow you to check the errors of the file system and repair them when you boot the PC, as you can see that the command will execute a force fsck command on boot. 

$ sudo touch /forcefsck

If required, you can also set the above-mentioned forcefsck command to run every time you fire up the system. 

$ sudo touch /forcefsck
$ sudo tune2fs -c 1 /dev/sdb3 

In another way, if you think that executing every time on the boot is too much, you can set it after every three system reboots. This will also help you to understand the situation of how bad the errors are in your Debian system. 

$ sudo tune2fs -c 3 /dev/sdb3

For getting more help and syntaxes about the FSCK tool, you can always go through the command manual. 

$ man fsck

Method 3: Reboot To Repair Errors in File System 


This method will guide you to do a manual checkup of the file system on your Debian system to find out the errors and repair them. In this method, we will originally run the fsck command in recovery mode for better repair. First, reboot your system and go into recovery mode. Pressing the Shift button will help you to go into recovery mode. 

recovery mode Repair File System Errors in Debian

Once you are in recovery mode, select the fsck tool and press OK from the keyboard. Then it will ask you to set the mount point in read/write mode. Please complete this section to go to the fsck repairing mode. When you set the mount point, it will automatically run the fsck command on the system and repair file system errors in your Debian system. 

recovery mode FSCK mode

After you finish the process, you can now reboot your system and start using the system. 

Final Words 


If you’ve been a keen Ubuntu user, you might have noticed that while you install the Ubuntu OS on your machine, Ubuntu automatically runs a file system check while installing it. Many users may cancel the automatic file system checking by pressing Ctrl + C, but letting this procedure happen would be good before installing the OS. However, in the entire post, we have seen a few methods on how to repair file system errors in Debian-based systems. 

Please share it with your friends and the Linux community if you find this post useful and informative. You can also write down your opinions regarding this post in the comment section.

Jahid Onik
Jahid Onik
He has completed his Electrical and Electronic Engineering graduation from a well-reputed University. He has been working as a data analyst for the past few years. He has been using Ubuntu since 2014.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Post

Must Read