1

I got a file system corruption from a sudden power loss. During boot, it reported following error.

 error: unknown filesystem. 
 Entering rescue mode... 
 grub rescue> _"

The board is an Intel NUC using M.2 2242 SSD as storage. The SSD is partitioned as sda1, sda2, and sda5 for typical Ubuntu installation. I ran a liveCD and tried to fsck the ext4 filesystem, but tune2fs -l /dev/sda1 complained.

Bad magic number in super-block ... couldn't find valid filesystem superblock.

I know a power loss may result in a file system problem. But how could it be so bad that the super block is lost? I have done the following to reduce the chance of corruption, but it still happens too often.

  1. disable disk write cache. (hdparm -W 0 /dev/sda, every time it boots)
  2. KVM virtual machine disk image cache mode set to 'directsync'.

Halfgaar and Ts'o say that during a voltage drop, the DIMM is more sensitive and the content is garbage; whereas SSDs can last longer, thus copy wrong data from DIMM. This paper gives 6 ways for SSDs to fail, including the metadata (FTL) is corrupted. I wonder how can I determine what happened in my case.

Can somebody give example scenarios that damage the super block?

1
  • 3
    Note, an ext3/4 filesystem keeps multiple copies of the superblock. See man fsck.ext3 to use an alternative one.
    – meuh
    Jul 19, 2016 at 15:37

1 Answer 1

1

If you suffer from frequent voltage drops or noise in your mains power then GET AN ONLINE OR LINE-INTERACTIVE UPS.

See https://en.wikipedia.org/wiki/Uninterruptible_power_supply

There is no software solution that can fix this.

As for your question, the superblock is just data. It can be corrupted like any other data. Either when it's being deliberately written to, or if the RAM contains corrupted data (e.g. due to a voltage drop) and that data is corrupted in such a way as to cause the superblock sectors to be written instead of the intended sectors.

you probably can't determine exactly what happened in your case because transient garbage is a) garbage, and most significantly b) transient.

2
  • 1
    btw, even a cheap UPS is better than nothing....but cheap models usually aren't cheap in the medium to long term, they (and/or their batteries) need replacing far more often than more expensive models. anything $50-$100 is probably junk that will blow up and set your cat on fire. Low-end starting-to-be-decent UPSes start from $150-$200 or so. That's AUD, relative prices may be different in your location.
    – cas
    Jul 19, 2016 at 14:20
  • Thank you for your answer. Actually there is a UPS, but the users tend to ignore that and just yank the power cord. Another reason is that we want the system to behave like an appliance (router, webcam, etc), but the initial design has flaws (root fs is not read-only, no battery, no power drop interrupt, etc). I'm looking for a solution that doesn't require much hardware change. Is it possible to change the FS mount options ( noatime, data=journal), or use another FS (btrfs, ZFS) to make it more robust? If total elimination is not possible, at least a reduced probability of corruption is good.
    – lqu
    Jul 21, 2016 at 0:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .