1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1995-07-22 by Michael Chastain <mec@duracef.shout.net>
28 .\" Modified 1995-07-23 by aeb
29 .\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 1998-09-08 by aeb
31 .\" Modified 2004-06-17 by Michael Kerrisk <mtk-manpages@gmx.net>
32 .\" Modified 2004-10-10 by aeb
33 .\" 2004-12-14 mtk, Anand Kumria: added new errors
35 .TH SWAPON 2 2004-10-10 "Linux 2.6.7" "Linux Programmer's Manual"
37 swapon, swapoff \- start/stop swapping to file/device
39 .B #include <unistd.h>
41 .B #include <asm/page.h> /* to find PAGE_SIZE */
43 .B #include <sys/swap.h>
45 .BI "int swapon(const char *" path ", int " swapflags );
47 .BI "int swapoff(const char *" path );
50 sets the swap area to the file or block device specified by
53 stops swapping to the file or block device specified by
64 bit turned on, the new swap area will have a higher priority than default.
65 The priority is encoded within
70 .I " (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK"
73 These functions may only be used by a privileged process (one having the
77 Each swap area has a priority, either high or low.
78 The default priority is low.
79 Within the low-priority areas,
80 newer areas are even lower priority than older areas.
82 All priorities set with
84 are high-priority, higher than default.
85 They may have any non-negative value chosen by the caller.
86 Higher numbers mean higher priority.
88 Swap pages are allocated from areas in priority order,
89 highest priority first.
90 For areas with different priorities,
91 a higher-priority area is exhausted before using a lower-priority area.
92 If two or more areas have the same priority,
93 and it is the highest priority available,
94 pages are allocated on a round-robin basis between them.
96 As of Linux 1.3.6, the kernel usually follows these rules,
97 but there are exceptions.
99 On success, zero is returned.
100 On error, \-1 is returned, and
102 is set appropriately.
110 is already being used as a swap area.
115 exists, but refers neither to a regular file nor to a block device;
118 the indicated path does not contain a valid swap signature;
122 is not currently a swap area.
125 The system limit on the total number of open files has been reached.
133 The system has insufficient memory to start swapping.
136 The caller does not have the
140 (earlier 8; 32 since Linux 2.4.10) are in use.
142 These functions are Linux specific and should not be used in programs
143 intended to be portable.
146 argument was introduced in Linux 1.3.2.
148 The partition or path must be prepared with