Repair the filesystem on the system partition and avoid breaking it in the first place
This MR implements the solution I proposed on #17902 (closed):
- Try to avoid leaving the system partition in a dirty state after applying an automatic upgrade
- Repair filesystems already left unclean by our shutdown procedure, after applying automatic upgrades in the past
Closes #17902 (closed)