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

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.

can't read superblock

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.

can’t read superblock 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.

fdisk physical sector size logical sector size

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.

parted alignment check

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 (e.g. 32KiB) at the start of SSD and make sure the size of every partition on SSD is multiples of the page size.

When you use GParted to create the first partition on SSD, it automatically leaves 1MiB empty space before the first partition, which is 32 empty pages (32 KiB * 32 = 1024 KiB). This is fine. The following screenshot shows creating an EFI system partition (ESP) for a UEFI computer. The partition size is 512MiB with a FAT32 file system.

ssd partition alignment in gparted

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.

can't read superblock

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

For example, the device name of my HDD partition is /dev/sdb1, so I run

sudo mke2fs -n /dev/sdb1

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

Install a Btrfs utility.

sudo apt install btrfs-progs

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

btrfs rescue clear the filesystem log tree

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

If there’s periodic IO failure for your Btrfs file system, you can add a crontab job to automatically clear the file system log tree once a day.

sudo crontab -e

Add the following line at the end of the crontab file.

@daily umount /dev/xxx && btrfs rescue zero-log /dev/xxx && mount -a

Save and close the file.

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.

External HDD becomes Read-only?

Sometimes there can be error in the file system so Linux can only mount the external HDD in read-only mode. To fix it, you need to unmount the external HDD, then use the e2fsck command-line utility to fix the file system errors.

For example,

sudo e2fsck /dev/sdb1

then answer y to optimize or fix the file system, and you will be able to mount the external HDD in writable mode.

Tip

  • Some motherboards can still charge USB devices when you shut down the operating system. If you have an external HDD, it’s recommended to turn off electricity for USB devices when shut down, so your external HDD can stop spinning. This is good for its life span. For example, I have an ASUS PRIME z270 motherboard. I go to the UEFI advanced settings section and disable “charging USB devices in power state s5”.

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: 32 Average: 4.9]

44 Responses to “How to Fix “can’t read superblock” Error on Linux (ext4 & Btrfs)

  • Hi,
    Pretty good and easy.
    Thank you so much for the great topic,

  • Duffman
    4 years ago

    great infomation on hard drives.

    thank you

  • Very interesting, thank you 🙂

  • Shakyknees
    4 years ago

    Awesome coverage of the material. Best tutorialist in the linuxverse!

  • Chris Malan
    4 years ago

    In your ext4 instructions you have /dev/xxx twice–once for determining the location of and once for writing the backup superblock to the damaged superblock. In your example your damaged superblock is on /dev/sdb1. Shouldn’t it be /dev/xxxx? 4x instead of 3x?

    • Xiao Guoan (Admin)
      4 years ago

      Yes, my partition is /dev/sdb1 and the command should be

      sudo mke2fs -n /dev/sdb1

      If a partition spans the entire disk, you can use dev/sdb. You can always use /dev/sdb1 first. If mke2fs can’t find the partition, it will show an error.

    • sdb or xxx or sdc is the drive. 1 or 2 or 3 is the partition. So sdb1 would likely be the first partition on the second drive. sdd3 would be the third partition on the 4th drive (since d is the fourth letter from a). sdd would be the whole 4th disk.

  • Angello
    4 years ago

    Hi mr Xiao, is it possible somehow to recover the info of the hard drive if not possible to fix the superblock? thanks

  • Thank you so much! I installed Fedora 33 in a Western Digital Easystore 2647 5TB external drive. All was good till one day, after updating the Fedora software, the WD 5TB USB drive refused to boot. The disk has always been on my desk, never any physical damage. Thank you so much for this document. I thought all my family pictures (over 2TB) were lost …

  • Yes, this tutorial also saved my disk today. Thanks!

  • mark angeles
    3 years ago

    thank you very much, i feel lost when all of my memories on that hard disk cant recover! thank to this website
    !

  • Thank you very much for this tutorial. I had a USB flash drive that i could no longer mount and this repaired it and saved my data. Much appreciated!

  • LinuxUser
    3 years ago

    The most simple thing to do is simply not to use BTRFS. I have just migrated one of my OpenSUSE systems based on BTRFS to an Ubuntu one based on EXT4. I do not want to risk losing my work and files due to an unfinished filesystem.

  • Infotecnica
    3 years ago

    My problem seems to be more serious than it appears that no backup seems to work. Always get these errors and keep jumping endlessly to the next one.

    Error reading block xxxxx (Input/output error) while reading inode and block bitmaps. Ignore error?

    Problem that before I was still able to get into reading mode using.
    mount -o ro,noload /dev/vg/root /mnt

    But now returns the error

    root@rescue ~ # mount -o ro,noload /dev/vg/root /mnt
    mount: /mnt: mount(2) system call failed: Stale file handle.

    And I can no longer access local vg-root

    Can someone help me with any tips on how to solve

    • I got the same error as yours. I chose ignore error by pressing “y”, but then it asks me to rewrite, and I thought maybe it will rewrite my disk from fresh, and being afraid of losing my data, I closed my terminal. Now, when I am trying to open the contents of my disk, it says that “Device already mounted or resource is busy”
      I am of no help. Sorry! Let me know if you have any solution

      • # e2fsck -b 32768 /dev/sdb1
        e2fsck 1.46.2 (28-Feb-2021)
        Superblock needs_recovery flag is clear, but journal has data.
        Recovery flag not set in backup superblock, so running journal anyway.
        /dev/sdb1: recovering journal
        Error reading block 91379647 (Input/output error). Ignore error? yes
        Force rewrite? yes

        I made the same error, but I went ahead and do it, waited a long time now…

        Would not recommend anyone else try it. Here is my test data.

  • It’s good to know how it works. Great article.

  • Diku Khanikar
    3 years ago

    I followed the exact steps for ext4 files systems to the last but when I entered the last command and hit enter, it showed me:

    JBD2: Invalid checksum recovering data block 22020592 in log
    and a long list of almost the same with different block numbers. I have given an attachment regarding this… What should I do now? I pressed ‘yes’ for everything it asked me for…please help. All my important files are in the /dev/sda2. But can’t access. Please help.

  • Awesome. Truly awesome. Thank you so much. My problem was pretty serious as group counts were wrong and the command simply sorted it all out so that I could mount the drive. Great explanation also. Much appreciated.

  • AncientOne
    2 years ago

    Thank you very much.
    I was considering formatting my HDD, but thanks to you, I was able to recover without losing any data.
    Big thanks once again.

  • So so so awesome!

    This happened to my btrfs root file system earlier tonight. I was seconds away from giving up and letting the distro-hopper inside me nuke my machine when I found this. Saved my night!

  • Dan Masters
    2 years ago

    I have this problem after putting the computer in sleep mode. When I turned it back on it crashed and I got the bad superblock when trying to reboot. Using a Fedora live usb I tried following the instructions for btrfs, but when I tried to clear the log I got:

    Clearing log on /dev/sdb2, previous log_root 211910656, level 0
    ERROR: failed to write super block for devid 1: flush error: Input/output error
    ERROR: failed to write dev supers: Input/output error

    I also ran the read-only fix and that errored out as well. Can anyone help?

  • Pikachu
    2 years ago

    ~$ sudo e2fsck -b 163840 /dev/sda
    e2fsck 1.46.5 (30-Dec-2021)
    e2fsck: Invalid argument while trying to open /dev/sda

    The superblock could not be read or does not describe a valid ext2/ext3/ext4
    filesystem. If the device is valid and it really contains an ext2/ext3/ext4
    filesystem (and not swap or ufs or something else), then the superblock
    is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193
    or
    e2fsck -b 32768

  • fdisk -l /dev/sda
    a@a-MS-7B86:~$ fdisk -l /dev/sda
    fdisk: cannot open /dev/sda: Permission denied
    a@a-MS-7B86:~$ ^C
    a@a-MS-7B86:~$

  • i had power outage few days ago, i have parrot security OS on virtualbox after the outage it start load on initramfs mode i spend 2 days trying to fix this then i found this article.

    IT works!

    Thank you

  • Francisco
    2 years ago

    thank you. this article helped me save my hd.

  • Thank You very much. Your tutorial was perfect to solve my hdd-problem!

  • Potato brain
    2 years ago

    I can’t use sudo commands, it just says sudo not found

    • are you using debian? it need to install sudo, or just using root for the time bing

  • Bellatrix
    2 years ago

    really helpfull, thanks

  • Cowboy22
    2 years ago

    Thank You, THANK you, THANK YOU! Recovered my ext4 ssd in Linux Mint 20.3 using your method.

  • This was so helpful! Thank you for writing this up in so much detail! It saved my btrfs partition that had important data on it. Maybe its time to figure out a good backup solution.

  • The article reads “Don’t worry the -n option tells mke2fs not to create a file system.” THIS IS NOT TRUE ON MY VERSION OF mke2fs and CAUSED A LOSS OF ALL MY DATA, BEWARE

    • Linux manual page:

      -n

      Causes mke2fs to not actually create a filesystem, but display what it would do if it were to create a filesystem. This can be used to determine the location of the backup superblocks for a particular filesystem, so long as the mke2fs parameters that were passed when the filesystem was originally created are used again. (With the -n option added, of course!)

      note: is lower cause

  • Sajal Suraj
    1 year ago

    I am still getting errors. I want to mount an external HDD, it is not showing up in the system. I am using ubuntu 20.04.

    sajalsuraj@sajalsuraj-H110M-S2:~$ sudo e2fsck -b 32768 /dev/sdb
    e2fsck 1.45.5 (07-Jan-2020)
    e2fsck: Input/output error while trying to open /dev/sdb
    
    The superblock could not be read or does not describe a valid ext2/ext3/ext4
    filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
    filesystem (and not swap or ufs or something else), then the superblock
    is corrupt, and you might try running e2fsck with an alternate superblock:
        e2fsck -b 8193 
     or
        e2fsck -b 32768 
    
    

    Any help would be appreciated.

    • Maybe you’re supposed to do it on the partition /dev/sdb1 instead of the whole disk? Instructions in the article are unclear in that regard

  • This post was useful in my case, thank you very much!

    • Maybe you’re supposed to do it on the partition /dev/sdb1 instead of the whole disk? Instructions in the article are unclear in that regard

  • THANK YOU!

  • Thank you very much for this great tutorial.

  • WillSapgreen
    4 months ago

    Thank you very much for this great tutorial.

    Have you encountered that all backup superblocks are corrupted ( not working )?

    I tried all backup superblocks
    sudo e2fsck -b NUMBER /dev/xxx
    but still saw the same error message “can’t read superblock” when trying to mount.

    Thank you for your precious time on this question.

    • This is my case now. I’m afraid that when this happens the damage is massive so further actions are needed.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here