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@xxxxxxxxxx> http://karelzak.blogspot.com