[Solved] Run fsck on external mounted device

I automount a 1TB drive on a nextcloud server

How would I ensure it runs an fsck check each boot to ensure data is not corrupted

I used this entry, but not 100% sure it will run it
tune2fs -c 1 /dev/sda1

My external drive mounts as:
/dev/sda1 917G 76G 795G 9% /mnt/3189011b-6b04-433b-8de3-6bdb8a925672

I used the example from here for the non-root partitions

Can you run command as a cron job?

Which device?

On x86 devices at least, fsck is done by initramfs and produces the following flag file: /run/initramfs/fsck-root
On RPi at least, initramfs is not enabled by default (due to custom boot loader), in this case systemd-fsck-root.service kicks in: systemctl status systemd-fsck-root

Besides tune2fs -c 1 /dev/sda1, also take care that /etc/fstab drive entry contains the fsck flag: The last integer in the line needs to be 1 instead of 0. If I remember right, by default on DietPi this flag is only set for rootfs.

In all cases you should be able to see the fsck execution via: journalctl and/or dmesg

So by changing /etc/fstab with the entry of 0 1 that will have it do a drive scan on every boot…cool

I just want to make sure if power drops out or whatever it doesn’t corrupt the 1TB drive, sometimes it will boot from SD but if the harddrive is borked…it won’t start the services because it is messed up

The fstab entry alone does not lead to fsck. It just enables fsck on boot for those drives, by reading other flags, most importantly tune2fs, which were otherwise ineffective.
tune2fs -c 1 /dev/sda1 then allows fsck on every boot/mount, with -c 5 every fifth boot/mount of the drive etc.

AFAIK by default it is configured to fsck on every 60th mount :wink:.

Just used the built in dietpi-drivemanager utility…worked like a champ! Thanks!