dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0180-swapon-mkswap-sync-man-page-with-upstream.patch

553d6a
From ec6f608028249480bae04c062089cb9120fcd8bd Mon Sep 17 00:00:00 2001
553d6a
From: Karel Zak <kzak@redhat.com>
553d6a
Date: Thu, 21 Mar 2019 13:21:54 +0100
553d6a
Subject: [PATCH 180/185] swapon, mkswap: sync man page with upstream
553d6a
553d6a
Clean up all notes about swap-area restrictions (fallocate, XFS,
553d6a
BTRFS, NFS, ...)
553d6a
553d6a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1203378
553d6a
Signed-off-by: Karel Zak <kzak@redhat.com>
553d6a
---
553d6a
 disk-utils/mkswap.8 |  42 +++++-----
553d6a
 sys-utils/swapon.8  | 186 ++++++++++++++++++++------------------------
553d6a
 2 files changed, 104 insertions(+), 124 deletions(-)
553d6a
553d6a
diff --git a/disk-utils/mkswap.8 b/disk-utils/mkswap.8
553d6a
index 6435dd6ae..b57433388 100644
553d6a
--- a/disk-utils/mkswap.8
553d6a
+++ b/disk-utils/mkswap.8
553d6a
@@ -1,14 +1,13 @@
553d6a
 .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl)
553d6a
 .\"
553d6a
 .\" May be distributed under the GNU General Public License
553d6a
-.\" Rewritten for 2.1.117, aeb, 981010.
553d6a
 .\"
553d6a
 .TH MKSWAP 8 "March 2009" "util-linux" "System Administration"
553d6a
 .SH NAME
553d6a
 mkswap \- set up a Linux swap area
553d6a
 .SH SYNOPSIS
553d6a
 .B mkswap
553d6a
-.RI [ options ]
553d6a
+[options]
553d6a
 .I device
553d6a
 .RI [ size ]
553d6a
 .SH DESCRIPTION
553d6a
@@ -32,14 +31,14 @@ parameter is superfluous but retained for backwards compatibility.
553d6a
 (It specifies the desired size of the swap area in 1024-byte blocks.
553d6a
 .B mkswap
553d6a
 will use the entire partition or file if it is omitted.
553d6a
-Specifying it is unwise -- a typo may destroy your disk.)
553d6a
+Specifying it is unwise \(en a typo may destroy your disk.)
553d6a
 
553d6a
 After creating the swap area, you need the
553d6a
 .B swapon
553d6a
 command to start using it.  Usually swap areas are listed in
553d6a
 .I /etc/fstab
553d6a
 so that they can be taken into use at boot time by a
553d6a
-.B swapon -a
553d6a
+.B swapon \-a
553d6a
 command in some boot script.
553d6a
 
553d6a
 .SH WARNING
553d6a
@@ -54,7 +53,7 @@ like many others mkfs-like utils,
553d6a
 However,
553d6a
 .B mkswap
553d6a
 refuses to erase the first block on a device with a disk
553d6a
-label (SUN, BSD, ...).
553d6a
+label (SUN, BSD, \&...\&).
553d6a
 
553d6a
 .SH OPTIONS
553d6a
 .TP
553d6a
@@ -103,48 +102,47 @@ Display version information and exit.
553d6a
 .SH NOTES
553d6a
 The maximum useful size of a swap area depends on the architecture and
553d6a
 the kernel version.
553d6a
-It is roughly 2GiB on i386, PPC, m68k and ARM, 1GiB on sparc, 512MiB on mips,
553d6a
-128GiB on alpha, and 3TiB on sparc64.  For kernels after 2.3.3 (May 1999) there is no
553d6a
-such limitation.
553d6a
 
553d6a
-Note that before version 2.1.117 the kernel allocated one byte for each page,
553d6a
-while it now allocates two bytes, so that taking into use a swap area of 2 GiB
553d6a
-might require 2 MiB of kernel memory.
553d6a
+The maximum number of the pages that is possible to address by swap area header
553d6a
+is 4294967295 (32-bit unsigned int).  The remaining space on the swap device is ignored.
553d6a
 
553d6a
-Presently, Linux allows 32 swap areas (this was 8 before Linux 2.4.10 (Sep 2001)).
553d6a
+Presently, Linux allows 32 swap areas.
553d6a
 The areas in use can be seen in the file
553d6a
 .I /proc/swaps
553d6a
-(since 2.1.25 (Sep 1997)).
553d6a
 
553d6a
 .B mkswap
553d6a
 refuses areas smaller than 10 pages.
553d6a
 
553d6a
 If you don't know the page size that your machine uses, you may be
553d6a
-able to look it up with "cat /proc/cpuinfo" (or you may not --
553d6a
+able to look it up with "cat /proc/cpuinfo" (or you may not \(en
553d6a
 the contents of this file depend on architecture and kernel version).
553d6a
 
553d6a
 To set up a swap file, it is necessary to create that file before
553d6a
 initializing it with
553d6a
 .BR mkswap ,
553d6a
-e.g. using a command like
553d6a
+e.g.\& using a command like
553d6a
 
553d6a
 .nf
553d6a
 .RS
553d6a
-# fallocate --length 8GiB swapfile
553d6a
+# dd if=/dev/zero of=swapfile bs=1MiB count=$((8*1024))
553d6a
 .RE
553d6a
 .fi
553d6a
 
553d6a
-Note that a swap file must not contain any holes (so, using
553d6a
-.BR cp (1)
553d6a
-to create the file is not acceptable).
553d6a
+to create 8GiB swapfile.
553d6a
+
553d6a
+Please read notes from
553d6a
+.BR swapon (8)
553d6a
+about
553d6a
+.B the swap file use restrictions
553d6a
+(holes, preallocation and copy-on-write issues).
553d6a
 
553d6a
 .SH ENVIRONMENT
553d6a
-.IP LIBBLKID_DEBUG=0xffff
553d6a
-enables debug output.
553d6a
+.IP LIBBLKID_DEBUG=all
553d6a
+enables libblkid debug output.
553d6a
 
553d6a
 .SH "SEE ALSO"
553d6a
 .BR fdisk (8),
553d6a
 .BR swapon (8)
553d6a
 .SH AVAILABILITY
553d6a
 The mkswap command is part of the util-linux package and is available from
553d6a
-ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
553d6a
+https://www.kernel.org/pub/linux/utils/util-linux/.
553d6a
diff --git a/sys-utils/swapon.8 b/sys-utils/swapon.8
553d6a
index 836b17277..a45b38865 100644
553d6a
--- a/sys-utils/swapon.8
553d6a
+++ b/sys-utils/swapon.8
553d6a
@@ -31,59 +31,24 @@
553d6a
 .\"
553d6a
 .\"     @(#)swapon.8	6.3 (Berkeley) 3/16/91
553d6a
 .\"
553d6a
-.\" Sun Dec 27 12:31:30 1992: Modified by faith@cs.unc.edu
553d6a
-.\" Sat Mar  6 20:46:02 1993: Modified by faith@cs.unc.edu
553d6a
-.\" Sat Oct  9 09:35:30 1993: Converted to man format by faith@cs.unc.edu
553d6a
-.\" Sat Nov 27 20:22:42 1993: Updated authorship information, faith@cs.unc.edu
553d6a
-.\" Mon Sep 25 14:12:38 1995: Added -v and -p information
553d6a
-.\" Tue Apr 30 03:32:07 1996: Added some text from A. Koppenhoefer
553d6a
-.\"
553d6a
-.TH SWAPON 8 "September 1995" "util-linux" "System Administration"
553d6a
+.TH SWAPON 8 "October 2014" "util-linux" "System Administration"
553d6a
 .SH NAME
553d6a
 swapon, swapoff \- enable/disable devices and files for paging and swapping
553d6a
 .SH SYNOPSIS
553d6a
-Get info:
553d6a
-.br
553d6a
-.in +5
553d6a
-.B swapon \-s
553d6a
-.RB [ \-h ]
553d6a
-.RB [ \-V ]
553d6a
-.sp
553d6a
-.in -5
553d6a
-Enable/disable:
553d6a
-.br
553d6a
-.in +5
553d6a
 .B swapon
553d6a
-.RB [ \-d ]
553d6a
-.RB [ \-f ]
553d6a
-.RB [ \-p
553d6a
-.IR priority ]
553d6a
-.RB [ \-v ]
553d6a
-.IR specialfile ...
553d6a
+[options]
553d6a
+.RI [ specialfile ...]
553d6a
 .br
553d6a
 .B swapoff
553d6a
-.RB [ \-v ]
553d6a
-.IR specialfile ...
553d6a
-.sp
553d6a
-.in -5
553d6a
-Enable/disable all:
553d6a
-.br
553d6a
-.in +5
553d6a
-.B swapon \-a
553d6a
-.RB [ \-e ]
553d6a
-.RB [ \-f ]
553d6a
-.RB [ \-v ]
553d6a
-.br
553d6a
-.B swapoff \-a
553d6a
-.RB [ \-v ]
553d6a
-.in -5
553d6a
+.RB [ \-va ]
553d6a
+.RI [ specialfile ...]
553d6a
 .SH DESCRIPTION
553d6a
 .B swapon
553d6a
 is used to specify devices on which paging and swapping are to take place.
553d6a
 
553d6a
 The device or file used is given by the
553d6a
 .I specialfile
553d6a
-parameter. It may be of the form
553d6a
+parameter.  It may be of the form
553d6a
 .BI \-L " label"
553d6a
 or
553d6a
 .BI \-U " uuid"
553d6a
@@ -105,82 +70,85 @@ flag is given, swapping is disabled on all known swap devices and files
553d6a
 or
553d6a
 .IR /etc/fstab ).
553d6a
 
553d6a
+.SH OPTIONS
553d6a
 .TP
553d6a
-.B "\-a, \-\-all"
553d6a
+.BR \-a , " \-\-all"
553d6a
 All devices marked as ``swap'' in
553d6a
 .I /etc/fstab
553d6a
 are made available, except for those with the ``noauto'' option.
553d6a
 Devices that are already being used as swap are silently skipped.
553d6a
 .TP
553d6a
-.B "\-d, \-\-discard\fR [=\fIpolicy\fR]"
553d6a
+.BR \-d , " \-\-discard" [ =\fIpolicy\fR]
553d6a
 Enable swap discards, if the swap backing device supports the discard or
553d6a
-trim operation. This may improve performance on some Solid State Devices,
553d6a
-but often it does not. The option allows one to select between two
553d6a
+trim operation.  This may improve performance on some Solid State Devices,
553d6a
+but often it does not.  The option allows one to select between two
553d6a
 available swap discard policies:
553d6a
-.BI \-\-discard=once
553d6a
+.B \-\-discard=once
553d6a
 to perform a single-time discard operation for the whole swap area at swapon;
553d6a
 or
553d6a
-.BI \-\-discard=pages
553d6a
-to discard freed swap pages before they are reused, while swapping.
553d6a
+.B \-\-discard=pages
553d6a
+to asynchronously discard freed swap pages before they are available for reuse.
553d6a
 If no policy is selected, the default behavior is to enable both discard types.
553d6a
 The
553d6a
 .I /etc/fstab
553d6a
 mount options
553d6a
-.BI discard,
553d6a
-.BI discard=once,
553d6a
+.BR discard ,
553d6a
+.BR discard=once ,
553d6a
 or
553d6a
-.BI discard=pages
553d6a
-may be also used to enable discard flags.
553d6a
+.B discard=pages
553d6a
+may also be used to enable discard flags.
553d6a
 .TP
553d6a
-.B "\-e, \-\-ifexists"
553d6a
+.BR \-e , " \-\-ifexists"
553d6a
 Silently skip devices that do not exist.
553d6a
 The
553d6a
 .I /etc/fstab
553d6a
 mount option
553d6a
-.BI nofail
553d6a
-may be also used to skip non-existing device.
553d6a
+.B nofail
553d6a
+may also be used to skip non-existing device.
553d6a
 
553d6a
 .TP
553d6a
-.B "\-f, \-\-fixpgsz"
553d6a
-Reinitialize (exec /sbin/mkswap) the swap space if its page size does not
553d6a
+.BR \-f , " \-\-fixpgsz"
553d6a
+Reinitialize (exec mkswap) the swap space if its page size does not
553d6a
 match that of the current running kernel.
553d6a
 .BR mkswap (2)
553d6a
 initializes the whole device and does not check for bad blocks.
553d6a
 .TP
553d6a
-.B \-h, \-\-help
553d6a
-Provide help.
553d6a
+.BR \-h , " \-\-help"
553d6a
+Display help text and exit.
553d6a
 .TP
553d6a
-.B "\-L \fIlabel\fP"
553d6a
+.BI \-L " label"
553d6a
 Use the partition that has the specified
553d6a
 .IR label .
553d6a
 (For this, access to
553d6a
 .I /proc/partitions
553d6a
 is needed.)
553d6a
 .TP
553d6a
-.B "\-p, \-\-priority \fIpriority\fP"
553d6a
+.BR \-p , " \-\-priority " \fIpriority\fP
553d6a
 Specify the priority of the swap device.
553d6a
 .I priority
553d6a
 is a value between \-1 and 32767.  Higher numbers indicate
553d6a
 higher priority.  See
553d6a
 .BR swapon (2)
553d6a
-for a full description of swap priorities. Add
553d6a
+for a full description of swap priorities.  Add
553d6a
 .BI pri= value
553d6a
 to the option field of
553d6a
 .I /etc/fstab
553d6a
 for use with
553d6a
 .BR "swapon -a" .
553d6a
-When priority is not defined it defaults to \-1.
553d6a
+When no priority is defined, it defaults to \-1.
553d6a
 .TP
553d6a
-.B "\-s, \-\-summary"
553d6a
-Display swap usage summary by device. Equivalent to "cat /proc/swaps".
553d6a
-Not available before Linux 2.1.25.
553d6a
+.BR \-s , " \-\-summary"
553d6a
+Display swap usage summary by device.  Equivalent to "cat /proc/swaps".
553d6a
+This output format is DEPRECATED in favour
553d6a
+of \fB\-\-show\fR that provides better control on output data.
553d6a
 .TP
553d6a
-\fB\-\-show\fR [\fIcolumn,column\fR]
553d6a
-Display definable device table similar to
553d6a
-.B \-\-summary
553d6a
-output.  See \-\-help output for
553d6a
-.I column
553d6a
-list.
553d6a
+.BR \-\-show [ =\fIcolumn\fR ...]
553d6a
+Display a definable table of swap areas.  See the
553d6a
+.B \-\-help
553d6a
+output for a list of available columns.
553d6a
+.TP
553d6a
+.B \-\-output\-all
553d6a
+Output all available columns.
553d6a
 .TP
553d6a
 .B \-\-noheadings
553d6a
 Do not print headings when displaying
553d6a
@@ -195,51 +163,65 @@ output without aligning table columns.
553d6a
 .B \-\-bytes
553d6a
 Display swap size in bytes in
553d6a
 .B \-\-show
553d6a
-output instead of user friendly size and unit.
553d6a
-.B "\-U \fIuuid\fP"
553d6a
+output instead of in user-friendly units.
553d6a
+.TP
553d6a
+.BI \-U  " uuid"
553d6a
 Use the partition that has the specified
553d6a
 .IR uuid .
553d6a
 .TP
553d6a
-.B "\-v, \-\-verbose"
553d6a
+.BR \-v , " \-\-verbose"
553d6a
 Be verbose.
553d6a
 .TP
553d6a
-.B "\-V, \-\-version"
553d6a
-Display version.
553d6a
+.BR \-V , " \-\-version"
553d6a
+Display version information and exit.
553d6a
 .SH NOTES
553d6a
-You should not use
553d6a
-.B swapon
553d6a
-on a file with holes.
553d6a
-Swap over NFS may not work.
553d6a
-.PP
553d6a
+.SS Files with holes
553d6a
+The swap file implementation in the kernel expects to be able to write to the
553d6a
+file directly, without the assistance of the filesystem.  This is a problem on
553d6a
+files with holes or on copy-on-write files on filesystems like Btrfs.
553d6a
+.sp
553d6a
+Commands like
553d6a
+.BR cp (1)
553d6a
+or
553d6a
+.BR truncate (1)
553d6a
+create files with holes.  These files will be rejected by swapon.
553d6a
+.sp
553d6a
+Preallocated files created by
553d6a
+.BR fallocate (1)
553d6a
+may be interpreted as files with holes too depending of the filesystem.
553d6a
+Preallocated swap files are supported on XFS since Linux 4.18.
553d6a
+.sp
553d6a
+The most portable solution to create a swap file is to use
553d6a
+.BR dd (1)
553d6a
+and /dev/zero.
553d6a
+.SS Btrfs
553d6a
+Swap files on Btrfs are supported since Linux 5.0 on files with nocow attribute.
553d6a
+See the
553d6a
+.BR btrfs (5)
553d6a
+manual page for more details.
553d6a
+.SS NFS
553d6a
+Swap over \fBNFS\fR may not work.
553d6a
+.SS Suspend
553d6a
 .B swapon
553d6a
-automatically detects and rewrites swap space signature with old software
553d6a
-suspend data (e.g S1SUSPEND, S2SUSPEND, ...). The problem is that if we don't
553d6a
+automatically detects and rewrites a swap space signature with old software
553d6a
+suspend data (e.g. S1SUSPEND, S2SUSPEND, ...). The problem is that if we don't
553d6a
 do it, then we get data corruption the next time an attempt at unsuspending is
553d6a
 made.
553d6a
-.PP
553d6a
-.B swapon
553d6a
-may not work correctly when using a swap file with some versions of btrfs.
553d6a
-This is due to the swap file implementation in the kernel expecting to be able
553d6a
-to write to the file directly, without the assistance of the file system.
553d6a
-Since btrfs is a copy-on-write file system, the file location may not be
553d6a
-static and corruption can result. Btrfs actively disallows the use of files
553d6a
-on its file systems by refusing to map the file. This can be seen in the system
553d6a
-log as "swapon: swapfile has holes." One possible workaround is to map the
553d6a
-file to a loopback device. This will allow the file system to determine the
553d6a
-mapping properly but may come with a performance impact.
553d6a
-
553d6a
 .SH ENVIRONMENT
553d6a
-.IP LIBMOUNT_DEBUG=0xffff
553d6a
-enables debug output.
553d6a
+.IP LIBMOUNT_DEBUG=all
553d6a
+enables libmount debug output.
553d6a
+.IP LIBBLKID_DEBUG=all
553d6a
+enables libblkid debug output.
553d6a
 
553d6a
 .SH SEE ALSO
553d6a
-.BR swapon (2),
553d6a
 .BR swapoff (2),
553d6a
+.BR swapon (2),
553d6a
 .BR fstab (5),
553d6a
 .BR init (8),
553d6a
+.BR fallocate (1),
553d6a
 .BR mkswap (8),
553d6a
-.BR rc (8),
553d6a
-.BR mount (8)
553d6a
+.BR mount (8),
553d6a
+.BR rc (8)
553d6a
 .SH FILES
553d6a
 .br
553d6a
 .I /dev/sd??
553d6a
@@ -253,4 +235,4 @@ The
553d6a
 command appeared in 4.0BSD.
553d6a
 .SH AVAILABILITY
553d6a
 The swapon command is part of the util-linux package and is available from
553d6a
-ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
553d6a
+https://www.kernel.org/pub/linux/utils/util-linux/.
553d6a
-- 
553d6a
2.20.1
553d6a