h1

tune2fs practical

July 1, 2008

How do I make the system perform a filesystem check after a certain number of mounts?

If the system is fairly reliable, it is safe to increase the maximum mount count. However, you should strongly consider the implications. Bad disk drives, cables, memory and kernel bugs can all corrupt a filesystem without marking the filesystem dirty or have it error out. A filesystem error detected by the kernel will force an fsck on the next reboot, but by that time, it may already be too late to prevent data loss.

With these in mind, here are the instructions to performing filesystem checks after a certain number of mounts. To adjust the maximum mount count, the filesystem should be unmounted before using tune2fs .

The example below will check the filesystem or partition after 50 mounts or 2 months, whichever comes first. You need to type in this command in a root shell:

tune2fs -c 50 -i 2m /dev/hda1

root@server61 [/etc/pam.d]# tune2fs -c 300 -i 11m /dev/sda8
tune2fs 1.35 (28-Feb-2004)
Setting maximal mount count to 300
Setting interval between check 28512000 seconds

root@server61 [/etc/pam.d]# tune2fs -c 300 -i 11m /dev/sda2
tune2fs 1.35 (28-Feb-2004)
Setting maximal mount count to 300
Setting interval between check 28512000 seconds

root@server61 [/etc/pam.d]# fdisk  -l

Disk /dev/sda: 250.8 GB, 250808893440 bytes
255 heads, 63 sectors/track, 30492 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          65      522081   83  Linux
/dev/sda2              66        2023    15727635   83  Linux
/dev/sda3            2024        3720    13631152+  83  Linux
/dev/sda4            3721       30492   215046090    5  Extended
/dev/sda5            3721        4112     3148708+  83  Linux
/dev/sda6            4113        4373     2096451   83  Linux
/dev/sda7            4374        4634     2096451   82  Linux swap
/dev/sda8            4635       30492   207704353+  83  Linux

Disk /dev/sdb: 250.8 GB, 250808893440 bytes
255 heads, 63 sectors/track, 30492 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1       30492   244926958+  83  Linux
root@server61 [/etc/pam.d]# mkdir /backup
root@server61 [/etc/pam.d]# mount /dev/sdb1 /backup

tune2fs disable disk check
##############################

one of my disk using etx3,and as usual e2fsck will check the disk every 20 mounts or 180 days or whichever come first. This is annoying especially if you have very big volume in your system. We can disable this feature by using this command.
tune2fs -i 0 /dev/hdxx

root@server61 [/etc/pam.d]# tune2fs -i 0 /dev/sdb1
tune2fs 1.35 (28-Feb-2004)
Setting interval between check 0 seconds
root@server61 [/etc/pam.d]#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: