How to force file system check (fsck) at boot?


How to force fsck to check and repair root partition (/dev/mmcblk0p1) at boot on Jetson TX2?

I tried with:

  1. sudo shutdown -rF now
  2. sudo touch /forcefsck
  3. uncomment and change FSCKFIX value to “yes” in /etc/default/rcS
  4. add line: “UUID=ec921b95-a565-4a06-81eb-cfc4d3cab999 / ext4 rw 0 1” to /etc/fstab
  5. adjust the number of mounts after which the filesystem will be checked by e2fsck (tune2fs -c 1 /dev/mmcblk0p1)
  6. Set kernel parameters fsck.mode=“force” and“yes”

But every attempt failed.

The only way I’ve found is to boot to alternate media (e.g., SD card).

Just for general discussion, it isn’t possible to fsck a mounted system (it can be forced on command line…this is usually a bad idea, and yet it might be reasonable if read-only). When a desktop PC boots it is a tendency to use an initial ramdisk and to not go straight into the file system mount. Jetsons go straight into file system mount.

So to make it possible to use the fsck.force or other methods it looks like you’d want to boot to an initrd and only pivot_root to the actual disk after the fsck. Unfortunately I haven’t been very successful at building an initrd in the more recent L4T releases. I had partial success, but nothing “useful”. See:

So for now what I recommend is to have an SD card available for rescue and fsck from that without eMMC being mounted.

EDIT: I’ve also failed to find a way to mount read-only. The version of systemd and kernel command line parameters in this case seems to not accept the “ro” parameter.