Score:0

Preventing ext4 metadata corruption during shutdown

pe flag

Recently, I have started getting the "Read-Only File System" error when shutting down the system (Xubuntu 20.04 LTS running on an HP laptop). Rebooting does not trigger these corruptions. The laptop has a battery inside which prevents abrupt power failures but only holds for a few minutes so is effectively a UPS.

I wrote a bash script running as a systemd service that cleanly powers off the machine if AC power is lost, but one pattern I've noticed in each of these ext4 corruptions when fixing them with fsck is that they all have exactly the same problems:

  • Incorrect free block count
  • Incorrect free inode count

The HDD inside the laptop has 1 reallocated sector as seen from SMART tests. Replacing the disk is not possible but works properly (for now) otherwise.

I am wondering if there are some preventions I can embed in the bash script to avoid these kind of problems as they appear to be very simple errors that in theory should be preventable.

ChanganAuto avatar
us flag
This is a symptom of eminent failure, regardless of the SMART data.
David avatar
cn flag
Sounds like you have 2 problems. Why does the battery only last a few mins and the hard drive is failing.
Zenul_Abidin avatar
pe flag
@David The laptop is quite old and was factory-shipped with Windows XP
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.