Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

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 =)

share|improve this answer
    
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. –  d_r_w Feb 19 '13 at 13:50

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

share|improve this answer

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

share|improve this answer
    
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. –  d_r_w Feb 18 '13 at 21:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.