Home Ubuntu How to Repair File System Errors in Ubuntu

How to Repair File System Errors in Ubuntu

Whether you are an experienced Linux administrator or an elite Linux user, dealing with Linux file system errors can be a headache for anyone. However, this headache has a valid prescription if you can pinpoint or identify the filesystem partition that is causing your Linux OS to have performance issues.

Most Linux operating systems come preconfigured with the fsck (file system check) terminal-based utility. This file repair tool requires that the immediate Linux user be familiar with the basic understanding and usage of the Linux command line environment and its associated commands.

FSCK Usage

The standard syntax for fsck command-line utility is as follows:


To comfortably use fsck utility without running into any issues, you need to be a root or Sudoer user on your Ubuntu system. Sudo privileges are necessary for the correct execution of the fsck command.

There are a number of important rules to follow before attempting file system repair using the fsck command.

  • Use the fdisk -l command to identify the existing OS system partition labels associated with the filesystem you are interested in repairing.
  • Unmount the filesystem partition you identified from the above step (umount /dev/sdx) to give fsck full diagnosis and repair power on any identifiable OS file system issues.
  • Execute the fsck command (fsck -p) on the unmounted filesystem partition.
  • Remount the filesystem partition and reboot your machine if necessary.

How to Use FSCK to Repair Ubuntu File System Errors

There are two approaches to fixing file system errors on a Ubuntu partition using the fsck utility.

Repairing Ubuntu Non-Root File System Partitions

Non-root file systems do not require you to reboot your Ubuntu OS to attempt file system repair from the Grub menu’s Advanced Options. It can be an OS file system existing on an external USB drive.

1. From your terminal environment, identify the device name with the corrupted file system you wish to repair using the following command:

$ sudo fdisk -l 
Identify Ubuntu Filesystem
Identify Ubuntu Filesystem

From my end, I have identified the file system partition I am interested in as /dev/sdb3.

2. Make sure that this file system partition is unmounted.

$ sudo umount /dev/sdb3

3. Attempt file system partition repair using the fsck utility command. The -p option will automatically attempt file system repair on any identifiable broken OS files.

$ sudo fsck -p /dev/sdb3
Repair Ubuntu Partition
Repair Ubuntu Partition

As expected, the command was executed successfully as per the above fsck command output.

4. Now that the fsck command is through with fixing the file system partition, it is time to remount it.

$ sudo mount /dev/sdb3

Repairing Ubuntu Root File System Partition

Since you cannot unmount an active file system, it is impossible to attempt filesystem repair using fsck on a running OS. However, this step is achievable when the operating system is booting. We just need to instruct the OS to run an FSCK check and attempt file repair when the system restarts.

1. Force fsck to run once during system restart by creating the following file on your root (/forcefsck) OS file system will achieve this objective.

$ sudo touch /forcefsck

FSCK is forced to run once your system restarts. However, this file is deleted by the OS once fsck finishes executing. You will need to create it each time you want to attempt file system repair during reboot.

2. Force fsck to run after specified system reboots, this option is a more permanent solution.

$ sudo tune2fs -c 2 /dev/sda2

From the above command, the filesystem partition /dev/sda2 will be scanned and repaired after every 2 system boots. You can set this value to any positive integer value like 9 or 15.

File system errors can be a nightmare for any OS user and might even force you to reinstall your operating system. Learning how to deal with them saves you precious time and improves your OS productivity and experience.

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.

Got something to say? Join the discussion.

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.