5

The man page for fstab has this to say about the pass value:

Pass (fsck order) Fsck order is to tell fsck what order to check the file systems, if set to "0" file system is ignored.

Often a source of confusion, there are only 3 options :

0 == do not check. 1 == check this partition first. 2 == check this partition(s) next In practice, use "1" for your root partition, / and 2 for the rest. All partitions marked with a "2" are checked in sequence and you do not need to specify an order.

Use "0" to disable checking the file system at boot or for network shares.

It doesn't explicitly mention values higher than 2, but implies that 0, 1 and 2 are the only useable values.

Other sources (such as the fsck man page) imply that values above 0 will be treated in ascending order ("passno value of greater than zero will be checked in order")

Can values higher than 2 be used, or not?

Codebling
  • 785

2 Answers2

7

The answer is.. it depends, but probably not.

TL;DR if you use systemd, non-zero pass numbers will be checked in the order in which they appear in fstab. If not systemd, pass numbers will be checked sequentially in ascending order and values higher than 2 can be used.

On most distributions of linux, the fsck binary is provided by util-linux. This fsck accepts pass numbers higher than 2, and these will be treated in order.

Any system which calls fsck directly will understand "pass number" values higher than 2 in fstab.

It turns out that util-linux's fsck is not always used to check fstab. systemd maintains its own internal copy of fsck called systemd-fsck, which treats any non-zero fstab entries in the order in which they appear (specifically, it will not scan your pass number 1 entries before others).

On linux distributions that use systemd, systemd-fsck is used for automated file system checks, and in those cases the pass number is treated as a boolean (0 is means "false", or "don't verify" and != 0 is true, or "verify").

Also, don't forget that the root drive (the / mount) is sometimes checked separately.

Many thanks to Ned64, who did much research in their answer.

Codebling
  • 785
  • 1
    Thanks for finding this! The question is, is this still the way things work in the systemd age, when booting the system and checking the file systems then. Please see my Answer for my own research results. – Ned64 Oct 20 '19 at 13:48
  • @Ned64 interesting, going to update my answer with my findings – Codebling Oct 20 '19 at 19:45
2

No, only 0, 1 and 2 are possible.

From the man page (man fstab):

The sixth field (fs_passno). This field is used by fsck(8) to determine the order in which filesystem checks are done at boot time. The root filesystem should be specified with a fs_passno of 1. Other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. Defaults to zero (don't fsck) if not present.

Nowadays (i.e. in the systemd age) the pass_no entry in /etc/fstab seems to be tested against 0 (to disable checking), only, then the / (root) file system will be checked first (as if pass_no == 1). All others are treated equally. Please see systemd/fsck.c source and systemd//fstab-generator.c source for details (or rather, missing tests of pass_no except against 0).

That means that while you could write other numbers like 17 these would only be tested against 0 and the exact value would otherwise be ignored.

Ned64
  • 8,726
  • I don't think "should" is the same as "must". – Codebling Oct 19 '19 at 21:05
  • @CodeBling I researched and added links to the source code. Please check and confirm (or comment) to see whether you read the same from the source as I. – Ned64 Oct 20 '19 at 13:37
  • I updated my answer with the information I found. Nice job finding this. It's strange that systemd maintains its own fsck binary which doesn't operate the same way as the default one. – Codebling Oct 20 '19 at 21:45
  • It's interesting that the manual is wrong in both cases. It says "there are only 3 options", but with util-linux any value above zero works (there are many options), and with systemd-fsck, all non-zero values are the same (there are only 2 options). – Codebling Oct 20 '19 at 21:52