Home Debian How to Repair File System Errors in Debian

How to Repair File System Errors in Debian

The Debian Linux distribution laid down the foundation for the creation of other popular Linux operating system platforms like Ubuntu, Linux Mint, and Kali Linux. The community-supported development of this GNU/Linux distribution attributes it as free and open-source software.

Unfortunately, the prominence of the Linux operating system and its related distributions like Debian does not spare it from nagging file system errors. Fortunately, Linux ensures that you are never helpless when faced with such operating system performance challenges.

What Causes Linux File System Errors?

The consequential effect of file system errors is file system corruption. When the file system of your Linux operating system becomes corrupt, it implies that you might have traditioned yourself to improper shutdown of your system.

It is never a good idea to be turning off your computer with the power button unless your computer freezes. Properly turning off the computer through the shutdown command gives the file systems time to sync which later prevents improper startup procedures, NFS write errors, and hardware failures.

File system corruption can also result from the kernel’s software errors and improperly unmounting a mounted filesystem by suddenly taking it offline. Also, physically unmounting a running file system can be another cause of file system errors.

Handling File System Errors in Debian

Now that we know the root cause of file system errors, it’s time to prescribe an effective remedy to this problem. When faced with file system errors and challenges, there is one tool that is a recommended solution in almost all Linux distributions and its name is FSCK (File System Check).

The command syntax for the FSCK utility is as follows:

$ sudo fsck [Command_Options] [Targeted_Filesystem_Partition]

Using FSCK to Fix Non-Root File System Errors

When dealing with a non-root file system, the procedure to find and fix any filesystem error involves the following steps:

  • Identify the filesystem partition using the fdisk -l command.
  • Make sure the filesystem partition is unmounted using the umount command.
  • Run fsck command on the unmounted filesystem using fsck -p -y command.
  • If the filesystem is not automatically mounted back online, mount it using the mount command.

1. Identify the filesystem partition.

$ sudo fdisk -l
Find Filesystem Partitions in Debian
Find Filesystem Partitions in Debian

2. Unmount the filesystem partition.

$ sudo umount /dev/sdb3

3. Run the fsck command to fix file system errors on the partition.

$ sudo fsck -p /dev/sdb3

4. Remount the filesystem partition.

$ sudo mount /dev/sdb3

Using FSCK to Fix Root File System Errors

When dealing with root file systems, there are two approaches to consider:

Force FSCK to Run on System Boot

Approach 1: Force FSCK to execute one-time during system reboot on your Debian OS root file system by creating a file named forcefsck.

$ sudo touch /forcefsck

The creation of this file (forcefsck) forces the fsck utility to execute the next OS reboot. During the system reboot, fsck will scan, detect, and fix any evident file system errors. Once you login back into your machine, this file will have been deleted by the OS since it’s a one-time solution.

Force FSCK to Run on Every System Boot

With the following command, you can force FSCK to check and repair file system errors after every system reboot.

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

If you want file system errors to be scanned and fixed after every 3 system reboots, the associated command looks like the following:

$ sudo tune2fs -c 3 /dev/sdb3

You can even schedule file system errors scan and repair to occur after every 10 or 15 OS reboots.

The power of the FSCK utility speaks for itself. It is an efficient and reliable utility to use when you suddenly feel like your Linux operating system is showing symptoms of file system errors. More on its usage options can be found under the fsck man page.

$ man fsck
Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

3 thoughts on “How to Repair File System Errors in Debian”

Leave a Reply to Ravi Saive Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.