Let me start out by giving you some general background information. My actual question is at the very bottom of this post.
Background, part 1: Journal replays vs. consistency checks.
Please assume that your Android device uses the ext4 filesystem for its internal storage, and the FAT32 filesystem for its removable MicroSD storage (if present).
On ext4, a "journal replay" is a partial filesystem check-and-repair operation which normally takes no more than few seconds. (Source.) The Android kernel does a journal replay whenever necessary. (Based on this source and this source.)
On ext4, a full filesystem consistency check takes longer. For an average Android device, it takes 12 seconds or so. (Based on this source.)
FAT32 is a non-journaling filesystem. So there are no journal replays. There are only consistency checks.
Background, part 2: It's probably a good idea for your OS to do periodic consistency checks. Here's why.
Microsoft program manager Kiran Bangalore writes that there are certain cases in which a filesystem can become corrupted. On a journaling filesystem such as ext4, such cases are exceedingly rare. On removable MicroSD cards, I suspect that such cases are not so rare.
The usual way to check for such corruption is to configure your OS to run a consistency-check tool every so often. Such tools include
chkdsk, ScanDisk, Apple Disk Utility,
fsck, and others.
Even on ext4 storage built into an Android device, periodic consistency checks are probably a good idea. The
tune2fs manual page explains why:
Bad disk drives, cables, memory, and kernel bugs could all corrupt a filesystem without marking the filesystem dirty or in error. If you are using journaling on your filesystem, your filesystem will never be marked dirty, so it will not normally be checked. A filesystem error detected by the kernel [may] still force a [consistency check] on the next reboot, but it may already be too late to prevent data loss at that point.
(Note that, on Android, I think a filesystem error detected by the kernel will not lead to a consistency check on the next reboot. Android is strange that way.)
Background, part 3: Here's what other OSes do.
Windows Vista, and all later versions of Windows, include an NTFS self-healing feature. Kiran Bangalore therefore writes that, nowadays, Windows users no longer need to run periodic consistency checks anymore. He explains that the OS "will inform you when ... corruption is found".
Windows 10 Mobile
Windows 10 Mobile is probably the third-most-popular smartphone OS. I think it uses NTFS. So perhaps it also can do NTFS self-healing.
In practice, when a filesystem is marked in error, Linux runs a consistency check at the next reboot. At other times, modern Linux distributions don't do automatic periodic consistency checks, ever. Those who want them must schedule these checks themselves.
Stock Android includes an ext4 consistency-check tool. As well, it includes a consistency-check tool which works on removable MicroSD cards of 32 GB or less (but may corrupt larger cards). Finally, your device may or may not also include
exfatfsck, for running consistency checks on removable MicroSD cards of 64 GB or more.
But does the OS ever run any of these tools automatically?
The iOS filesystem is normally either HFSX or APFS, and
fsck is included with the OS. I don't know whether or not iOS ever runs automatic consistency checks.
Here's my question.
Please consider the stock ROMs shipped with current Android devices.
Do such stock ROMs ever periodically run consistency checks, either on the internal storage device or (if applicable) on the removable MicroSD card?
(P.S. In cases where a device shuts down gracefully and has enough battery charge left, it's possible to run a consistency check at shutdown instead of at startup. But it takes some engineering effort to implement such functionality, and so operating system developers normally don't bother. I wonder what Android does.)
(P.P.S. I also wonder whether or not there exist any smartphones, running any OS, which do any routine periodic consistency checking. Again, please post comments below.)