2

I need to run fsck so that it automatically fixes problems (i.e., fsck -y). And because I am using "systemd" instead of "init" in the linux system, I cannot modify the /etc/default/rcS.

So what should I do to make this check run automatically?

4
  • 2
    What do you mean by "automatically"? Each time you mount the fs? If so, you could consider tune2fs. E.g.: tune2fs -c 1 /dev/sda1 to run fsck each time you mount /dev/sda1 partition. It only works with ext2/ext3 volumes.
    – Laurent C.
    Apr 1, 2014 at 10:15
  • I hqve got this error when i start the machine: /etc/sda2: unexpected inconsistency; run fsck manually I waht that the check will be auto, not manually
    – Bingo
    Apr 1, 2014 at 11:11
  • 1
    If that error pops up there you have a serious error that should be looked at manually.
    – Nils
    Apr 3, 2014 at 15:13

1 Answer 1

3

In the structure of the /etc/fstab file you can request the filesystem to be checked each time the system is booted - example :

/dev/sda1       /       ext4      errors=remount-ro,relatime      0       1
/dev/sda2       swap    swap      defaults        0       0
proc            /proc   proc      defaults        0       0
sysfs           /sys    sysfs     defaults        0       0
devtmpfs        /dev    devtmpfs  rw              0       0

The last column (6th) indicates in which order you want the filesystems be checked at boot time. 0 means no check, 1 the first check, 2 the second, ... Filesystem with the same pass number are checked in parallel.

For information and completness:

  • First column : device of the filesystem
  • Second column : where to mount the filesystem
  • Third column : type of filesystem
  • Fourth column : options passed to mount when mounting the filesystem
  • Fifth column : if the filesystem needs to be included (1) or not (0) by the dump command
  • Sixth column : pass of the automatic filesystem check at boot, 0 means no check.

If the filesystem check returns a fatal error during boot, you will be prompted to enter into the filesystem repair mode (basically single-user mode text console).

1
  • 1
    FYI: Op left a comment after you answered clarifying that he/she wants to run fsck -y; fsck is already being run (just without -y).
    – derobert
    Apr 1, 2014 at 22:04

You must log in to answer this question.

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