This utility verifies HFS file systems by using fsck_hfs
command line interface inside.
Verification will avoid the time machine backup process by waiting until backup will be done.
Also, we will lock your disk volume from I/O operations while verification proceeds.
NOTE: This utility was designed for MacOS and works with bash shells only.
The shell script not maintained or supported by the developer. It was made for personal use only, so please don't use it on production or commercial platforms. There is no warranty in any cases.
This script was made for automating the volume structure verification,
and notify an administrator about any problems was found for.
We will not try to fix any problems automatically, cause in some cases it will exacerbate the problem.
wget -O /usr/local/bin/hfshealth https://raw.githubusercontent.com/timoshka-lab/hfshealth/master/hfshealth.sh
chmod +x /usr/local/bin/hfshealth
sudo hfshealth [OPTIONS] {Volume UUID}
Simply, verify the health of your volume and get results as stdout.
sudo hfshealth 7DFCEB10-F686-3834-A903-8E61D9CBAC03
Also, you can send verification results into your slack channel. For specific instructions about Slack webhooks API, please check this article.
sudo hfshealth --slack-url https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXX 7DFCEB10-F686-3834-A903-8E61D9CBAC03
At first, you have to open the crontab settings as root user. Without root user privileges, fsck_hfs
command won't work fine.
sudo crontab -e
Next, we have to include some path which we use inside the shell script.
PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Run hfs verification every day at midnight
0 0 * * * /usr/local/bin/hfshealth --slack-url https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXX 7DFCEB10-F686-3834-A903-8E61D9CBAC03
You can find the UUID easily by using diskutil
command.
If you don't know you device identifier, you can find it by diskutil list
command, which will list all disks on your system.
The volume identifier will be looked like disk4s2
.
diskutil info /dev/diskXXX | grep "Volume UUID"
fsck_hfs
was designed to work with device identifier which can be changed by replacing your storage disk to another USB or Thunderlot device.
So, it won't be safe to use the device identifier for scheduling verification jobs at background system.
My first purpose of this script was to make it work with the Volume UUID instead of identifier.