It’s possible for your filesystem to become so corrupted that you can’t repair it easily. In that case, you can repair your Linux filesystem with a live USB or DVD.
Your filesystem may become corrupted for any number of reasons. One of the most common reasons is an improper shutdown, where your filesystem doesn’t have time to properly write everything to disk because it wasn’t shut down properly. You might see that sort of thing when you suffer from a power outage.
There are any number of reasons why your filesystem will have become corrupted and, in most instances, your system will automatically repair your Linux filesystem when you boot your computer.
It’s also possible that a simple boot won’t repair your Linux filesystem. In that case, your OS probably has some sort of recovery mode and you can use that mode to repair your filesystem.
Once in a while, your filesystem may have become so corrupted that you can’t fix it in recovery mode because you can’t get to recovery mode to fix it. Not to worry. This is something you can easily do with a live USB or DVD.
This article assumes you already have a USB or DVD with an OS that runs live. I’ll use Ubuntu as the example OS, as it’s really common. Adjust for your distro and you’ll be okay.
Here’s a link if you need to know how to access your temporary boot menu.
NOTE: If you’re using Btrfs, you shouldn’t need to run fsck, it should heal itself. If not, here are Btrfs-specific commands that you should learn.
The first thing you’re going to do is boot to the USB or DVD. You’ll need to be patient as the live instance loads into RAM. Once the OS has loaded to a GUI, you’ll want to select “Try Ubuntu”. (Remember to adjust that for your own distro, should you not be using Ubuntu.)
Again, this will take a minute – especially on older hardware. Eventually, the GUI will load and you’ll have a functional live instance running. If you needed to use nomodeset, acpi=off, or anything similar, you’ll probably also need to use those things to get the live instance of Linux running.
The tool we’re going to use is known as ‘fsck‘, which is a tool in and of itself and a front end for other tools. fsck interacts with more specific tools for your specific filesystem, but that’s not important right now.
If you’re curious, fsck stands for ‘file system consistency check‘ and the man page helpfully describes it as:
fsck – check and repair a Linux filesystem
Now that you have a functional live desktop, it’s time to repair your Linux filesystem. The first step is, as is often the case, opening up your terminal. You can use your keyboard to do this, just press CTRL + ALT + T and a terminal should pop right up.
At this point, you’ll want to identify the correct disk. To do that, you run:
sudo fdisk -l
You’ll want to identify the disk where you installed Linux. That’s the disk that has the corrupted filesystem that is preventing you from booting. It’s often something like ‘/dev/sda1’ or maybe even ‘/dev/nvme0n1p1’.
Once you have the disk identified, it’s time to repair your Linux filesystem. Enter this:
sudo fsck -y /dev/sda*
NOTE: Change the /dev/sda* to match the data from the fdisk command you ran earlier.
That ‘fsck’ command should find and fix any errors automatically. If you really know what you’re doing, you can run ‘fsck’ manually and maybe do a better job than the automatic method. Then again, if you know that much then I’d suspect you don’t actually need this article.
This shouldn’t take very long to run, unless there were a whole lot of errors. Next, all you need to do is reboot and you should find that you were able to successfully repair your Linux filesystem. To do that from the terminal, you can just type:
reboot
When prompted, remove the disk from the drive and press the ENTER button.
There you have it, another way to run fsck and to repair your Linux filesystem when it is broken. This method works even when the recovery mode will have worked.
Thanks for reading! If you want to help, you can buy some cheap hosting, unblock ads, donate, sign up for the newsletter (below), write an article, leave a comment, register to help, or just vote for the article below and leave a comment!
Today we'll cover one way to enable or disable your network interface in the Linux…
Today's exercise is a nice and simple exercise where we check your NIC speed in…
Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…
I think I've covered this before with the ls command but this time we'll count…
Today we'll be learning about a basic Linux command that's known as 'uname' and it…
If you've used hardinfo in the past, it may interest you to know that hardinfo…