5

I created two partitions on a 1.5 TB drive, the first was 1 TB, the latter was the remaining .5 TB. Both were formatted as ext3. I don't mind the automatic filesystem checks occurring every so often, so I never bother configuring the frequency of it. What I found odd was that it decided to make the automatic check occur every 39 mounts for the 1 TB, and 27 mounts for the .5 TB partition. I attempted to look in the man pages as well as various forums, but I couldn't find any mention about how it determines the frequency for file system checks. I assume it is a simple formula, so does anyone know what it is?

CassOnMars
  • 181
  • 6

3 Answers3

6

The good thing about linux is the source is always somewhere. You can download or view the base e2fsprogs sources on kernel.org. This can also depend on your specific version and distribution though...

From current code it looks like it's some value added to 20 based on the UUID of the partition, if you have enable_periodic_fsck = 1 in your mke2fs.conf

mke2fs.c

if (get_bool_from_profile(fs_types, "enable_periodic_fsck", 0)) {
    fs->super->s_checkinterval = EXT2_DFL_CHECKINTERVAL;
    fs->super->s_max_mnt_count = EXT2_DFL_MAX_MNT_COUNT;
    /*
     * Add "jitter" to the superblock's check interval so that we
     * don't check all the filesystems at the same time.  We use a
     * kludgy hack of using the UUID to derive a random jitter value
     */
     for (i = 0, val = 0 ; i < sizeof(fs->super->s_uuid); i++)
         val += fs->super->s_uuid[i];
     fs->super->s_max_mnt_count += val % EXT2_DFL_MAX_MNT_COUNT;
 } else
     fs->super->s_max_mnt_count = -1;

mke2fs.h

:#define EXT2_DFL_MAX_MNT_COUNT              20

Always good to see the words 'kludgy' and 'hack' in code =)

Matt
  • 8,991
  • Admittedly, it's always a tad alarming to see "kludgy hack" near anything close to the file system level, but given the point of said kludgy hack, it's permissible. – CassOnMars Feb 19 '13 at 13:50
1

Look at mke2fs(8), and the contents of /etc/mke2fs.conf(5) for defaults.

vonbrand
  • 18,253
0

You have to use the tune2fs command to set various parameters like number of mounts or number of day between FS sanity checks.

You can also use tune2fs -l /dev/device to display current informations about your filesystem

Poulpatine
  • 102
  • 3
  • I'm aware of tune2fs to change the parameters. I'm asking how it comes up with the default parameters, as they appear to be partition size-dependent. – CassOnMars Feb 18 '13 at 21:25