1. Home
  2. Linux
  3. Fix corrupted home partition on linux

How to fix a corrupted home partition on Linux

The home directory is the lifeblood of every Linux user’s operating system setup, as it handles just about every configuration file, personal data file, terminal configuration, and even esoteric things like command-line history and profile picture data.

These days, the home directory isn’t just a folder in a root partition. Instead, more and more, we see Linux operating systems placing user’s home directory onto their hard drive partition. For the most part, this is a good idea, as it separates user files from the operating system and keeps it safe. However, things can go wrong, and partitions can get corrupted.

If you’re dealing with a corrupted home partition and looking to fix it so you can gain access to your data, this guide is for you. Follow along and learn how to fix a corrupted home partition on Linux.

Note: though this guide focuses on cleaning home partitions, the same instructions can be applied to those who have their home directory on the Root partition as well.

Create a live disk

The home partition on your Linux PC is in use when you load up your operating system, so it’s not possible to run any fix tools to remove the “dirty bits” likely causing your home partition to be inaccessible. As a result, you must create a Linux live disk to do the work from.

There isn’t an official Linux operating system suited for this kind of fix. However, we highly recommend creating a live disk using Ubuntu, as even if your home partition and the data on it is unrecoverable, you’ll be able to install the Ubuntu operating system and start over quickly. To learn how to create an Ubuntu Live Disk, follow the step-by-step instructions below.

Step 1: Head over to Ubuntu’s official website, and download the latest release of the operating system to a spare computer. Or, if you prefer going the stable route, download the latest LTS instead.

Step 2: To create an Ubuntu Live Disk, you’ll need a USB burning application. Click here to go to the Etcher website and download the newest version of the app to the same spare PC you downloaded Ubuntu onto.

Step 3: Launch the Etcher app on the spare PC, and plug in a USB flash drive of at least 4GB in size.

Step 4: Using Etcher, browse for the Ubuntu ISO file, and click the “Flash!” button to create a new live USB.

Step 5: Unplug the Ubuntu Live Disk from the spare PC and plug it into the Linux PC with the corrupt home partition.

Step 6: Reboot your Linux PC, load into the BIOS and configure it to boot from USB.

Step 7: When your Linux PC has loaded up Ubuntu, click the “Try Ubuntu” button to gain access to the live Ubuntu environment we’ll need to use to fix the corrupted home partition.

Fix the corrupted home partition

In this guide, the word”corrupted” means that the home partition has gone through some damage, due to unmounting incorrectly during a restart, or some other similar issue that causes it to be non-functioning or close to non-functioning.

Usually, when a partition is corrupted, the problem is that there are “dirty bits” on it. These dirty bits can cause problems, and if they’re severe, they can even prevent you from accessing data on the partition.

The quickest way to solve this problem is to use the Fsck tool. To use Fsck, start by opening up a terminal window on the Ubuntu Live disk by pressing Ctrl + Alt + T or Ctrl + Shift + T.  Once the terminal window is open, use the sudo -s command to gain a root shell, which will make entering system-level commands much easier.

sudo -s

Now that your terminal session has a root shell, run the lsblk command to view all storage devices connected to the computer. Look through and find out what the label of your home partition is. In this guide, the partition is /dev/sdb2.

Note: need help identifying hard drive partitions on Linux? Read our guide on the subject!

lsblk

Take the label of the home partition and pipe it into fsck to clean out the dirty bits and fix any errors. Be sure to add the “y” switch at the end to automatically accept prompts, as hundreds could appear and it is time-consuming to say yes to each one manually.

Note: change the /dev/sdb2 with the label of your home partition.

fsck /dev/sdb2 -y

Let the Fsck tool do its thing. If there are a lot of dirty bits, cleaning could take quite a long time. Just sit back and be patient. When the process is complete, close the terminal, and reboot your Linux PC. Upon login, your home folder should be fully accessible and not corrupt!

2 Comments

  1. Thank you so much. I nearly formatted my Zorin OS Partition. You saved me 💖💖

  2. THANK YOU! This fixed my partition and is up to date. I’m a newish linux user still experimenting, and this was the only tutorial that helped.