ext4 corrupted superblock on USB-stick
I have built EasyOS version 2.2.11 and wrote it to a USB-stick.
Booted it on my HP desktop, no problem. Then booted it on my Acer
Aspire1 laptop, no problem. Rebooted on the laptop, and Easy could not
find the working partition.
There were the little dots as it searched for the boot-partition and
working-partition, then it timed out and booted up running in RAM. It is
good to have this fallback, as at least there is a running desktop and I
can examine what went wrong.
I saw right off, only "sda1" icon was on the screen, the
boot-partition. "sda2", the working-partition, was not there. I ran
"probepart" in a terminal, and /dev/sda2 was listed as having a
filesystem of "none".
Running "fsck.ext4 /dev/sda2" returned a message "Bad magic number in super-block". In other words, the superblock is corrupted.
So how did that happen? USB-stick failing?
Fortunately, ext4 maintains backup superblocks. Running "mkfs.ext4 -n
/dev/sda2" will list them. one of them is "32768". So, I ran this:
# fsck.ext4 -y -b 32768 /dev/sda2
...the "-y" means say yes to all questions. The "-p", automatic repair, did not work.
That did the trick, rebooted a few times, no problem.
I am wondering whether I should put code into the initrd to attempt
this automatic recovery of a corrupted superblock. Hmmm, don't know.
This is the first time that I have encountered this particular failure,
and perhaps it is a warning of a deeper problem, like the USB-stick on
the way out. Perhaps just attempting an automatic repair, if it
succeeds, will not be sufficient warning to the user that perhaps the
USB-stick should be retired. Or, there could be bad RAM, in which case
corruption could be happening all over the place.
Tags: easy