Linux: Recover Corrupted Partition From A Bad Superblock

Q. How can I Recover a bad superblock from a corrupted ext3 partition to get back my data? I’m getting following error:

/dev/sda2: Input/output error
mount: /dev/sda2: can’t read superblock

How do I fix this error?

A. Linux ext2/3 filesystem stores superblock at different backup location so it is possible to get back data from corrupted partition.

WARNING! Make sure file system is UNMOUNTED.

If your system will give you a terminal type the following command, else boot Linux system from rescue disk (boot from 1st CD/DVD. At boot: prompt type command linux rescue).

Mount partition using alternate superblock

Find out superblock location for /dev/sda2:
# dumpe2fs /dev/sda2 | grep superblock
Sample output:

  Primary superblock at 0, Group descriptors at 1-6
  Backup superblock at 32768, Group descriptors at 32769-32774
  Backup superblock at 98304, Group descriptors at 98305-98310
  Backup superblock at 163840, Group descriptors at 163841-163846
  Backup superblock at 229376, Group descriptors at 229377-229382
  Backup superblock at 294912, Group descriptors at 294913-294918
  Backup superblock at 819200, Group descriptors at 819201-819206
  Backup superblock at 884736, Group descriptors at 884737-884742
  Backup superblock at 1605632, Group descriptors at 1605633-1605638
  Backup superblock at 2654208, Group descriptors at 2654209-2654214
  Backup superblock at 4096000, Group descriptors at 4096001-4096006
  Backup superblock at 7962624, Group descriptors at 7962625-7962630
  Backup superblock at 11239424, Group descriptors at 11239425-11239430
  Backup superblock at 20480000, Group descriptors at 20480001-20480006
  Backup superblock at 23887872, Group descriptors at 23887873-23887878

Now check and repair a Linux file system using alternate superblock # 32768:
# fsck -b 32768 /dev/sda2
Sample output:

fsck 1.40.2 (12-Jul-2007)
e2fsck 1.40.2 (12-Jul-2007)
/dev/sda2 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #241 (32254, counted=32253).
Fix? yes

Free blocks count wrong for group #362 (32254, counted=32248).
Fix? yes

Free blocks count wrong for group #368 (32254, counted=27774).
Fix? yes
/dev/sda2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda2: 59586/30539776 files (0.6% non-contiguous), 3604682/61059048 blocks

Now try to mount file system using mount command:
# mount /dev/sda2 /mnt
You can also use superblock stored at 32768 to mount partition, enter:
# mount sb={alternative-superblock} /dev/device /mnt
# mount sb=32768 /dev/sda2 /mnt

Try to browse and access file system:
# cd /mnt
# mkdir test
# ls -l
# cp file /path/to/safe/location

You should always keep backup of all important data including configuration files.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 39 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
39 comments… add one
  • Gypsy Chief Apr 15, 2009 @ 0:18

    Well written article with lots of good information.
    Does any of this work on OpenBSD and the ffs
    file system?

    • JW0914 Apr 28, 2015 @ 16:18

      if using mount command on BSD OSs (FreeBSD, FreeNAS, etc), you will always receive the error in the OP as it’s not the proper syntax.

      To mount ext2 on BSD OSs, the correct command would be:

      mount -t ext2fs /dev/YourDevice /mnt/YourMountPoint

      Please refer to the ext2fs man page:

  • yakub pashas Jun 24, 2009 @ 14:08

    thank you very much for the valuable inforamation

  • tuxsun1 Aug 3, 2009 @ 22:49

    Lately I’ve noticed that when I Google on Linux questions, this site consistently returns the best or one of the best responses to what I was trying to solve. Because of that, I have signed up for your daily newsletter. Thanks for the great site!!

  • George Aug 21, 2009 @ 6:00

    Very good information.

  • Martin Sep 2, 2009 @ 21:26

    Awesome. Thanks.
    This is exactly what I needed instead of all the opinion with no solution.

  • Phillip Oct 7, 2009 @ 17:06

    Awesome. Worked Perfectly on RHEL5

  • Phillip Oct 7, 2009 @ 17:10

    Worked perfectly under RHEL5. Notes on my issue are below

    I was getting following error when mounting.
    Wrong fs type, bad option, bad superblock on /dev/sdd1
    missing codepage or other error
    In some cases usefull info is foinf in syslog – try
    dmesg | tail or so

    dmeg | tail displayed
    EXT3-fs: filesystem has both journal and inode journals!

    I tried useing the tune2fs -f -O ^has_journal /dev/sdd1 to remove the journal and try recreating but it did not work. tune2fs just hung there sucking 100% CPU when trying to remove the journal

    The command given here worked great.

  • rick Oct 29, 2009 @ 18:42

    Does not seem to work, when I run dumpefs all it says:

    “Bad magic number in super-block while trying to open…”

    I already know the superblock is bad.

  • ShadowCat8 Nov 2, 2009 @ 23:33

    Another way to cut to the quick of finding out where your superblocks should be after losing your primary is to use the following command:
    # mke2fs -n /dev/[device and partition number]
    This is making the utility you used to create the filesystem tell you where the backups are. You get a response similar to this:
    # mke2fs -n /dev/sdb1
    mke2fs 1.39 (29-May-2006)
    Filesystem label=
    OS type: Linux
    Block size=1024 (log=0)
    Fragment size=1024 (log=0)
    62248 inodes, 248976 blocks
    12448 blocks (5.00%) reserved for the super user
    First data block=1
    Maximum filesystem blocks=67371008
    31 block groups
    8192 blocks per group, 8192 fragments per group
    2008 inodes per group
    Superblock backups stored on blocks:
    8193, 24577, 40961, 57345, 73729, 204801, 221185

    Now, remember when using this command, you need to use the same flags you used when you created the filesystem originally, and just add ‘-n’ to them. If you made an ext3 filesystem, you would use:
    # mke2fs -j -n /dev/[device and partition number]


    • ashwn Sep 24, 2010 @ 11:33

      Yes. Indeed this is a great shortcut – mke2fs -n /dev/XX .

      Thank you for suggesting this.

      This is a wonderful website with easy to understand and clear text linux resource. Simply, one of the best Linux learning sites on the net.

      • midgard Jul 25, 2013 @ 17:57

        Also you can use mkfs command, for example for ext4 fs:

        mkfs.ext4 -n /dev/XX

  • uncle max Dec 28, 2009 @ 7:06

    Hi, this looks like a potential lifesaver. Great Stuff. Question: do superblocks ever move?? Obviously i don’t know ext3 filesystem internals — too much to learn, so little time… My point is: would there be any value in storing the list of superblock locations offline?


  • 🐧 nixCraft Dec 28, 2009 @ 11:33

    @uncle max

    You can.. but I strongly recommend backup instead of just superblocks. Linux comes with rsnapshot backup tool that can make hourly, daily and weekly backup of all your servers. If you are old school UNIX person, tar, dump and restore are regular tools for backup.


  • Evan Jan 3, 2010 @ 2:39

    thank you so much, this is valuable information, and it saved me a LOT of work!!!!!

    thanks for the write up, awesome, worked like a charm on ubuntu 9.10 off live cd rescuing a / partition on my HDD

  • Jaciss Mar 1, 2010 @ 0:28

    Thank you! Successfully recovered my data, and with much less stress than I might have had due to the clear explanations. Thanks also to ShadowCat8 – I was getting magic error numbers with the other method of finding the superblock locations.

  • Ashwin Mar 20, 2010 @ 15:45

    hi.. Even after i run d command i m gettin a ‘couldnt find ext2 superblock. Tryin backup blocks’ n then a bad magic number in superblock again! I ve lot of data n desperately need to retrieve them..


  • mahendra Sep 1, 2010 @ 14:56

    Good and simple.
    I believe we will be able to mount the fs using a diff super block “only” if we r running system in rescue mode with cd media mounted,
    I could not mount the fs when the system was live.. instead i was seeing help of mount command

    mount sb=”204801″ /dev/hda1 /vol1
    Usage: mount -V : print version
    mount -h : print this help
    mount : list mounted filesystems
    mount -l : idem, including volume labels
    So far the informational part. Next the mounting.
    The command is `mount [-t fstype] something somewhere’.
    Details found in /etc/fstab may be omitted.
    mount -a [-t|-O] … : mount all stuff from /etc/fstab
    mount device : mount device at the known place
    mount directory : mount known device here
    mount -t type dev dir : ordinary mount command
    Note that one does not really mount a device, one mounts
    a filesystem (of the given type) found on the device.
    One can also mount an already visible directory tree elsewhere:
    mount –bind olddir newdir
    or move a subtree:
    mount –move olddir newdir
    A device can be given by name, say /dev/hda1 or /dev/cdrom,
    or by label, using -L label or by uuid, using -U uuid .
    Other options: [-nfFrsvw] [-o options] [-p passwdfd].
    For many more details, say man 8 mount .

    any clues on this?

  • Don Oct 11, 2010 @ 23:11


    Here is what I did that worked for me.

    $ dumpe2fs /dev/sda6
    – got just the “Bad magic number in super-block while trying to open…” message
    $ mke2fs -n /dev/sda6
    got the 2nd super block same as in the example.
    $ fsck -b 32768 /dev/sda6
    to fix.

    Should have used “-a” option to automatically accept fixes because it had a gazillion complaints and I had to lean on the “y” key for 20 minutes. My disk may not be optimally fixed, but I can see the data I was missing before which is a big step forward.



  • Gilbert Apr 12, 2011 @ 1:06

    Hi there!
    Sorry, I can’t find, here in this place, the example where was the explanation in how to recover a NTFS partition with linux utils; I remember I red, that the program asks if the partition was created under Vista.
    A friend of mine, needs back his HD, at least, recover his important data, I told him that it could be possible to restore the whole drive too.

  • Bryn Aug 26, 2011 @ 15:40

    Hi, I still have a problem. Have tried all things suggested in comments, still no luck, just get these errors

    freenas:/mnt# mke2fs /dev/ad1
    mke2fs 1.41.14 (22-Dec-2010)
    /dev/ad1: Operation not permitted while setting up superblock


    dumpe2fs /dev/ad1
    dumpe2fs 1.41.14 (22-Dec-2010)
    dumpe2fs: Bad magic number in super-block while trying to open /dev/ad1
    Couldn’t find valid filesystem superblock.


    fsck -t ufs /dev/ad1
    ** /dev/ad1 (NO WRITE)
    Cannot find file system superblock
    ioctl (GCINFO): Inappropriate ioctl for device
    fsck_ufs: /dev/ad1: can’t read disk label

    • Richard Sep 20, 2011 @ 13:57


      You need to use the -n switch with fsck

  • cabello Sep 28, 2011 @ 17:33

    nice really help me!! regards!

  • ChrisH Nov 17, 2011 @ 13:03

    Great help thanks guys.. Only one issue.
    After getting super block issue fixed guess some fragmenting was conducted) I now continue to get the following message:

    Inconsistency detected by dynamic-link.h: 187: elf_get_dynamic_info: Assertion `info[20]->d_un.d_val == 7′ failed!

    So far it’s whenever trying to run firefox, thunderbird, deluge or Virtual box.
    Tried removing and re-installing, still no luck. Any suggestions greatly appreciated.

  • wcdolphin Jan 12, 2012 @ 7:12

    Helped me when restoring from a bad superblock, kudos and hopefully a quick upvote on Google’s search rankings!

  • Caroline Feb 7, 2012 @ 5:29

    No rsaoen why you can’t run linux if your clients run windows… ;)Just saying there are a lot of good rsaoens to try it out ;)I can respect windows…MS makes life easy in some ways, but I know that after using Linux for 5 years I pull my hair out every time i have to diagnose a problem in windows, or get it to do some specific thing, etc.I don’t want everyone running linux, just enough to make MS improve the bits they are terrible at ;)

  • Randy Kramer Mar 6, 2012 @ 14:43

    When you answer “yes” to the following question, might files be lost / deleted? (What if you answer “no” to the question?)

    Free blocks count wrong for group #368 (32254, counted=27774).
    Fix? yes

  • paul (un)lucky13 May 28, 2012 @ 21:35

    You can also use superblock stored at 32768 to mount partition, enter:
    # mount sb={alternative-superblock} /dev/device /mnt
    # mount sb=32768 /dev/sda2 /mnt

    should it not be?

    You can also use superblock stored at 32768 to mount partition, enter:
    # mount -o sb={alternative-superblock} /dev/device /mnt
    # mount -o sb=32768 /dev/sda2 /mnt

    tip: it using it on loop? pass -o loop,sb=32768
    else excellent and had to also RTFM man mkfs.ext3 and also cat /etc/mke2fs.conf

  • userxo Jul 26, 2012 @ 9:29

    You saved me!!!! Thanks for the post!

  • Dean Oct 23, 2012 @ 22:37

    Nice! saved me so i can a least backup and rebuild raid. thats if drive is not gone bad.

  • roberto Dec 20, 2013 @ 9:48

    I just stumbled on this page and I would like to thank because I think it is really what I need :)

    I have a superblock read failure at boot time, I’m asked to type the root password and I managed to browse the root / partition, that was the only one that the system was able to mount. At this point I used fsck as explained above on the / partition and fixed hundreds of errors, but after the reboot the broken superblock situation is still present. Trying to reiterate restoring the superblock with fsck didn’t help.
    Do I have to fix the superblock of the other partition on my disk? Those partition are /home and /usr/local, which contains the important data and I would like to be sure that they are not accessible before modifying their superblock. Now I am not in front of my broken PC and unfortunately yesterday I didn’t try to mount the other partitions.
    So, how can I know which is the partition with a broken superblock? Is it safe trying to run fsck on an eventually clean pertition?
    In addition, I don’t understand how is it possible that I managed to browse the / partition if its superblock was broken.

    thanks in advance for any answer

  • elguil Jun 11, 2014 @ 1:42

    It worked! Many thanks!

  • JugeHuge Aug 18, 2014 @ 15:41

    Is there any possibility to copy superblock to other identical drive??
    I had RAID1 setup which both drivers mechanically failed. I can mount another but another is missing superblock.
    Drives are identical so could there be someway to copy superblock from /dev/sda6 to /dev/sdb6 or should i try to mdadm –create command keep fingers crossed that it doesn’t destroy data.

  • Rajan Sep 25, 2014 @ 6:33

    Thanks for the nice article. In one of my Ubuntu machine, the boot stopped in initramfs, I booted with a liveUSB and found that the journal on the disk was corrupted. Running fsck repaired it. Thanks again for your help.

  • vikrant Nov 2, 2014 @ 15:56

    Hi every one i don’t know this is right forum or not but when i read about fsck and repair options i think any of expert from above will definitely help me. I am using LynxOS 2.XXX WITH SHIMADZU CT SCAN system and application .it’s uses LynxFS file system.while system in running state i have used mkfs command accidentally and now one of my partition is showing empty disk.So i tried recovery and found that no any recovery software can understand this partition style but i can successfully make image of this drive. and when for repair work finally i saw in RAW Display of partition which is /dev/sdob has data in raw format so i think due to mkfs is front end and high level tool this only changed my partition table and still data is there.I have 3 partitions Sd0a Sd0b Sd0c , a and c is ok and b having partition table issue Please help me if any one can? my mail :

    Mumbai – INDIA

  • satish amrutwar Jun 10, 2015 @ 14:21


    I have read all your suggestions given to the readers. I have accidently run fsck on a corrupted umounted file system without taking back up. As it is showing some data loss during fsck. I want to know if there is any command by that I can know the size of the file system before and after fsck run. So that I can confirm is there any data loss or not.

    Thanks in advance
    Satish Amrutwar

  • Manish Dec 21, 2015 @ 20:30

    Hi !
    What do I do in the last line
    Cp file /path/to/safe/location ?
    Can someone give an example ?

  • vamsi Apr 24, 2016 @ 5:20

    You are a life saver man. This piece of blog is solid gold. Thanks

  • Shubham Sep 19, 2017 @ 21:13

    YOU SAVED ME !!!


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum