3

Whenever systemd.fsck actually has to do a repair* at boot time, automatic mounting of my partition fails because the mount command doesn't wait until [email protected] is done.

How do I ensure that mount waits until the file system check service finishes instead of failing immediately because the file system check was started?

The relevant line in fstab looks like this:

LABEL=cfdata   /data   ext4  defaults,nofail,x-systemd.device-timeout=60     0 0

(the label cfdata is on /dev/sda1)

The relevant systemd logs look like this when there's a failed mount at boot:

Jun 23 06:24:45 dev-machine-1 kernel:  sda: sda1
Jun 23 06:24:45 dev-machine-1 kernel: sd 0:0:0:0: [sda] Attached SCSI disk
Jun 23 06:24:47 dev-machine-1 systemd[1]: Starting File System Check on /dev/sda1...
Jun 23 06:24:47 dev-machine-1 mount[5563]: mount: /data: /dev/sda1 already mounted or mount point busy.
Jun 23 06:24:47 dev-machine-1 systemd-fsck[5483]: cfdata: recovering journal
Jun 23 06:24:49 dev-machine-1 systemd-fsck[5483]: cfdata: Clearing orphaned inode 13 (uid=0, gid=0, mode=0100644, size=39685)
Jun 23 06:24:49 dev-machine-1 systemd-fsck[5483]: cfdata: clean, 2767944/29310976 files, 75558004/117212630 blocks
Jun 23 06:24:49 dev-machine-1 systemd[1]: Started File System Check on /dev/sda1.
Jun 23 06:24:49 dev-machine-1 kernel: EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)

When this happens, the drive gets mounted to /media/<uuid> instead of my mount point in fstab.

Note: When [email protected] has to do a repair, output in the journal will be something like: Clearing orphaned inode 13 (uid=0, gid=0, mode=0100644, size=39685). The mount problem only happens when fsck is actually doing something like this and holds up the device.

1
  • 1
    Look at the appropriate unit file in /run/systemd/generator/ to see if it has a Requires=systemd-fsck@... line or not and if this matches the fstab 6th field being 0 or not. If it is ending up in /media doesn't that mean it is udisks2 that is doing a fsck-before-mount, so perhaps it is starting too soon somehow.
    – meuh
    Jun 24, 2021 at 9:03

1 Answer 1

2

Tell your system to include it in the file system check list:

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 filesystemshould 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.

(From man fstab)

Make the line read

LABEL=cfdata   /data   ext4  defaults,nofail,x-systemd.device-timeout=60     0 2

And it should be handled automatically.

2
  • 1
    Since I have it set to 0 now, wouldn't that mean fsck shouldn't run at all? Jun 23, 2021 at 22:45
  • @StevenT.Snyder yes. But it will have to check the journal when mounting. But you will not have a full fsck.
    – vidarlo
    Jun 24, 2021 at 7:31

You must log in to answer this question.

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