Can I use a pass value higher than 2 in fstab?

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?

Asked By: Codebling

||

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.

Answered By: Ned64

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.

Answered By: Codebling
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.