util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fstab format, 4th field mandatory and the "sw" value
@ 2023-03-29 13:03 Christoph Anton Mitterer
  2023-04-04 10:13 ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Anton Mitterer @ 2023-03-29 13:03 UTC (permalink / raw)
  To: util-linux

Hey.

The following is in principle just cosmetic.


I recently wondered[0] what fstab entries for swap areas should look
like.

Some resources recommend e.g.:
  <swap-device/file> none swap sw 0 0
others somehting like:
  <swap-device/file> swap swap defaults 0 0


fstab(5) describes the appropriate values for swap for fields 1 to 3
(inclusive).
But it gives nothing about the 4th.
Neither do e.g. the manpages mount(8) or swapon(8).
Especially there seems to be no longer any mention of "sw"

getfsent(3) still contains a reference to "sw",... seems it comes
originally from BSD.


"default", which is documented as:
> use default options: rw, suid, dev, exec, auto, nouser, and async.

doesn't seem to be the best choice either.

Personally I'd have said that - from the documented values alone -
"auto,nouser" perhaps in addition with "rw" might the most fitting
choice.

fstab(5) even seems to make either "rw" or "ro" mandatory, by saying:
> It contains at least the type of mount (ro or rw)

which I don't thin is however really enforced (neither would it mention
any such thing for auto vs. noauto).


In the thread at [0], a participant suggested that the most appropriate
entry would be simply:
  <swap-device/file> none swap
i.e. omitting the 4-6th fields.


However, at least by fstab(5), the 4th field (unlike #5 and #6) does
seem to be required.


*If* fstab(5) is considered to be like a formal description of the
fstab format it would be nice if the following could be clarified:
- Whether or not "rw" respectively "ro" are really required (or whether
  absence of both of them (and absence of "defaults") causes an
  implicit default to be used.
  The same for auto/noauto.
- Whether he 4th field is mandatory and if not, what that means.
  Is it the meaning of "defaults" or is it nothing except for the
  "implicit defaults" of ro/rw noauto/auto?
- Whether or not the other special values from getfsent(3), i.e. "rq",
  "sw", "xx" still have any meaning for linux (and if it's just that
  they're ignored)... and similar as it's done for fields 1-3, what
  should be used for swap areas.

Along with that, it might perhaps make sense to replace "swap
partition(s)" with "swap device(s)", as a swap device doesn't need to
be a partition.


Thanks,
Chris.


[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1033630

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fstab format, 4th field mandatory and the "sw" value
  2023-03-29 13:03 fstab format, 4th field mandatory and the "sw" value Christoph Anton Mitterer
@ 2023-04-04 10:13 ` Karel Zak
  2023-04-05 23:01   ` Christoph Anton Mitterer
  0 siblings, 1 reply; 3+ messages in thread
From: Karel Zak @ 2023-04-04 10:13 UTC (permalink / raw)
  To: Christoph Anton Mitterer; +Cc: util-linux

On Wed, Mar 29, 2023 at 03:03:16PM +0200, Christoph Anton Mitterer wrote:
> The following is in principle just cosmetic.

OK, let's be academic ;-)

> I recently wondered[0] what fstab entries for swap areas should look
> like.
> 
> Some resources recommend e.g.:
>   <swap-device/file> none swap sw 0 0
> others somehting like:
>   <swap-device/file> swap swap defaults 0 0
> 
> 
> fstab(5) describes the appropriate values for swap for fields 1 to 3
> (inclusive).
> But it gives nothing about the 4th.

For libmount/mount(8)/swapon, everything after 3rd field is optional.

> Neither do e.g. the manpages mount(8) or swapon(8).
> Especially there seems to be no longer any mention of "sw"
> 
> getfsent(3) still contains a reference to "sw",... seems it comes
> originally from BSD.

swapon(1) supports pri= or discard= options, so the field makes sense

> "default", which is documented as:
> > use default options: rw, suid, dev, exec, auto, nouser, and async.

The "default" should be described better on the man page. I'll fix it.
Its _kernel_ default for the filesystem, mount, or swapon has no
built-in default.

> doesn't seem to be the best choice either.

Frankly, "default" would be the best do describe what happen for a
swap area or an FS.

> Personally I'd have said that - from the documented values alone -
> "auto,nouser" perhaps in addition with "rw" might the most fitting
> choice.
> 
> fstab(5) even seems to make either "rw" or "ro" mandatory, by saying:
> > It contains at least the type of mount (ro or rw)
> 
> which I don't thin is however really enforced (neither would it mention
> any such thing for auto vs. noauto).

The default is rw, the man page is wrong here.

> In the thread at [0], a participant suggested that the most appropriate
> entry would be simply:
>   <swap-device/file> none swap
> i.e. omitting the 4-6th fields.
> 
> 
> However, at least by fstab(5), the 4th field (unlike #5 and #6) does
> seem to be required.

It depends who read the man page, I can imagine that some parsers
requires it.

> *If* fstab(5) is considered to be like a formal description of the
> fstab format it would be nice if the following could be clarified:
> - Whether or not "rw" respectively "ro" are really required (or whether
>   absence of both of them (and absence of "defaults") causes an
>   implicit default to be used.
>   The same for auto/noauto.
> - Whether he 4th field is mandatory and if not, what that means.
>   Is it the meaning of "defaults" or is it nothing except for the
>   "implicit defaults" of ro/rw noauto/auto?
> - Whether or not the other special values from getfsent(3), i.e. "rq",
>   "sw", "xx" still have any meaning for linux (and if it's just that
>   they're ignored)... and similar as it's done for fields 1-3, what
>   should be used for swap areas.

I have committed:
https://github.com/util-linux/util-linux/commit/43a6b183d8945cc91307f21adc8070254eb925b5

I'm unsure if this is explicit enough, but it answers the basics (I hope).

> Along with that, it might perhaps make sense to replace "swap
> partition(s)" with "swap device(s)", as a swap device doesn't need to
> be a partition.

Good point.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fstab format, 4th field mandatory and the "sw" value
  2023-04-04 10:13 ` Karel Zak
@ 2023-04-05 23:01   ` Christoph Anton Mitterer
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Anton Mitterer @ 2023-04-05 23:01 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

Hey Karel.


On Tue, 2023-04-04 at 12:13 +0200, Karel Zak wrote:
> I have committed:
> https://github.com/util-linux/util-linux/commit/43a6b183d8945cc91307f21adc8070254eb925b5

I think it's fine.

Thanks for the clarifications.


Cheers,
Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-05 23:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 13:03 fstab format, 4th field mandatory and the "sw" value Christoph Anton Mitterer
2023-04-04 10:13 ` Karel Zak
2023-04-05 23:01   ` Christoph Anton Mitterer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).