Recently my Linux desktop computer can’t mount my 5TB external hard disk drive (HDD), and the file manager displays the “can’t read superblock” error on the screen. I’m going to share with you what I did to fix the error, so if you are in the same situation, this article may help you.

How to Fix “can’t read superblock” Error on Linux (ext4 & Btrfs) Desktop Linux GNU-Linux

But before doing that, I want to explain some basic knowledge about hard disk drives and filesystems on Linux, so you will really know what you are doing. If you don’t care about those details, you can jump directly to the solution. A hard disk drive (HDD) is magnetic disk. A solid-state drive (SSD) is electronic disk.

The Structure of Hard Disk Drive

A hard disk drive usually has several circular platters stacked vertically with a spindle that rotates the disk in the center. Each platter is coated with a magnetizable material to record data. Each platter surface is divided into tens of thousands of tracks. It’s like running tracks in sports.

How to Fix “can’t read superblock” Error on Linux (ext4 & Btrfs) Desktop Linux GNU-Linux

Hint: Hard disk drives are very complex devices and can be easily damaged if you drop them to the ground.

Each track is divided into sectors. There are typically hundreds of sectors per track and each sector usually has the same length. A sector is the smallest unit for reading data from the disk. That is to say, even if you just need a portion of the data from a sector, the read-write head will read the entire sector to retrieve the data. Traditionally one sector stores 512 bytes of data. In 2009 the industry devised the 4K sector size format known as the advanced format to improve disk reliability and increase capacity. After January 2011, most new hard drives store 4096 bytes of data in one sector.

Physical Sector Size vs Logical Sector Size

Although new hard drives use the 4K advanced format, operating systems still expect a 512 bytes sector size, so the firmware on the HDD divides a 4K physical sector into several logical sectors, typically 512 bytes. On Linux, you can check the physical sector size and logical sector size of an HDD with the fdisk command.

fdisk -l /dev/sda

You can see from the screenshot that the physical sector size of my hard disk is 4096 bytes and the logical sector size is 512 bytes. I/O size is the minimal chunks of data the operating system reads from a disk.

How to Fix “can’t read superblock” Error on Linux (ext4 & Btrfs) Desktop Linux GNU-Linux

Partition Alignment

Using firmware to produce a logical sector can degrade performance, especially when file system partitions are not aligned with physical sectors. There are two requirements for partition alignment:

  • The number of sectors on each partition must be in multiples of 8 because a physical sector contains 8 logical sectors.
  • The start sector of each partition must be the first logical sector in a physical sector. Since sector 0 is the first sector of the entire disk, this means the start sector of each partition should be a multiple of 8, sector 0, sector 8, sector 16, etc.

When you create partitions on a hard disk drive, you should be aware of the following two partition tables.

  • MBR: Master Boot Record.
  • GPT: GUID Partition Table.

If you buy a new hard disk, it’s recommended to use the newer GPT format to partition your hard disk. Both MBR and GPT will use some sectors at the beginning of the disk, so you should leave some empty space (like 1MiB) before the first partition.  To create partitions that will be aligned with the physical sector, use sector as the unit when you partition your disk.

You can quickly check if your disk partitions are aligned with physical sectors with the parted (partition editor) utility. parted is a disk partition editor that supports multiple partition table formats, including MBR and GPT.

First, tell parted to use your disk. I use my/dev/sdb as an example.

parted /dev/sdb

Then type p to print the partition table on the disk. And run the following command to check partition alignment.

align-check opt partition-number

Type q to quit.

As you can see from the screenshot below, the first two partitions are not properly aligned. The third partition is aligned.

How to Fix “can’t read superblock” Error on Linux (ext4 & Btrfs) Desktop Linux GNU-Linux

SSD Partition Alignment

Note that the structure of SSD is very different than that of an HDD. The smallest unit of an SSD module is called a cell. Consecutive cells form a page, many of which are organized into a block. Read and write operations are executed at the page level. The page size of an SSD varies from manufacturer to manufacturer and from model to model. There’s no straightforward way to check page size using the Linux command line, because the flash translation layer makes the OS think the SSD is a traditional hard disk. The OS doesn’t understand SSD pages and still uses sectors to describe locations on SSD.

Common page sizes are 8KiB, 16KiB, 32KiB. It’s also very important to have aligned partitions on SSD. If partitions are misaligned, then there will always be one extra page to read or write. Not only will it degrade performance, but also decreases the life span of SSD. To properly align partitions on SSD, all you need to do is to leave one empty page at the start of SSD and make sure the size of every partition on SSD is multiples of the page size.

Blocks in Filesystem

There’s a concept in filesystem called block, which is similar to a sector on disk drives. Many folks are confused by these two concepts. It’s not really that hard to understand the difference. When you create a partition on a disk, you can use sectors to define its size. If you format a partition with a file system, blocks will be created.

Operating system and file system access data on the disk in blocks rather than in sectors. A block is usually a multiple of sector. So why don’t we just access data in sectors? Well, the block can abstract away the physical details of the disk. If you address a sector (find out the address of a sector), you need to use the CHS scheme (cylinder-head-sector). This is because a hard disk drive has multiple platters. You need to know which platter and track the sector is located at. If you address a block, you just use block 0, block 1, block 2, etc, without having to know the physical details of the disk. Each block is mapped to a sector (or several sectors) with the logical block addressing (LBA) scheme.

Superblock

The first block of a disk or of a partition is called the superblock, and it’s the primary superblock. Superblock can be damaged like in a sudden power outage, so there are backup copies of the superblock in a block group.

  • primary superblock
  • backup superblock

Can’t read superblock

There can be several reasons why your OS can’t read the superblock on your HDD.

  • The HDD is dropped to the ground and the superblock is damaged. This is usually physical damage to the corresponding sectors on the disk.
  • There’s a sudden power outage. Because the superblock is cached in RAM, if a power outage happens, there might be important changes to the superblock that hasn’t been written to the disk.

How to Fix “can’t read superblock” Error on Linux (ext4 & Btrfs) Desktop Linux GNU-Linux

If the primary superblock is damaged, you can’t mount the filesystem, and the operating system will probably tell you that it “can’t read superblock” if you try to mount the filesystem. We need to recover the bad superblock from backup copies. The following instructions show how to recover superblock for ext4 and Btrfs file system. My HDD is an external hard disk. If the damaged filesystem is your root file system, you need to boot your computer from a Linux Live USB stick.

Recover superblock on ext4 filesystem

Find out the device name of the damaged partition.

sudo parted -l

Determine the location of the backup superblocks.

sudo mke2fs -n /dev/xxx

It will tell you that the partition contains an ext4 file system, press y to continue. Don’t worry the -n option tells mke2fs not to create a file system.

mke2fs 1.45.5 (07-Jan-2020)
/dev/sdb1 contains a ext4 file system labelled 'Stretch'
	last mounted on /media/linuxbabe/b43e4eea-9796-4ac6-9c48-2bcaa46353732 on Thu Jan 28 02:43:43 2021
Proceed anyway? (y,N) y
Creating filesystem with 7864320 4k blocks and 1966080 inodes
Filesystem UUID: fcae3dc8-ee11-412c-97f0-27106601314e
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000

At the bottom, you can see the location of backup superblocks. Next, restore the superblock from the first backup copy.

sudo e2fsck -b 32768 /dev/xxx

Now you should be able to mount your ext4 partition.

Recover superblock on btrfs filesystem

Find out the device name of the damaged partition.

sudo parted -l

Then run the following command to recover superblock.

sudo btrfs rescue super-recover -v /dev/xxx

If it tells you “All supers are valid, no need to recover”, then check the syslog.

sudo dmesg

You might find the following message, which indicates the log tree is corrupted, so it can’t replay the log.

BTRFS: error (device sdb1) in btrfs_run_delayed_refs:2227: errno=-5 IO failure
BTRFS: error (device sdb1) in btrfs_replay_log:2287: errno=-5 IO failure (Failed to recover log tree)

Then you need to run the following command to clear the filesystem log tree.

sudo btrfs rescue zero-log /dev/xxx

How to Fix “can’t read superblock” Error on Linux (ext4 & Btrfs) Desktop Linux GNU-Linux

Now you should be able to mount your Btrfs file system.

Backing Up Files on your Disk

To prevent data loss, it’s recommended to use a tool like Duplicati to automatically back up your files to cloud storage. Duplicati will encrypt your files to prevent prying eyes.

Wrapping Up

I hope this tutorial helped you fix the “can not read superblock” error on Linux. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial

[Total: 2 Average: 5]