Score:3

Why doesn't mount wait for systemd.fsck to finish running?

cn flag

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.

meuh avatar
in flag
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.
Score:2
ar flag

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.

cn flag
Since I have it set to 0 now, wouldn't that mean fsck shouldn't run at all?
vidarlo avatar
ar flag
@StevenT.Snyder yes. But it will have to check the journal when mounting. But you will not have a full fsck.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.