I have a backup script that mounts and unmounts a USB drive.
I just noticed that its warning me:

EXT3-fs warning: maximal mount count reached, running e2fsck is recommended

My question: How can I get it to run e2fsck automatically when the mount command is run?
This is how it looks in /etc/fsck

UUID=c870ccb3-e472-4a3e-8e82-65f4fdb73b38   /media/backup_disk_1  auto  defaults,rw,noauto  0 3

So <pass> is 3, so I was expecting fsck to be run when required.


This is how I ended up doing it, based on the given answer:

(In a Bash script)

function fsck_disk {
  echo "Checking if we need to fsck $UUID"
  MCOUNT=`tune2fs -l "UUID=$UUID" 2> /dev/null | sed -n '/Mount count:\s\+/s///p'`
  if [ "$MCOUNT" -eq "$MCOUNT" ] 2> /dev/null
    echo "Mount count = $MCOUNT"
    if (( $MCOUNT > 30 ))
      echo "Time to fsck"
      fsck -a UUID=$UUID \
           1>> output.log \
           2>> error.log
      echo "Not yet time to fsck"

fsck_disk a60b1234-c123-123e-b4d1-a4a111ab2222
  • 2
    You would want to run fsck before you mount the volume. You can do this in your backup script before mounting the volume.
    – Raza
    Commented Oct 27, 2014 at 3:53
  • If you'd like I'l be substitute grep "Mount count" | cut -f2 -d':' | tr -d ' ' by sed -n '/Mount count:\s\+/s///p' to be short a little
    – Costas
    Commented Oct 31, 2014 at 14:43

2 Answers 2


According to man fstab:

The sixth field (fs_passno). This field is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck will assume that the filesystem does not need to be checked.

So 3 is void. Moreover the fstab influences just on boot time check not every time a device is mounted. So to check during the boot, change 6th field to 2. If your wants to make check every mount you can do it by simple script or even make alias (for example

alias bk_mount='fsck -a UUID=c870ccb3-e472-4a3e-8e82-65f4fdb73b38 && \
                mount /media/backup_disk_1'
  • Won't "fsck -a" always run a check? The goal is to only run a check when its past the max-count threshold. Or if there is some sort of issue.
    – user92979
    Commented Oct 27, 2014 at 12:29
  • You can use the information from tune2fs -l to check the parameter you are want to use as signal to start fsck: Mount count or time from Last checked
    – Costas
    Commented Oct 27, 2014 at 13:07
  • You must be running Ubuntu. They edited the man page to say that since they use Upstart rather than fsck -a at boot time. Historically the number was simply the order that fsck -a should fsck them in, so 3 was quite valid. Really the Ubuntu man page is misleading; upstart simply treats all values above 0 the same: it means it should be fscked, but there is no ordering.
    – psusi
    Commented Oct 31, 2014 at 15:43
  • @psusi Thanks for remark. Whould you like to get some link to research the matter?
    – Costas
    Commented Oct 31, 2014 at 15:50
  • Link? No... just the source code from Ubuntu's repositories.
    – psusi
    Commented Oct 31, 2014 at 16:00

This warning is rather pointless so you can simply ignore it, or alternatively, you can get rid of it by using tune2fs -c 0 /dev/sdb. There is really no reason to fsck the filesystem after X mounts, especially with ext3/4. This is a holdover from when ext2 was new in the 90's and it was thought that it would just be "a good idea", "just in case".

  • Whatever the wisdom might be about the necessity or non-necessity of an fsck every N mounts, that's not what the question is about.
    – Celada
    Commented Oct 31, 2014 at 15:53
  • 1
    @Celada, questions don't always ask exactly what the questioner needs to know; sometimes they need guided to the right answer that they didn't consider in their question because they didn't know it was a possibility.
    – psusi
    Commented Oct 31, 2014 at 15:58
  • Your point is valid, and I appreciate it, however in this case: * I have seen FSCK required on ext3/4 in extreme corruption cases, and * This is for a external backup disk, so mount speed is not important, and I want to catch any corruption as early as possible (ie not when I'm trying to restore!)
    – user92979
    Commented Nov 1, 2014 at 23:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .