Bug 195326 - swapon: /dev/md0: Read-only file system
Summary: swapon: /dev/md0: Read-only file system
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 10.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Hiroki Sato
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-24 05:45 UTC by Rihad
Modified: 2022-04-02 16:10 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rihad 2014-11-24 05:45:30 UTC
I have a single fs / (no separate /var /usr etc).

This line in /etc/fstab
md                      none            swap    sw,file=/var/swap 0        0

which used to set up swap file properly in 10-STABLE a few months old, started giving this error on startup after the upgrade to 10.1-RELEASE:

swapon: /dev/md0: Read-only file system

Adding the "late" option to fstab now fixes the issue:
... sw,file=/var/swap,late ...
Comment 1 Xin LI freebsd_committer freebsd_triage 2014-11-24 05:59:59 UTC
Over to Hiroki-san who made the swap changes that may be related to this issue.

Note that I don't think this is a recent change of behavior -- the code was in 10.0-RELEASE.  Additionally, it seems to be not fixable: swap is intentionally set to start before fsck, if there is only one UFS filesystem and swap is on a file, then the swap can not be made available if the file system is corrupted.
Comment 2 Rihad 2014-11-24 06:11:44 UTC
Thanks. This looks like a documentation issue, I think some mentioning of the early/late bootup semantics (/etc/rc.d/swaplate) would be appropriate in fstab's manpage where it describes setting up swap space via md.
Comment 3 Hiroki Sato freebsd_committer freebsd_triage 2014-11-25 21:47:59 UTC
Thank you your report.  This is partially due to a change in r272885 (10.1 also has this change).  Before this revision, "late" flag was automatically added when a "file=" was specified because the rc.d/swap script is invoked before mountcritlocal and fsck as Xin also pointed out.  It worked, but had a side-effect that "swapoff -a" did not handle a entry with "file=".  It was counter-intuitive for sysadmins because "late" was not always in /etc/fstab.

So now one should think "file=" always needs "late" flag and documentation should be updated to emphasize it.  I will work on it.
Comment 4 Bryan Drewery freebsd_committer freebsd_triage 2015-05-14 04:01:55 UTC
(In reply to Hiroki Sato from comment #3)
> Thank you your report.  This is partially due to a change in r272885 (10.1
> also has this change).  Before this revision, "late" flag was automatically
> added when a "file=" was specified because the rc.d/swap script is invoked
> before mountcritlocal and fsck as Xin also pointed out.  It worked, but had
> a side-effect that "swapoff -a" did not handle a entry with "file=".  It was
> counter-intuitive for sysadmins because "late" was not always in /etc/fstab.
> 
> So now one should think "file=" always needs "late" flag and documentation
> should be updated to emphasize it.  I will work on it.

Ping. It would be good to get the documentation in the manpage and handbook updated before 10.2.
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:43:02 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 6 Jason W. Bacon freebsd_committer freebsd_triage 2022-04-02 16:10:25 UTC
This seems to still be an issue on FreeBSD 13.0.

Any progress?

Thanks...