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@gmail.com>
32 .\" Modified 2004-10-10 by aeb
33 .\" 2004-12-14 mtk, Anand Kumria: added new errors
34 .\" 2007-06-22 Ivana Varekova <varekova@redhat.com>, mtk
35 .\" Update text describing limit on number of swap files.
37 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
38 .\" all rights reserved.
39 .\" Translated Mon Mar 3 23:54:56 JST 1997
40 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
41 .\" Modified Tue Dec 1 00:08:07 JST 1998
42 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
43 .\" Updated & Modified Fri Feb 11 07:40:12 JST 2005
44 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
45 .\" Updated 2007-09-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.64
47 .\"WORD: swap ¥¹¥ï¥Ã¥×
48 .\"WORD: block device ¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹
49 .\"WORD: super-user ¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼
50 .\"WORD: round robin ¥é¥¦¥ó¥É¡¦¥í¥Ó¥ó
51 .\"WORD: partition ¥Ñ¡¼¥Æ¥£¥·¥ç¥ó
53 .\"WORD: kernel ¥«¡¼¥Í¥ë
55 .TH SWAPON 2 2007-06-22 "Linux" "Linux Programmer's Manual"
58 .\"O swapon, swapoff \- start/stop swapping to file/device
59 swapon, swapoff \- ¥Õ¥¡¥¤¥ë/¥Ç¥Ð¥¤¥¹¤Ø¤Î¥¹¥ï¥Ã¥×¤ò³«»Ï/Ää»ß¤¹¤ë
62 .B #include <unistd.h>
64 .\"O .B #include <asm/page.h> /* to find PAGE_SIZE */
65 .B #include <asm/page.h> /* PAGE_SIZE ¤ò¸«¤Ä¤±¤ë¤¿¤á */
67 .B #include <sys/swap.h>
69 .BI "int swapon(const char *" path ", int " swapflags );
71 .BI "int swapoff(const char *" path );
75 .\"O sets the swap area to the file or block device specified by
80 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤ä¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤Ë¥¹¥ï¥Ã¥×Îΰè¤òÀßÄꤹ¤ë¡£
82 .\"O stops swapping to the file or block device specified by
87 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤ä¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤Ø¤Î¥¹¥ï¥Ã¥×¤òÄä»ß¤¹¤ë¡£
100 .\"O .B SWAP_FLAG_PREFER
101 .\"O bit turned on, the new swap area will have a higher priority than default.
105 ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢¿·¤·¤¤¥¹¥ï¥Ã¥×Îΰè¤Ï¥Ç¥Õ¥©¥ë¥È¤è¤ê¤â¹â¤¤
107 .\"O The priority is encoded within
112 ¤Ë°Ê²¼¤Î¤è¤¦¤Ë¥³¡¼¥É²½¤µ¤ì¤Æ¤¤¤ë¡£
115 .I " (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK"
118 .\"O These functions may only be used by a privileged process (one having the
119 .\"O .B CAP_SYS_ADMIN
121 ¤³¤ì¤é¤Î´Ø¿ô¤ÏÆø¢¥×¥í¥»¥¹
123 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability) ¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬»ÈÍѤǤ¤ë¡£
126 .\"O Each swap area has a priority, either high or low.
127 .\"O The default priority is low.
128 .\"O Within the low-priority areas,
129 .\"O newer areas are even lower priority than older areas.
130 ¤½¤ì¤¾¤ì¤Î¥¹¥ï¥Ã¥×Îΰè¤Ï¹â (high) ¤ÈÄã (low) ¤Î¤É¤Á¤é¤«¤ÎÍ¥ÀèÅÙ¤ò»ý¤Ä¡£
131 ¥Ç¥Õ¥©¥ë¥È¤ÎÍ¥ÀèÅÙ¤ÏÄã¤Ç¤¢¤ë¡£
132 Ä㤤ͥÀèÅÙ¤ÎÎΰè¤Ë¤ª¤¤¤Æ¡¢¿·¤·¤¤Îΰè¤Ï¸Å¤¤Îΰè¤è¤ê¤µ¤é¤ËÄ㤤
135 .\"O All priorities set with
137 .\"O are high-priority, higher than default.
138 .\"O They may have any nonnegative value chosen by the caller.
139 .\"O Higher numbers mean higher priority.
141 ¤¬ÀßÄꤵ¤ì¤¿¤â¤Î¤ÏÁ´¤Æ¹â¤¤Í¥ÀèÅ٤Ȥʤꡢ¥Ç¥Õ¥©¥ë¥È¤è¤ê¤â¹â¤¤Í¥ÀèÅÙ¤ò»ý¤Ä¡£
142 »ÈÍѼԤϤ½¤ì¤é¤ËÉé¤Ç¤Ê¤¤Ãͤ¬»ØÄê¤Ç¤¤ë¡£
143 Â礤ʿô»ú¤Ï¹â¤¤Í¥ÀèÅÙ¤ò°ÕÌ£¤¹¤ë¡£
145 .\"O Swap pages are allocated from areas in priority order,
146 .\"O highest priority first.
147 .\"O For areas with different priorities,
148 .\"O a higher-priority area is exhausted before using a lower-priority area.
149 .\"O If two or more areas have the same priority,
150 .\"O and it is the highest priority available,
151 .\"O pages are allocated on a round-robin basis between them.
152 ¹â¤¤Í¥ÀèÅÙ¤ÎÎΰ褫¤é½ç¤Ë¥¹¥ï¥Ã¥×¡¦¥Ú¡¼¥¸¤È¤·¤Æ»ÈÍѤµ¤ì¤ë¡£
153 ¤è¤êÄ㤤ͥÀèÅÙ¤ÎÎΰè¤ò»ÈÍѤ¹¤ëÁ°¤Ë¤è¤ê¹â¤¤Í¥ÀèÅÙ¤Î
154 Îΰè¤ò»È¤¤Àڤ롣¤â¤·Æó¤Ä°Ê¾å¤ÎÎΰ褬Ʊ¤¸Í¥ÀèÅÙ¤ò»ý¤Á¡¢
155 »È¤¨¤ëÃæ¤Ç°ìÈֹ⤤ͥÀèÅ٤Ǥ¢¤ì¤Ð¡¢¤½¤ì¤é¤Î¥Ú¡¼¥¸¤Ï´Ö¤Ç
156 ¥é¥¦¥ó¥É¡¦¥í¥Ó¥óÊý¼°¤ÇÇÛʬ¤µ¤ì¤ë¡£
158 .\"O As of Linux 1.3.6, the kernel usually follows these rules,
159 .\"O but there are exceptions.
160 Linux 1.3.6 ¤Ë¤ª¤¤¤Æ¡¢¥«¡¼¥Í¥ë¤ÏÄ̾ï¤Ï¤³¤ì¤é¤Îµ¬Â§¤Ë½¾¤Ã¤Æ¤¤¤ë¡£
161 ¤·¤«¤·Îã³°¤â¸ºß¤·¤Æ¤¤¤ë¡£
162 .\"O .SH "RETURN VALUE"
164 .\"O On success, zero is returned.
165 .\"O On error, \-1 is returned, and
167 .\"O is set appropriately.
168 À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
179 .\"O is already being used as a swap area.
183 ¤¬´û¤Ë¥¹¥ï¥Ã¥×Îΰè¤È¤·¤Æ»ÈÍѤµ¤ì¤Æ¤¤¤ë¡£
188 .\"O exists, but refers neither to a regular file nor to a block device;
191 ¤Ï¸ºß¤¹¤ë¤¬¡¢Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤â¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤â»²¾È¤·¤Æ¤¤¤Ê¤¤¡£
194 .\"O the indicated path does not contain a valid swap signature or
195 .\"O resides on an in-memory file system like tmpfs; or, for
199 .\"O is not currently a swap area.
202 ¤Ë¤ª¤¤¤Æ¡¢»ØÄꤵ¤ì¤¿ path ¤Î¥Õ¥¡¥¤¥ë¤¬Í¸ú¤Ê¥¹¥ï¥Ã¥×¤Î½ð̾ (signature) ¤ò
203 ´Þ¤ó¤Ç¤¤¤Ê¤¤¤«¡¢tmpfs ¤Î¤è¤¦¤Ê¥¤¥ó¥á¥â¥ê (in-memory) ¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à
209 ¤¬¸½ºß¤Î¤È¤³¤í¥¹¥ï¥Ã¥×Îΰè¤Ç¤Ê¤¤¡£
212 .\"O The system limit on the total number of open files has been reached.
213 ¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ÎÁí¿ô¤¬¥·¥¹¥Æ¥à¤ÎÀ©¸Â¤Ë㤷¤¿¡£
224 .\"O The system has insufficient memory to start swapping.
225 ¥¹¥ï¥Ã¥×¤ò³«»Ï¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¡¼¤¬¥·¥¹¥Æ¥à¤Ë¤Ê¤¤¡£
228 .\"O The caller does not have the
229 .\"O .B CAP_SYS_ADMIN
231 .\"O Alternatively, the maximum number of swap files are already in use;
232 .\"O see NOTES below.
235 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
236 ¤â¤·¤¯¤Ï¡¢ºÇÂç¿ô¤Î¥¹¥ï¥Ã¥×¥Õ¥¡¥¤¥ë¤¬¤¹¤Ç¤Ë»ÈÍѤµ¤ì¤Æ¤¤¤ë
237 (²¼µ¤Î¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È)¡£
238 .\"O .SH "CONFORMING TO"
240 .\"O These functions are Linux-specific and should not be used in programs
241 .\"O intended to be portable.
242 ¤³¤ì¤é¤Î´Ø¿ô¤Ï Linux ÆÃͤǤ¢¤ê¡¢°Ü¿¢¤ò°Õ¿Þ¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï
246 .\"O argument was introduced in Linux 1.3.2.
249 °ú¤¿ô¤Ï Linux 1.3.2 ¤«¤éƳÆþ¤µ¤ì¤¿¡£
252 .\"O The partition or path must be prepared with
254 ¥Ñ¡¼¥Æ¥£¥·¥ç¥ó¤ä¥Ñ¥¹¤Ï
256 ¤Ë¤è¤Ã¤Æ½àÈ÷¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
258 .\"O There is an upper limit on the number of swap files that may be used,
259 .\"O defined by the kernel constant
260 .\"O .BR MAX_SWAPFILES .
261 .\"O Before kernel 2.4.10,
262 .\"O .B MAX_SWAPFILES
263 .\"O has the value 8;
264 .\"O since kernel 2.4.10, it has the value 32.
265 .\"O Since kernel 2.6.18, the limit is decreased by 2 (thus: 30)
266 .\"O if the kernel is built with the
267 .\"O .B CONFIG_MIGRATION
269 .\"O (which reserves two swap table entries for the page migration features of
272 .\"O .BR migrate_pages (2)).
273 »ÈÍѤǤ¤ë¥¹¥ï¥Ã¥×¥Õ¥¡¥¤¥ë¤Î¿ô¤Ë¤Ï¾å¸Â¤¬¤¢¤ê¡¢¤½¤Î¾å¸Â¤Ï
278 ¤ÎÃͤϡ¢¥«¡¼¥Í¥ë 2.4.10 ¤è¤êÁ°¤Ç¤Ï 8¡¢
279 ¥«¡¼¥Í¥ë 2.4.10 °Ê¹ß¤Ç¤Ï 32 ¤Ç¤¢¤ë¡£
280 ¥«¡¼¥Í¥ë 2.6.18 °Ê¹ß¤Ç¤Ï¡¢¥«¡¼¥Í¥ë¤¬
282 ¥ª¥×¥·¥ç¥ó¤ò͸ú¤Ë¤·¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¡¢
283 ¤³¤Î¾å¸Â¤¬ 2 ¾¯¤Ê¤¤ÃÍ (¤Ä¤Þ¤ê 30) ¤È¤Ê¤ë
287 .BR migrate_pages (2)
288 ¤Î¥Ú¡¼¥¸¡¦¥Þ¥¤¥°¥ì¡¼¥·¥ç¥óµ¡Ç½ÍѤ˥¹¥ï¥Ã¥×¡¦¥Æ¡¼¥Ö¥ë¤Î¥¨¥ó¥È¥ê¡¼¤¬