What are the best practice steps to check for / recover from potential Linux OS corruption, in the event of unexpected power outage (or VM host failure)?
Of course it "depends" on the installation and setup, but I'm looking for common actions / checks to perform for majority of Linux OS (Debian, Ubuntu, Mint, other) and file systems (XFS, ZFS, EXT4, vfat).
This is not about preventing ungraceful shutdowns - it's about dealing with when they do happen and to try and ensure best case recovery.
I'm aware that OSes tend to detect when a filesystem wasn't unmounted (like it would during a graceful shutdown) and therefore automatically perform checks upon boot-up, but what are those checks and how to I perform them manually?
E.g. e2fsck -f
is one such tool, but for the uninitiated, when can/should it be used and when not (or won't it work)?
As an example, in Windows you might do:
- Check for NTFS file system corruption using the old
chkdsk
or the modern equivalent of repair-volume
(in PowerShell)
- Verify integrity of OS core system files using
sfc.exe /scannow
Application specific verification/recovery steps like MySQL database
or LDAP directories
etc., fall outside of the scope this question - unless it's a very common thing, like some OS database e.g. apt
or snap
databases.
What do you do?