When and how should this be run? Is it better to boot from a DVD-ROM and run fsck on each real hard drive? Or can this be done automatically after X number of mounts?
-
Possble duplicate of http://serverfault.com/questions/674694/how-to-have-automatic-file-system-checks-for-linux-software-raid/674728 – Paul Haldane May 10 '15 at 10:28
2 Answers
The answer to when to run fsck
on the underlying physical disks is very simple:
Never
If you are using RAID-1 the fsck
command might not notice you are using it incorrectly and perform an actual check. If that check results in any writes to the disk, you will end up with a RAID where the disks are out of sync.
Having metadata out of sync between RAID replicas can potentially lead to data loss.
The correct way to check your RAID
Periodic checks of the file system metadata are to be performed on the logical layer above the RAID. This is done as part of the boot process, and there is a good chance this is already configured for you.
Periodic verification that the replicas are readable and in sync is also a good idea. This happens at a lower layer and doesn't check any integrity at the file system layers. On one of my servers I can see that these checks are happening by inspecting the output of
dmesg | grep data-check
- 29,894
- 16
- 72
- 122
-
Red Hat-based systems have a cron job that rescans software RAID arrays every Sunday morning. – Michael Hampton May 10 '15 at 14:54
-
@MichaelHampton Debian has a cron job which does it the first Sunday of the month. – kasperd May 10 '15 at 14:58
fsck stands for 'file system consistency check', it checks a filesystem, not the underlying disks - as such it should be used to testing the entire filesystem. As for periodic automatic fsck executions look at your /etc/fstab file, it's in that file that we can define automatic checks.
- 100,240
- 9
- 106
- 238