I'm hoping to use a Raspberry Pi as the basis of an in-car infotainment system. I've followed a number of guides on reducing boot times, but the Pi will often take a long time to boot—about 20 s longer than usual—apparently due to
fsck running on the root filesystem on the SD card. These happen unpredictably: I've observed several slow warm (re)boots in a row, and several fast/normal ones in a row. I'm using
sudo reboot and
sudo shutdown now to restart or halt the Pi, and waiting for LED activity to cease before removing power.
systemd-analyze blame picarputer.service reveals the following for a slow boot:
For a fast boot, the following is typical:
mount confirms that the
mmcblk0p7 partition holds the root filesystem:
/dev/mmcblk0p7 on / type ext4 (rw,noatime,stripe=32596,data=ordered)
To simplify troubleshooting in the face of complications such as fake-hwclock, NTP and the lack of a BBU-RTC, I've deactivated the time-based fsck interval (
tune2fs -i 0). I tried deactivating mount-count-based fsck scheduling entirely with
tune2fs -c -1 but found that fsck was often still running.
I'm checking the mount counts using
sudo tune2fs -l /dev/mmcblk0p7 | grep -i mount, which produces output such as:
Default mount options: user_xattr acl
Last mount time: Wed Oct 13 01:44:35 2021
Mount count: 2
Maximum mount count: -1
After a slow boot, the mount count field has been reset to 1, and
systemd-analyze shows ~20 s due to the root fsck. After a fast boot, the mount count field has incremented by 1 since the previous boot.
So, it seems that something is sometimes resetting the mount count, which causes a boot-time fsck. Sometimes the mount count increments monotonically each reboot, in which case boot times are reasonable, but when there is a slow boot, I find that the mount count has reset to 1. I don't know what would be resetting the mount count, whether it's happening at shutdown/umount or at boot time, or why it would only happen sometimes!
Hardware is a Raspberry Pi 3 Model B+.
lsb_release -a returns the following:
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.4 (stretch)
Kernel version is:
4.14.74-v7+ #1149 SMP Mon Oct 8 17:39:42 BST 2018 armv7l GNU/Linux