The de­fault con­fig­u­ra­tion in Ubuntu is to per­form a disk check every 35 times the hard disk is mounted. When us­ing a lap­top on the go, there are times dur­ing which it can be a great in­con­ve­nience to have to wait for a disk check at boot.

While it’s pos­si­ble to change or even dis­able this com­pletely, I personally find it most help­ful to just have a lit­tle fore­warn­ing about when it’s go­ing to hap­pen.

Prior warning about Ubuntu’s disk checks

I run the fol­low­ing script at startup to query how many times the disk has been mounted and no­tify me if a disk check will hap­pen 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: