Bug 262580 - fsck fails system startup if USB disk is not yet configured
Summary: fsck fails system startup if USB disk is not yet configured
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 13.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-16 00:41 UTC by Mike Karels
Modified: 2022-03-16 23:58 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Karels freebsd_committer freebsd_triage 2022-03-16 00:41:57 UTC
I have a USB disk listed in /etc/fstab on a Raspberry Pi 4 system; the USB disk is not root.  When booting 13.1-BETA1, the system startup fails because fsck cannot open the disk device; the disk then configures shortly thereafter.  I discovered that this setup worked in 13.0-RELEASE because fsck failed to open the disk, but then exited with status 3, causing /etc/rc.d/fsck to invoke root_hold_wait() from /etc/rc.subr.  Once the USB bus and disk configured, fsck was re-run successfully.  In 13.1-BETA1, fsck exits with a status of 8 after failing to open the disk, aborting the startup.  I verified that the relevant change was in fsck by copying fsck* from 13.0 onto the 13.1 system; that combination works.
Comment 1 Kirk McKusick freebsd_committer freebsd_triage 2022-03-16 18:19:16 UTC
I have worked with Mike Karels to find a fix which will be committed shortly.
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-03-16 18:39:40 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2983ec0a87a18943564548c5c00c879c8db83edf

commit 2983ec0a87a18943564548c5c00c879c8db83edf
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-03-16 18:37:15 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-03-16 18:37:15 +0000

    Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code
    for missing devices.

    The fsck_ffs(8) utility uses its internal function openfilesys()
    when opening a disk to be checked. This change avoids the use
    of pfatal() in openfilesys() which always exits with failure (exit
    value 8) so that the caller can choose the correct exit value.
    In the case of a non-existent device it should exit with value 3
    which allows the startup system to wait for drives (such as those
    attached by USB) to come online.

    Reported by: karels
    Tested by:   karels
    PR:          262580
    MFC after:   3 days

 sbin/fsck_ffs/setup.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-03-16 22:58:20 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=934ba51bc929ee23248353a081a4cc4327a4ec54

commit 934ba51bc929ee23248353a081a4cc4327a4ec54
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-03-16 18:37:15 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-03-16 22:56:52 +0000

    Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices.

    PR:          262580
    Approved by: re (gjb, early MFC)

    (cherry picked from commit 2983ec0a87a18943564548c5c00c879c8db83edf)

 sbin/fsck_ffs/setup.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-03-16 23:31:27 UTC
A commit in branch releng/13.1 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=47b50c23185bed6759e5ce1345dba45e5ca703a3

commit 47b50c23185bed6759e5ce1345dba45e5ca703a3
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-03-16 18:37:15 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-03-16 23:14:57 +0000

    Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices.

    PR:          262580
    Approved by: re (gjb, early MFC)

    (cherry picked from commit 2983ec0a87a18943564548c5c00c879c8db83edf)
    (cherry picked from commit 934ba51bc929ee23248353a081a4cc4327a4ec54)

 sbin/fsck_ffs/setup.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Comment 5 Kirk McKusick freebsd_committer freebsd_triage 2022-03-16 23:58:34 UTC
Fix has been MFC'ed to 13-stable and releng-13.1