HOWTO: Repair a broken Ext4 Superblock in Ubuntu
This has happened to me a few times, and it’s not a nice problem to find yourself in. You computer won’t boot, all your filesystem checks tell you you’ve a bad superblock, but you cant seem to find how to fix it. Well, here goes 🙂
This guide is for ext4 , though I’ll explain how other filesystems can be cured along the way. The easiest way to carry all this out, seeing as your computer probably won’t boot at this stage, is to download and burn a copy of Parted Magic. Boot from that, and you’ll access to a number of useful tools.
First, figure out what partition we’re dealing with.
sudo fdisk -l
The above will list all the partitions on all the drives in your computer. To recover a lost partition, your going to need Testdisk. Testdisk is included in Parted Magic, and there’s a great guide on their site. For this though, we just need the partition number, such as /dev/sda3 or /dev/hdb1.
Now, make sure your superblock is the problem, by starting a filesystem check, replacing xxx with your partition name. Here, you can change ext4 to ext3, or ext2 to suit the filesystem.
sudo fsck.ext4 -v /dev/xxx
If your superblock is corrupt, the output will look like this
fsck /dev/sda5 fsck 1.41.4 (27-Jan-2009) e2fsck 1.41.4 (27-Jan-2009) fsck.ext4: Group descriptors look bad... trying backup blocks... fsck.ext4: Bad magic number in super-block while trying to open /dev/sda5 The superblock could not be read or does not describe a correct ext4 filesystem. If the device is valid and it really contains an 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 <device>
Now lets find where your superblock backups are kept.
sudo mke2fs -n /dev/xxx
Down at the bottom of this output, should be a list of the backups
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Your almost there. Finally, restore the superblock from the backup, again replacing the x’s with your partition name, and block_number with the first backup superblock.
sudo e2fsck -b block_number /dev/xxx
Now reboot, and your superblock should be fixed. If it’s not, repeat the steps, but restore a different backup superblock 🙂
Filed under: Operating Systems, Ubuntu | 145 Comments
Tags: Ext4, Ubuntu
145 Responses to “HOWTO: Repair a broken Ext4 Superblock in Ubuntu”
- 1 mount: wrong fs type, bad option, bad superblock on /dev/hdc3
- 2 lollate estive &vendetta in programma « Vincenzo007's
- 3 Operating system not found - firmware test fails - Page 4
- 4 HOWTO: Fix an NTFS partition in Ubuntu « Linux Expresso
- 5 Ukryptert » Linux, Raid, grow, MDADM og krasj – En fortelling om at backup er viktig!
- 6 Recover partition
- 7 group descriptors corrupted!
- 8 bad superblock AFTER a tar restore
- 9 s9y testdrive
- 10 Superblock corruption on every boot | PHP Developer Resource
- 11 rescue remix cd
- 12 Recuperando uma partição ext[2-3-4] superbloco no Ubuntu | Tech Computação
- 13 Corrupted super block | Ubuntu InfoUbuntu Info
- 14 Corrupted super block | WyldePlayground.netWyldePlayground.net -
- 15 Corrupted super block | James n Sheri.comJames n Sheri.com
- 16 [ubuntu] HDD mounts, but won't boot (1TB HDD, ext3, desktop) | Ubuntu InfoUbuntu Info
- 17 Help! -- HDD sda1 mounts but won't boot (1TB HDD, ext3, desktop) | Ubuntu InfoUbuntu Info
- 18 TBA… | computothought
- AMD64 Apt Apt-Cacher Apt-Cacher-NG Arch ArchBang Artic Silver 5 Backups Bang86 Broadband Celeron CentOS Cleaning Clonezilla Compiz Conky copy recursively CPU Crunchbang Debian DPKG Ebay find Firefox Flash Gnome GRUB GTk Hardware Heatsink HowTo Jesred Karmic Laptop Linux LUbuntu Maverick Network New Computer NTFS Nvidia Office 2007 Openbox Operating Systems Packages Packard Bell Pentium Pentium IV Perlico PIII postaweek2011 Posts Proxy RAID Repairs RSync Sensors Server Size Mismatch Snow Squid SSH Synaptic System64 Tecra terminal commands Themes Ubuntu Upgrade USB VNC W2K3 Windows Wine Xubuntu 9.10
Top Posts
Archives
-
Join 86 other subscribers
Meta
-
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License.
I have to say thank you. through no fault but my own I killed my partition table and the was unable get to any of my data. (4tb worth) because of the is how to and the linked download to the partition magic everything is humming again. thank you for your help and guidance.
Wow, that would be a lot of data to lose! I’m glad that I’ve helped mate.
just wanted to say a huge huge thank you. although i’m using arch, your guide worked perfectly (after all, ext4 is ‘distro-agnostic’ :). i’ve been messing around with solaris on a secondary partition, and who would’ve thought that sun’s fdisk messes up partitions it’s not even told to touch..
anyway, if i could kiss you without any gay overtones, i would. your straightforward guide is indeed a lifesaver.
I’m glad to hear I helped mate. This article is actually the biggest draw to the site at the moment 🙂
Saved my day!!! Got this problem on my / and couldn’t boot anymore, needed to boot from a pen and done what you said, and worked! No problems with my data! Yay!
Glad to hear that I helped Fabricio 😀
Thank you very much for your help. I’m still somewhat new to linux so to play with it and to help me learn more about it I use Kubuntu on an external hard drive connected via USB. Due to a power outage I have been unable to boot from the drive so I’ve been using a Live DVD. I found several articles about using fsck, but until I found your site I hadn’t seen anything telling me how to find where the Superblock backups are stored. Once I used that and the -b option in fsck it appears that everything has been fixed. My next step is to restart and see if I can now boot from it, but I wanted to leave a note for you before I do that in case I don’t find my way back here afterwards. Thank you, thank you!
I do believe I’m in business again. While booting-up Kubuntu gave an error that the drive had errors – I selected the ‘fix’ option, it did its thing, and then it auto-restarted. After that it was the familiar start-up process. Without your help I certainly wouldn’t be up and running again now. I’m glad you were there for me. *thumbs up and slaps on the back to you*
Brilliant! I always love hearing that the stuff I post here helps people 🙂
A very big thank you for this, i was meddling with the boot loader in windows when this error creeped into ubuntu, thankfully it is fine now.
you really saved me, was about to reinstall it entirely and reinstalling all the applications would have been a nightmare..
I can’t count how many times I’ve had to use this myself 😛 Glad it helped 🙂
It’s been interesting to find your help, in my case it did not work.
I upgraded from ext3 to ext4 and after fsck the mountpoint for /boot was marked as corrupt.
Anyway, everytime that I boot my system it asks me to type S to skip mounting, and after it it loads /root and /home at an extended partition.
Any idea?
Thanks.
Off the top of my head, no, not really. There are so many different causes for filesystem corruption that cases can be very individual. My best advice is to head over to the Ubuntu Forums, set up an account if you don’t have one, and state your case in the General Help section.
Ubuntu Forums has so many eyes and ears who’ll know what to do much better than I would. In fact, almost all problems I can’t fix myself, UF has found a cure 🙂
Thanks!
hey, I just wanted to thank you, I got my data back!worked great!
Thanks a lot, it seems to be ok now.
Great work!
I almost lost my subversion repo because I was lacy and had no backup. My RAID destroyed my filetables – running this fix fixed it!
You saved me a couple of days work! Thanx!
Glad to be of service 🙂
Maybe you should edit the page subject title Repair a broken Ext4 Superblock in Ubuntu Linux Expresso to something more suited for your content you make. I loved the post all the same.
Thank you too. This was very valuable information. Yeah!
Finally I was able to restore my broken ext4 partition. Many thanks 😀
Thanks! You saved my 2TB disk! 🙂
hi!
I was glad I’ve found your site in the hope of getting my hdd going again. There are some things I don’t understand, though:
fsck.ext4 -v /dev/sda
e2fsck 1.41.4 (17-May-2010)
fsck.ext4: Group descriptors look bad… trying backup blocks…
fsck.ext4: Bad magic number in super-block while trying to open /dev/sda
The superblock could not be read or does not describe a correct ext4
filesystem. If the device is valid and it really contains an 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
fsck.ext4 -v /dev/sda1:
e2fsck 1.41.4 (17-May-2010)
/dev/sda1: clean, 357378/60678144 files, 54736225/242684400 blocks
Then mke2fs -n /dev/sda(1) gives me the super block candidates and
e2fsck -b /dev/sda1 runs a few checks:
Group descriptor 1-7406 checksum is invalud. FIXED.
[..]
Pass 5: Checking group summary information
Free blocks count wrong for group #0-7406 (..) Fixy? -> y
Directories count wrong for group #0-7392 (..) Fix? -> y
Free inodes count wrong (..) Fix<y y
Then I reboot, and the story starts from the beginning. It also says that the volume has the same errors and fixes them again?
Do I miss something or is my hdd done?
Side note: I can mount /dev/sda1 and read my files. But I’d like to get my system going again and create a raid1 with another hdd. But because of the superblock error I cannot mount the md0 array that I create with /dev/sda1.
If you can mount the specific partition, than I don’t believe that it’s actually a superblock issue. Quite a few different problems give similar outputs.
Can you access the other partitions/drives in the raid array?
My advice would be to backup the data on your raid, rebuild it, and copy back your data. If your raid isn’t being detected, perhaps it’s an issue with the other partitions/devices in the raid. Ensure also that sda1 is in ext4 (though the above should pretty much work on other exts, with minor modifications)
Sorry in taking so long to reply to this, it’s been a rather hectic week.
What have i to do after mke2fs found the Backup of the superblock?:
[quote]
Superblock-Sicherungskopien gespeichert in den Blöcken:
32768, 98304, 163840, 229376, 294912, 819200, 884736
[/quote]
thx
My apologies, I’d accidentally cut off the end of the howto >.< Thanks for letting me know about this, this is the most popular post on this site.
Thank god for WordPress Revisions 😉
Have a read through again, the next steps should fix your problem.
Nice to help you 😉 I found the answer by myself:
fsck.ext4 -p -b 884736 /dev/md0, but it doesnt work and i get still the error
Root Inode is no directory. clean? no
Error1: Corrupt extent header on inode 1049436
exit (translate from german)
how can i rescue my data?
Generally, you’d perform this on the actual drive or partition, rather than the RAID device iirc. Maybe give that a try?
You mean instead of fsck.ext4 -p -b “blockid” /dev/md0 do fsck.ext4 -p -b “blockid” /dev/sdb and than the same with the other disk like sdc, sdd, sde …?
Exactly. It’s probably just one disk that’s gone bad and taken down the whole array. What RAID are you using?
Its an raid5 with 7disks of each 1,5tb. And my fault was that i want to test the performance with: dd if=/dev/zero of=/dev/md0 bs=1G count=1 oflag=direct, after that i realised that all my data a somewhere ;( now i must recover it.
If I’m not mistaken, that command would write blank data, to the size of 1GB, onto the array?
Yes for sure ;( I run this command 4 or 5 times.
Probably best to go to the Ubuntu Linux forums, setup an accont and explain your situation in the Server section. I’m not really sure I can help, but my best advice would be to stop using the drive until you get some help over there, to minimise the possiblity of overwriting your data. I fear that perhaps you’ve written over the data that was there, though I could be completely wrong.
I hope you solve your problem. In future, if you want to test a drives performance, reading performance anyway, try;
I stopped the use of the server. Yes i know hdparm but dd schould be ab better test, i think i read of it anywhere. which url is the ubuntuforum?
The link is in my above reply, though if it’s not there for you;
http://www.ubuntuforums.org/
Thanks a lot for this very helpful page!
I recovered most of my data. I just installed the unstable Version of e2fsprogs and get the most of my data back 😉
I have the same problem, can you tell me how did you usee thsi to solve your ptoblem. With this tutorial (very good indeed) I managed to get the folder lost+found really full of my files but it starts with # and I can not do anytinh g with it….
Thanks! It worked for my 250GB SATA drive. However, the output of fsck.ext4 was different:
ubuntu@ubuntu:~$ sudo fsck.ext4 -v /dev/sdc1
e2fsck 1.41.11 (14-Mar-2010)
fsck.ext4: Attempt to read block from filesystem resulted in short read while trying to open /dev/sdc1
Could this be a zero-length partition?
Ya, there can be a few variations, depending on the exact error 🙂 I’m glad it worked for you
Hello,
I can see a lot of superblocks and I tried them all but it does not work.
The erromessage is still the same (bad magic number in superblock …)
Ma son moved the sda2 partition with gparted to the left.
And afterwards we can’t boot the system anymore.
We do not have any LOGfile (I assume)
Do have any idea how to solve this or do we have to install the system again?
thanks Caro
My projects are recovered! Thanks!
Thanks! So easy and so not.. obvious. Helped me a lot today!
A note of thanks !
I was fiddling with the new Ubuntu 11.04 and accidentally formatted my /home which was on a separate partition. It contains lots of docs, old pics and lot of scripts which was there for the last 3 years. Your post helped to recover it and you saved my life.
simply amazing, 10000 thanks!!! 😉
Hey man, I love you.
There are no other words to say thank you.
My ext4 root partition with 10 GB of personal data is alive again.
Internet is a better place with you.
Glad to help mate 🙂
Hi – I have tried everythign above but it still seems broken !!! Can you help ??
So scared right now 😦
panic@ubuntus1:~$ sudo mke2fs -n /dev/md0
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
30531584 inodes, 122096368 blocks
6104818 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3727 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
panic@ubuntus1:~$ sudo e2fsck -b 32768 /dev/md0
e2fsck 1.41.11 (14-Mar-2010)
e2fsck: Bad magic number in super-block while trying to open /dev/md0
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
panic@ubuntus1:~$
I forgot to post this:
The output of mdadm –detail /dev/md0
panic@ubuntus1:~$ sudo mdadm –detail /dev/md0
/dev/md0:
Version : 00.90
Creation Time : Fri Jun 10 19:08:42 2011
Raid Level : raid1
Array Size : 488385472 (465.76 GiB 500.11 GB)
Used Dev Size : 488385472 (465.76 GiB 500.11 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Fri Jun 10 19:42:08 2011
State : clean, resyncing
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Rebuild Status : 30% complete
UUID : 2f00dd36:efc0862b:190295db:233044e4 (local to host ubuntus1)
Events : 0.13
Number Major Minor RaidDevice State
0 8 48 0 active sync /dev/sdd
1 8 64 1 active sync /dev/sde
panic@ubuntus1:~$
It looks like it’s trying to rebuild the RAID, currently at 30%. Try giving it a while to finish that before retrying.
If the first superblock (for you 32768) doesn’t work, retry with a few of the next superblocks (eg 98304).
Let me know how it goes 🙂
I am working through the same thing, does it say anything that Ubuntu 11.04 also gives me an error (tried all superblocks) above (bad magic) and I tried all the available superblocks
the drive is ext4 and the results of the e2fck refer to ext2 vs the ext4 in your output above.
root@D1G1T4L:/bin# e2fsck -b 214990848 /dev/sdc
e2fsck 1.41.14 (22-Dec-2010)
e2fsck: Invalid argument while trying to open /dev/sdc
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
Several of my 2TB drives are on the line 😦
THANK YOU SO MUCH. You saved my ass!!! THANK YOU!!!!!
Thank you very much. It was nicely explained and worked in few minutes. My machine is back to like.
Great to hear! 🙂
All my nightmare is registered here: http://goo.gl/WWg9x
The last error is this:
# fsck -vy /dev/sdb1
fsck from util-linux-ng 2.18
e2fsck 1.41.12 (17-May-2010)
fsck.ext4: Superblock invalid, trying backup blocks…
fsck.ext4: Bad magic number in super-block while trying to open /dev/sdb1
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
Any help is welcomed, thanks.
Mate, you need to follow the last two steps in my guide. Run
sudo mke2fs -n /dev/xxx
which will give you a list of alternate superblocks to use, down at the very bottom. It looks like this
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Pick a superblock and run
sudo e2fsck -b block_number /dev/xxx
replacing the block_number with one from the last command you ran. Then, attempt to mount the drive again. If that doesn’t work, repeat, using the next block number
e2fsck -b 32768 /dev/sdb1
e2fsck 1.41.14 (22-Dec-2010)
e2fsck: Bad magic number in super-block while trying to open /dev/sdb1
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
What i do???? I need my sdb1’s data back plz help me
Thank you very much for the reply. Indeed, I have followed the tips till the end but I was not lucky. I am coping the entire disk to another disk to start making new attemps.
I really appreciate your write up and I feel so close to getting my data off of the WD Mybook live 3TB HD. I have been at it for a week now. I would really appreciate some help.
Here is the situation:
I have carried out the above mentioned steps in Fedora as well as Ubuntu (running from Live CD).
The DIsk Utility shows the 3TB HD as healthy. There are four partitions – 2 are RAID components, one ‘unknown’ and the last one says ‘3TB’. Just like the pic in this link (2nd pic – the order is different and mine instead of RAID component says ‘3TB’ ext4):
http://community.wdc.com/t5/WD-ShareSpace/HOWTO-Recover-files-from-a-RAID-1-mirrored-drive-when-the/td-p/138448
The problem is that I can’t mount the drive. It gives me the infamous error message:
[I]”wrong fs type, bad option, bad superblock on ez,
missing codepage or other error
In some cases useful info is found in syslog – try
dmesg | tail or so”[/I]
I followed your instructions and identified /dev/sdb3 being the corrupted partition. But I can’t seem to recover from the superblocks. Every single one gives an error:
[I]The superblock could not be read or does not describe a correct ext4
filesystem. If the device is valid and it really contains an 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[/I]
I don’t know what else to do. I am really frustrated but feel that I have gotten very close!!!!
Was this drive part of a RAID in your MyBook? It’s possible that you’d need to rebuild the RAID, if it was RAID0 for instance, you’d need all drives to be working to access the data.
To be honest, it sounds like a problem with the RAID, rather than the actual filesystem. Would you mind explaining the situation a bit more?
well, i’ve made use of this for the second HDD in one week! the only drama i seem to have encountered is that whatever stuffed up my system also made a mess of my postgresql install too, seemed to nuke a few files needed for it to start up correctly… Ubuntu 10.04 x64 , soon to be in a different box… i think there might be something else gone haywire in the one that just caused me a week of computer frustration!
I’m glad you found it helpful 🙂
hey it was a great help…. and as it was my first attempt at being technical i had absolutely no idea what to do….
just wanna thank u… 🙂
No problem, glad to hear it helped!
well… i did as was written here…but now the sound’s not working..u have any idea how to fix it??
Hi!
I experienced a problem after a power outage, were I could not boot the system from a primary HD or from any of several rescue CDs, if the HD with I/O read error was plugged in.
Here is a hint to those that experience this problem, if the HD with the I/O read error is a SATA HD, it is possible to unplug the data (smaller) connector from the SATA HD, leaving the power (larger) connector plugged in and boot from a primary HD or from a rescue HD. After the boot has finished then plug in the data connector for the SATA HD.
To that this works, you can boot from your primary HD or rescue with the damaged HD disconnected. Start ‘testdisk’ after selecting to a logging option look in the media list and notice that your HD is NOT there.
Quit ‘testdisk’, connect the SATA HD and run ‘testdisk’ again.
You should see your SATA HD in the list now, but it might not be listed as the same device that you are used to. For example if you have a memory card reader attached to the system these normally get assigned a device name after hard drives, but it you wait until after the boot finishes and plug in the hard drive the memory card reader will get a lower device name so what normally would have been a second SATA HD as /dev/sdb is now /dev/sdf.
More info – when running ‘sudo fsck -v /dev/sdb’ it may only take 30 seconds for the command to output the results were as when you run the command on the partition with the problem it may take, as in my case, 20 minutes before the command finishes. NOTE: if you try to use ‘top’ to watch and see if fsck is doing anything you will not see the process counter advance, so it appears as though fsck is ‘hung’.
Now for my problem:
I have a second SATA HD that is 1TB, it’s only used for data.
After running ‘sudo e2fsck -b 32768 /dev/sdb1’, which took 15 minutes the message I received was:
/dev/sdb1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdb1: 246122/61054976 files (1.1% non-contiguous), 39505694/244190390 blocks
Error writing block 1 (Attempt to write block from filesystem resulted in short
write). Ignore error? yes
According to the instructions I’m supposed to reboot and see if the partition can be correctly read. But this takes even more time!
Before doign the following ‘su’ to root.
To try and save some time and since this is a second partition, not the boot partition, I think I should be able to attempt to mount the device. If no error occurs I should be able to immediately see if the repair process worked by viewing my data.
I can run ‘tail /var/log/messages’ to watch for any errors that occur while the system attempts to mount the HD.
sudo tail /var/log/messages | grep -i sdb
If any errors are occurring I can end the mount process with ‘kill -s9 {process id for the mount process}’. The ‘process ID for the mount process is ‘ps -A | grep -i mount’.
Then I think I should be able to try another superblock backup without the time consuming reboot to a ‘I/O read error’.
What do you think of my time saver to bypass the reboot?
Another thing which might speed up the process is to start with the latest superblock backup, which I assume is the one with the greater number, what do you think?
I recovered most of my data. except about 0.02%, which is very good.
thank you on the info, I didn’t find any info for superblocks in the ubuntu forum.
so thanks again for this blog.
No Problem! Glad to hear it worked!
just now it s running additional passes to resolve blocks claimed by more than one inode.. i hope it s going to work but anyway your blog is exellent!!so thanks even it won t work!!
You really help me a lot !
My wife did not make any backup the last 2 weeks (she is teacher) and everything is now against accessible.
We’ll enjoy the time you indirectly offer us !
Many many many thanks !
PS: the error message was “short read while trying to open the /dev/sda6”
Great to hear it helped!
Hi! for 2 weeks to try to solve the problem of my notebook! and this post could solve. The most interesting is the date of posting which is the same as my birthday! You saved my life and my neck! Thanks a lot!
No problem mate. Consider it a birthday present 😉
Estuve por lo menos dos horas intentando recuperar mis datos, ya al final di con tu post, y salvaste mi día! Thank you so, so much bro, you saved my day, im so fucking happy right now! 😀 😀 😀
No problem, glad it helped 🙂
Yes! Thank you for this. I read other posts that adviced using the command mk2fs -n to find a valid backup superblock to use for e2fsck -b
However, none of them mentioned that trying another backup superblock could yield success if the first one you tried didn’t.
For me, I had to try 3 backup superblocks before I got one to work.
The impression I got from other articles is once you’ve tried a valid backup superblock you’ve tried them all. This was not the case for me.
Glad to hear it worked!
This hint does not work here. (Sorry for the German output.)
sudo e2fsck -b 884736 /dev/sdb5
e2fsck 1.41.14 (22-Dec-2010)
Die Dateisystem Größe ( laut SuperBlock) ist 86903552 Blocks
Die physikalische Größe von Gerät ist 86903469 Blocks
Entweder der SuperBlock oder die Partionstabelle ist beschädigt!
Abbrechen? ja
There is only the possibility to cancel (“Abbrechen”). That’s it. No way to correct it. It seams that e2fsck does nothing at all.
A HUGE Thank to you! After a couple of days of searching for answers and failed restore attempts, including redhat tech support, I was able to recover my 16TB partition with the TestDisk link.
You’re Welcome! 😀
My /home partition was “NOT clean” so my Ubuntu 11.10 won’t boot. I followed until “sudo fsck.ext4 -v /dev/xxx,” which asked for fixes.
I had everything fixed. I don’t really care about the files in /home. I just wanted the OS to boot.
Thanks, life-saver.
No Problem 🙂
Hello. I need help please. I don’t know what to do next. Kind of stuck in the middle…used all 4 steps from above and still no success >>>
1. sudo fdisk -l
Disk /dev/sda: 16.1 GB, 16139354112 bytes
255 heads, 63 sectors/track, 1962 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001e4f8
Device Boot
/dev/sda1
*
/dev/sda2
/dev/sda5
/ Solaris
Start
1
1834
1834
End
1834
1963
1963
Blocks
14724096
1034241
1034240
Id
83
5
82
System
Linux
Extended
Linux swap
Disk /dev/sdb: 4103 MB, 4103937024 bytes
127 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 7874 * 512 = 4031488 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a62cb
Device Boot
/dev/sdb1
*
(LBA)
ubuntu@ubuntu:~$
Start
1
End
1017
Blocks
4003898
Id
c
2.sudo fsck.ext4 -v /dev/sda1
e2fsck 1.41.14 (22-Dec-2010)
/dev/sda1: recovering journal
fsck.ext4: unable to set superblock flags on /dev/sda1
3.sudo mke2fs -n /dev/sda1
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
920272 inodes, 3681024 blocks
184051 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3770679296
113 block groups
32768 blocks per group, 32768 fragments per group
System
W95 FAT32
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736,
1605632, 2654208
4.sudo e2fsck -b 32768 /dev/sda1
e2fsck 1.41.14 (22-Dec-2010)
Superblock needs_recovery flag is clear, but journal has data.
Recovery flag not set in backup superblock, so running journal
anyway.
/dev/sda1: recovering journal
Superblock needs_recovery flag is clear, but journal has data.
Recovery flag not set in backup superblock, so running journal
anyway.
e2fsck: unable to set superblock flags on /dev/sda1
ubuntu@ubuntu:~$
Thanks for posting this how-to. I have now bookmarked your site.
This article helped me recover a “failing” hard drive with bad superblocks which was the result of an unclean shutdown. I finally tracked the problem down to a failing power connector to the hard drive. Changed the connector, problem fixed, and all data recovered. I hope you keep posting useful articles like this!!
Glad to help!
Well, I can’t blame you for not checking every post. You can’t solve everyone’s problem, but I think you are the only one willing to give it a go.
But, a synopsis is: I had a crash of some sort and the superblock is corrupted when I try to mount the partition where I have the data. The RAID1 is “mirrored” although I set it as not backed up when I installed it on my home server – so it is a mirror with only one member. Nice huh?
I guess I would appreciate it if you could just look it over and tell me if you think I could get to the data without finding a way to build a raid of one member or that I do have to find a way, or else kiss my data good bye.
When I try to mount the “system” partition it works:
virtudesadmin@ubuntu:~$ sudo mount /dev/sdb1 /home/virtudesadmin/Documents/test-dump
mount: unknown filesystem type ‘linux_raid_member’
virtudesadmin@ubuntu:~$ sudo mount /dev/sdb1 /home/virtudesadmin/Documents/test-dump -t ext4
virtudesadmin@ubuntu:~$
BUT, when I try to mount the data partition:
virtudesadmin@ubuntu:~$ sudo mount /dev/sdb5 /home/virtudesadmin/Documents/test-dump5 -t ext4
mount: wrong fs type, bad option, bad superblock on /dev/sdb5,
missing codepage or helper program, or other error
In some cases useful info is found in syslog – try
dmesg | tail or so
virtudesadmin@ubuntu:~$
If I try the first command:
virtudesadmin@ubuntu:~$ sudo fsck /dev/sdb5
fsck from util-linux 2.19.1
fsck: fsck.linux_raid_member: not found
fsck: Error 2 while executing fsck.linux_raid_member for /dev/sdb5
virtudesadmin@ubuntu:~$
So, try the superblock option:
virtudesadmin@ubuntu:~$ sudo mke2fs -n /dev/sdb5
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
121905152 inodes, 487590816 blocks
24379540 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14881 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
virtudesadmin@ubuntu:~$
I stopped here for this post (but I actually did get something to work with the superblock but I forgot what it was, I think I tried mounting it and one of the blocks didn’t give an error but also didn’t fully mount either).
IF you are still with me, could you look over my RAID notes. They are not long but at a different site:
http://www.linuxquestions.org/questions/linux-hardware-18/get-data-off-a-raid-partition-rescue-from-server-crash-907132/
All help is Help,
Ken
Mdadm seems to be controlling the superblock to some degree. It says in your mdadm -D that the superblock is persistant, which I presume to mean it’s controlling it. That maybe the superblock for the md device though. >.< Might be worth trying a few more superblocks, and trying to mount the raid device between attempts.
Thanks a lot 😉
Now everything is in the directory lost+found. Uffffffff
What should be the output of a successful ‘sudo e2fsck -b block_number /dev/xxx’ ?
Mine still says:
e2fsck: Bad magic number in super-block while trying to open /dev/sdc
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
I’ve tried every super-block locations, all seem to fail.. Any idea?
You need to change xxx to your own device name.
LoL, obviously I knew that xxx was (sdc in my case), still I got the error message! That’s why I wanted to know what should the correct output be if the operation succeeds… It still sorted the problem somehow, when I restarted the superblock was good again eventhough it outputted an error message??
It gave an error message even though the drive was functioning normally? That’s really strange. The output you described is the ‘correct’ output for a corrupted superblock. If it is successful, it should output something about no errors. To be honest, I’m not too sure >.<
Thanks for sharing. This how to worked just fine for me and saved me from a lot of trouble.
Hi
I just reinstalled ubuntu 10.04LTS to a drive hoping that would overcome a grub error. For a few years now I have kept my /home directory on a seperate partition and am used to being able to remount that partition without formatting – thus preserving data. On this occasion I am sure that I did that as usual – I double checked – but for some reason the install has overwritten my partition with a default /home partition, my data is gone.
My first question is whether your method above will work for me despite the empty directory structure having been written? Presumably the old data is still there and hopefully can be recovered using a superblock backup.
My second question is that I am guessing the various backups are from different occasions, is there any way to deduce their order of creation, ie: which is most recent?
Cheers
Tim
Hmmm, interesting. As for how exactly the superblocks work, and whether they’re from different times, I’m not quite sure. I’ve not been able to find anything difinative on it in ext4. It’s most likely that the Ubuntu install has completely re-formatted the drive. As a result, it’s unlikely that this tutorial will help. However, it’s possible that TestDisk could help you. It’s a program used for recovering drive partitions, where the data has been formatted. It’s best if you do as little as possible to the drive, to prevent your data being overwritten. Testdisk can be found on the Parted Magic disk, the link to which is above. Parted Magic also has a variety of data recovery tools, especially for pictures and music, which can be quite effective, if the drive hasn’t been used much since being formatted.
It would be worth giving those a shot.
All the Best
Dave
WOW!!!!! Bro!! Thanks a lot, Althouth it’s a old post i thank you a lot, U save my life :).
Glad to help! 😀
Thanks a lot!! i had many files in my Hdd and i didn’t want to just format and repeat everything back again,, thanks a lot man!!
worked like a charm, broke my encrypted luks partition, and was able to restore it. thanks
Thanks a lot!! your post saved 4TB of data!!! i love you!! 😀
Glad to hear it helped 🙂
Hey, thanks a lot, I can now access my data !
Testdisk is a great tool, I backed up my disk with it before attempting anything else.
Anyway, I still have a problem : my disk was bootable and the partition is still displayed as bootable but it doesn’t do anything When booting, it shows a black screen for a second, then reboot 😦 And all my files have the “execute” flag set…
Any idea how to fix the boot problem ?
Every file is executable? That seems like a rouge permissions command, where you’ve accidentally changed the permissions on every file. Such an accident is almost impossible to fix, and it’s easier simply to start again. Cheers!
I was resizing my ext4 encrypted /home SSD partition when my Dell XPS 15Z over-heated and shut off. It was around 90% complete. I’ve done everything you said and have gotten nowhere. I did use testdisk and recovered 196GB of data. I want to reformat the partition and load the files back onto in hopes that I can decrypt and see them. Could it work?
Hmmm… I’m not sure. I’d say that the encryption is done at a filesystem level, but I’m not sure. If anything, it’s worth a shot.
root@PartedMagic:~# fsck.ext4 -cDfty -C 0 /dev/sda5
e2fsck 1.42.3 (14-May-2012)
ext2fs_open2: Bad magic number in super-block
/sbin/e2fsck: Superblock invalid, trying backup blocks…
/sbin/e2fsck: Bad magic number in super-block while trying to open /dev/sda5
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
root@PartedMagic:~# sudo mke2fs -n /dev/
mke2fs 1.42.3 (14-May-2012)
/dev/ is not a block special device.
Proceed anyway? (y,n) n
root@PartedMagic:~# sudo mke2fs -n /dev/sda4
mke2fs 1.42.3 (14-May-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13926400 inodes, 55694371 blocks
2784718 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1700 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Proceeded to try all superblocks as described with the following results:
root@PartedMagic:~# sudo e2fsck -b 32768 /dev/sda4
e2fsck 1.42.3 (14-May-2012)
e2fsck: Bad magic number in super-block while trying to open /dev/sda4
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
Did I bone it permanently? I have 2 major projects on that partition. Autocad, Rhino 3D, EASE, Visio and spreadsheets. I might as well shoot myself if I don’t get it back.
Try repeating it with another one of the listed superblocks, such as 98304, 163840 or 229376.
Eg
sudo e2fsck -b 98304 /dev/sda4
thank you. How do I buy you a cup of coffee?
Glad to hear I helped! If you really want to, there’s a donate button at the bottom of the page. All contributions are hugely appreciated.
Dave
Oh jeez. I have this problem.. but i’m afraid the solution is not this simple:
# fsck.ext3 -v /dev/sdh
e2fsck 1.38 (30-Jun-2005)
fsck.ext3: Attempt to read block from filesystem resulted in short read while trying to open /dev/sdh
Could this be a zero-length partition?
# mke2fs -n /dev/sdh1
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
181141504 inodes, 362281807 blocks
18114090 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
11056 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
# e2fsck -b 32768 /dev/sdh1
e2fsck 1.38 (30-Jun-2005)
e2fsck: Attempt to read block from filesystem resulted in short read while trying to open /dev/sdh1
I’ve tried replacing 32768 with every single backup block, but i still get the above message, or:
# e2fsck -b 23887872 /dev/sdh1
e2fsck 1.38 (30-Jun-2005)
e2fsck: Invalid argument while trying to open /dev/sdh1
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
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
Any additional insights will GREATLY help..
I was actually able to fix this a few days ago. Installed vmfs-tools on a separate host, installed iscsi initiator (since this was an iscsi volume) and was able to mount that volume via vmfs-tools (instructions here http://planetvm.net/blog/?p=1592)
Thank you very much! I am now back again.
Thanks a lot! For months I tried to find a solution to recover my data and you made my day. Thx again
A friend wanted to erase all the data on her disk. when she reformated the disk the data was still there. So she read that this command would destroy all data:
dd if=/dev/zero of =/dev/sdd
well of course it did delete all the data but also wiped out all the super blocks.
All super blocks are gone. Nice huh. How can we recover from that?
If the data isn’t important, use GParted or similar to delete the partition and recreate it with a new filesystem.
WOW really thanks very helpfull. At first time some is rescued .. I was already blaming Linux but forgot it was indeed a bad HD which I had problems with before sadly… I think I will have a lot of data loss. But first came to other help pages and messed up the rescue a bit. This is way better. Don’t do sudo fsck -y /dev/yourhardisk made it worse I think.
My hard disk was not working after an unclean shutdown and fsck didn’t even work. Found your website in google and it helped me to restore everything. I am really grateful and thank you so much 🙂
I have no words to thanks you this tutorial. You save my home partition (150gb) from the grave.
Thanks you, thanks you, thanks you.
Thank you a lot, without you I will be in an horrible situation. ^^
Saved me a lot of work. Thanks!
thanks a lot! fixed me up fine after playing around with FSCK for a day!
Many thanks for this post! It was really helpfull to me and now I have better overview how ext FS is working.
For me it was not so easy, when I was trying to use backup super block, it always failed for all backups with same error:
##########
sudo e2fsck -b 229376 /dev/sdb2
e2fsck 1.42 (29-Nov-2011)
/dev/sdb2: recovering journal
e2fsck: unable to set superblock flags on /dev/sdb2
/dev/sdb2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdb2: ********** WARNING: Filesystem still has errors **********
###########
so I was checking man page for e2fsck and found option “-c” which is doing checks in read-only mode, when I run it, it finds some broken group decriptor checksums and maaany errors in free blocks count for groups, after fix I can mount the FS without problems, so I assume that boot will work….
some details:
It is a Sandisk 32 GB 10class SD card used in Raspberry Pi, with two partitions, one 50MB FAT16 and the rest is on ext4 where is raspbian installed. – Yeah everything (Boot, OS and Data) is on that one big partition, not a good idea but now I am too lazy to change it. 🙂
Wow finally it worked for me… but I thought it must be mentioned that you have to define a partition,’sdd1′ not a whole disk e.g. ‘sdd’… tried this first, ’cause my hdd has had only one partition on it – but this didn’t work to specify the whole disk…
BIG thanxxx!!
You are God! Thanks a lot.
Nice. My laptop fell off my bed and the drive flew out. you saved my busted filesystem and the beast lives again!
Reblogged this on Henri Sekeladi – Sebuah Catatan Perjalanan.