Jump to content

How to Repair a Damaged Filesystem in Ubuntu


aum

Recommended Posts

The reputation of the various Linux operating system distributions speaks for itself. These prime operating system environments continue to be secure, open-source, open to frequent software updates, and are embraced by a growing user community and developers’ support.

 

However, these Linux OS attributes and stripes do not guarantee a bulletproof status. Sometimes you do not have control of what happens or what will happen to your Linux OS filesystem.

 

A Linux filesystem tends to get damaged or corrupted due to unavoidable circumstances like the unsafe removal of a media or drive hosting the Linux OS, instantaneous system crashes, and unexpected power losses.

 

How to Repair Ubuntu Filesystem


When victimized by filesystem damage or corruption on a Linux system, a user’s first instinct is usually to install a fresh copy of the operating system.

 

The inconvenience of this approach is that you could spend unnecessary hours backing up your data and reinstalling the Linux OS when a quick solution could be right in front of a terminal. Ubuntu is well-equipped with terminal-based tools that can quickly repair/fix a damaged/corrupted filesystem.

 

The most ideal tool for this job is the fsck (file system consistency check) utility. However, using the fsck command on a mounted filesystem is highly discouraged as it might result in additional damages to those files.

 

We, therefore, have the option of attempting an on-boot repair of the damaged filesystem.

 

Create a Bootable Ubuntu USB Drive


Download an Ubuntu OS ISO file and use it to create a bootable USB drive. This bootable USB drive should have the Ubuntu OS image inside it. A straightforward tool for this job is balenaEtcher.

 

Once you created a bootable Ubuntu USB drive, connect to the machine and restart your machine and press the boot devices to associate keys e.g. F12, to reveal a boot menu.

 

Ubuntu-Boot-Menu.png

Ubuntu Boot Menu

 

Trace the menu option associated with the USB/CD-ROM drive and press [Enter]. It will boot your Ubuntu into Live mode, here go with the Try Ubuntu option.

 

Try-Ubuntu-Option.png

Try Ubuntu Option

 

You will be logged in to an Ubuntu desktop environment (Live CD approach). From here, you will have more control of your initial Ubuntu OS installation and its associated filesystem.

 

Ubuntu-Live-Boot-Desktop.jpeg

Ubuntu Live Boot Desktop

 

At this point, we are comfortable enough to start executing the needed commands that will help us to identify the associated filesystem partitions to repair our damaged filesystem.

 

$ sudo fdisk -l

 

Find-Ubuntu-Filesystem-Partitions.png

Find Ubuntu Filesystem Partitions

 

In this case, the targeted filesystem partition with Ubuntu installation is /dev/sda5.

 

Repair Ubuntu Filesystem Using Fsck Command

 

First, unmount the filesystem partition you suspect is damaged. In most cases, it is usually unmounted but we need to be certain:

 

$ sudo umount /dev/sda5


To trace and repair the possibility of any file damages on this filesystem partition, we need to execute the following fsck command.

 

$ sudo fsck -p /dev/sda5

 

Repair-Ubuntu-Filesystem.png

Repair Ubuntu Filesystem

 

You can re-use the above fsck command syntax with other Linux filesystems you suspect to be damaged.

 

From here, you can comfortably exit the terminal and restart your computer to default to the originally installed Ubuntu OS version.

 

Boot-Ubuntu-OS.png

Boot Ubuntu OS

 

If your Ubuntu OS filesystem had any fixable issues or file damages, they should now be resolved.

 

Ubuntu-Login.png

Ubuntu Login

 

Being able to repair your damaged Ubuntu filesystem through this approach saves you from the headache of having to backup data and re-install your Linux OS. This methodology is efficient such that you don’t have to deal with filesystem partition mount issues while running FSCK.

 

Source

Link to comment
Share on other sites


  • Views 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

  • aum

    1

Popular Days

Top Posters In This Topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...