The default configuration in Ubuntu is to perform a disk check every 35 times the hard disk is mounted. When using a laptop on the go, there are times during which it can be a great inconvenience to have to wait for a disk check at boot.

While itโ€™s possible to change or even disable this completely, I personally find it most helpful to just have a little forewarning about when itโ€™s going to happen.

Prior warning about Ubuntuโ€™s disk checks

I run the following script at startup to query how many times the disk has been mounted and notify me if a disk check will happen soon.


# Get current status report of the disk
tune2fs_output="$(sudo tune2fs -l /dev/disk/by-label/UBUNTU)"

# Scrape for values
mountcount="$(echo "$tune2fs_output" | grep "Mount count:" | awk '{print $3}')"
maxmountcount="$(echo "$tune2fs_output" | grep "Maximum mount count:" | awk '{print $4}')"

# Notify
echo "Disk check in $deltamountcount boots. Mount count is $mountcount of $maxmountcount."
if [ "$deltamountcount" -le "3" ]; then
if [ "$deltamountcount" -le "1" ]; then
notify-send --icon /usr/share/icons/Human/scalable/devices/drive-harddisk.svg "Disk check on next boot" "Mount count is $mountcount of $maxmountcount."
notify-send --icon /usr/share/icons/Human/scalable/devices/drive-harddisk.svg "Disk check in $deltamountcount boots" "Mount count is $mountcount of $maxmountcount."


Two notes about the tune2fs line: