dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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