Always run fsck at startup

Asked by Steven Sroka

How do I set Ubuntu to always run fsck at startup before the Filesystem is mounted? (Since, when mounted, fsck can damaged the file system).

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
pablitofuerte
Solved:
Last query:
Last reply:
Revision history for this message
Best pablitofuerte (pablitofuerte) said :
#1

I'm not sure why are you trying to do this (for me fsck is really annoying) but it is posible...
The workaround (do it at your own risk) for Changing the frequency:

sudo tune2fs -c 1 /dev/sdaX

Where:

c = maximal mount count (the default value is 30)
sdaX = partition.

To now the partiton number use "sudo fdisk -l" and search the "Linux" ones....

For example:

 sudo fdisk -l
Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xbd77bd77
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1831 14707476 7 HPFS/NTFS
/dev/sda2 1832 4865 24370605 5 Extended
/dev/sda5 1832 3584 14080941 83 Linux -------------------------------------------------------------
/dev/sda6 4660 4865 1654663+ 82 Linux swap / Solaris
/dev/sda7 3585 4659 8634906 83 Linux ---------------------------------------------------------------

This command (tune2fs) won't work (and isn't needed) on partitions that fsck doesn't handle (e.g. swap or Windows partitions).

sudo tune2fs -c 10 /dev/sda5
sudo tune2fs -c 20 /dev/sda7

To return to previous settings:

# sudo tune2fs -c 30 /dev/sda5

Revision history for this message
pablitofuerte (pablitofuerte) said :
#2

The "tune2fs" feature is included in the "e2fsprogs" package, so you need to install it first:

sudo aptitude install e2fsprogs

Revision history for this message
Steven Sroka (lin-unix) said :
#3

Thanks pablitofuerte, that solved my question.