OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man2 / swapon.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4 .\"
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.
8 .\"
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.
13 .\"
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
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
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.
36 .\"
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
46 .\"
47 .\"WORD:        swap                    ¥¹¥ï¥Ã¥×
48 .\"WORD:        block device            ¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹
49 .\"WORD:        super-user              ¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼
50 .\"WORD:        round robin             ¥é¥¦¥ó¥É¡¦¥í¥Ó¥ó
51 .\"WORD:        partition               ¥Ñ¡¼¥Æ¥£¥·¥ç¥ó
52 .\"WORD:        page                    ¥Ú¡¼¥¸
53 .\"WORD:        kernel                  ¥«¡¼¥Í¥ë
54 .\"
55 .TH SWAPON 2 2007-06-22 "Linux" "Linux Programmer's Manual"
56 .\"O .SH NAME
57 .SH Ì¾Á°
58 .\"O swapon, swapoff \- start/stop swapping to file/device
59 swapon, swapoff \- ¥Õ¥¡¥¤¥ë/¥Ç¥Ð¥¤¥¹¤Ø¤Î¥¹¥ï¥Ã¥×¤ò³«»Ï/Ää»ß¤¹¤ë
60 .\"O .SH SYNOPSIS
61 .SH ½ñ¼°
62 .B #include <unistd.h>
63 .br
64 .\"O .B #include <asm/page.h>     /* to find PAGE_SIZE */
65 .B #include <asm/page.h>     /* PAGE_SIZE ¤ò¸«¤Ä¤±¤ë¤¿¤á */
66 .br
67 .B #include <sys/swap.h>
68 .sp
69 .BI "int swapon(const char *" path ", int " swapflags );
70 .br
71 .BI "int swapoff(const char *" path );
72 .\"O .SH DESCRIPTION
73 .SH ÀâÌÀ
74 .\"O .BR swapon ()
75 .\"O sets the swap area to the file or block device specified by
76 .\"O .IR path .
77 .BR swapon ()
78 ¤Ï
79 .I path
80 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤ä¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤Ë¥¹¥ï¥Ã¥×Îΰè¤òÀßÄꤹ¤ë¡£
81 .\"O .BR swapoff ()
82 .\"O stops swapping to the file or block device specified by
83 .\"O .IR path .
84 .BR swapoff ()
85 ¤Ï
86 .I path
87 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤ä¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤Ø¤Î¥¹¥ï¥Ã¥×¤òÄä»ß¤¹¤ë¡£
88 .PP
89 .\"O .BR swapon ()
90 .\"O takes a
91 .\"O .I swapflags
92 .\"O argument.
93 .BR swapon ()
94 ¤Ï
95 .I swapflags
96 °ú¤­¿ô¤ò¼è¤ë¡£
97 .\"O If
98 .\"O .I swapflags
99 .\"O has the
100 .\"O .B SWAP_FLAG_PREFER
101 .\"O bit turned on, the new swap area will have a higher priority than default.
102 .I swapflags
103 ¤Ë
104 .B SWAP_FLAG_PREFER
105 ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢¿·¤·¤¤¥¹¥ï¥Ã¥×Îΰè¤Ï¥Ç¥Õ¥©¥ë¥È¤è¤ê¤â¹â¤¤
106 Í¥ÀèÅÙ¤ò»ý¤Ä¡£
107 .\"O The priority is encoded within
108 .\"O .I swapflags
109 .\"O as:
110 Í¥ÀèÅÙ¤Ï
111 .I swapflags
112 ¤Ë°Ê²¼¤Î¤è¤¦¤Ë¥³¡¼¥É²½¤µ¤ì¤Æ¤¤¤ë¡£
113 .br
114 .sp
115 .I "    (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK"
116 .br
117 .PP
118 .\"O These functions may only be used by a privileged process (one having the
119 .\"O .B CAP_SYS_ADMIN
120 .\"O capability).
121 ¤³¤ì¤é¤Î´Ø¿ô¤ÏÆø¢¥×¥í¥»¥¹
122 .RB ( CAP_SYS_ADMIN
123 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability) ¤ò»ý¤Ä¥×¥í¥»¥¹) ¤Î¤ß¤¬»ÈÍѤǤ­¤ë¡£
124 .\"O .SS Priority
125 .SS Í¥ÀèÅÙ
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 Ä㤤ͥÀèÅÙ¤ÎÎΰè¤Ë¤ª¤¤¤Æ¡¢¿·¤·¤¤Îΰè¤Ï¸Å¤¤Îΰè¤è¤ê¤µ¤é¤ËÄ㤤
133 Í¥ÀèÅÙ¤ò»ý¤Ä¡£
134 .PP
135 .\"O All priorities set with
136 .\"O .I swapflags
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.
140 .I swapflags
141 ¤¬ÀßÄꤵ¤ì¤¿¤â¤Î¤ÏÁ´¤Æ¹â¤¤Í¥ÀèÅ٤Ȥʤꡢ¥Ç¥Õ¥©¥ë¥È¤è¤ê¤â¹â¤¤Í¥ÀèÅÙ¤ò»ý¤Ä¡£
142 »ÈÍѼԤϤ½¤ì¤é¤ËÉé¤Ç¤Ê¤¤Ãͤ¬»ØÄê¤Ç¤­¤ë¡£
143 Â礭¤Ê¿ô»ú¤Ï¹â¤¤Í¥ÀèÅÙ¤ò°ÕÌ£¤¹¤ë¡£
144 .PP
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 ¥é¥¦¥ó¥É¡¦¥í¥Ó¥óÊý¼°¤ÇÇÛʬ¤µ¤ì¤ë¡£
157 .PP
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"
163 .SH ÊÖ¤êÃÍ
164 .\"O On success, zero is returned.
165 .\"O  On error, \-1 is returned, and
166 .\"O .I errno
167 .\"O is set appropriately.
168 À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
169 .I errno
170 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
171 .\"O .SH ERRORS
172 .SH ¥¨¥é¡¼
173 .TP
174 .B EBUSY
175 .\"O (for
176 .\"O .BR swapon ())
177 .\"O The specified
178 .\"O .I path
179 .\"O is already being used as a swap area.
180 .RB ( swapon ()
181 ¤Ë¤ª¤¤¤Æ) »ØÄꤵ¤ì¤¿
182 .I path
183 ¤¬´û¤Ë¥¹¥ï¥Ã¥×Îΰè¤È¤·¤Æ»ÈÍѤµ¤ì¤Æ¤¤¤ë¡£
184 .TP
185 .B EINVAL
186 .\"O The file
187 .\"O .I path
188 .\"O exists, but refers neither to a regular file nor to a block device;
189 ¥Õ¥¡¥¤¥ë
190 .I path
191 ¤Ï¸ºß¤¹¤ë¤¬¡¢Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤â¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤â»²¾È¤·¤Æ¤¤¤Ê¤¤¡£
192 .\"O or, for
193 .\"O .BR swapon (),
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
196 .\"O or, for
197 .\"O .BR swapoff (),
198 .\"O .I path
199 .\"O is not currently a swap area.
200 ¤Þ¤¿¤Ï
201 .BR swapon ()
202 ¤Ë¤ª¤¤¤Æ¡¢»ØÄꤵ¤ì¤¿ path ¤Î¥Õ¥¡¥¤¥ë¤¬Í­¸ú¤Ê¥¹¥ï¥Ã¥×¤Î½ð̾ (signature) ¤ò
203 ´Þ¤ó¤Ç¤¤¤Ê¤¤¤«¡¢tmpfs ¤Î¤è¤¦¤Ê¥¤¥ó¥á¥â¥ê (in-memory) ¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à
204 ¾å¤Ë¤¢¤ë¡£
205 ¤Þ¤¿¤Ï
206 .BR swapoff ()
207 ¤Ë¤ª¤¤¤Æ¡¢
208 .I path
209 ¤¬¸½ºß¤Î¤È¤³¤í¥¹¥ï¥Ã¥×Îΰè¤Ç¤Ê¤¤¡£
210 .TP
211 .B ENFILE
212 .\"O The system limit on the total number of open files has been reached.
213 ¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ÎÁí¿ô¤¬¥·¥¹¥Æ¥à¤ÎÀ©¸Â¤Ë㤷¤¿¡£
214 .TP
215 .B ENOENT
216 .\"O The file
217 .\"O .I path
218 .\"O does not exist.
219 ¥Õ¥¡¥¤¥ë
220 .I path
221 ¤¬Â¸ºß¤·¤Ê¤¤¡£
222 .TP
223 .B ENOMEM
224 .\"O The system has insufficient memory to start swapping.
225 ¥¹¥ï¥Ã¥×¤ò³«»Ï¤¹¤ë¤Î¤Ë½½Ê¬¤Ê¥á¥â¥ê¡¼¤¬¥·¥¹¥Æ¥à¤Ë¤Ê¤¤¡£
226 .TP
227 .B EPERM
228 .\"O The caller does not have the
229 .\"O .B CAP_SYS_ADMIN
230 .\"O capability.
231 .\"O Alternatively, the maximum number of swap files are already in use;
232 .\"O see NOTES below.
233 »ÈÍѼԤ¬
234 .B CAP_SYS_ADMIN
235 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
236 ¤â¤·¤¯¤Ï¡¢ºÇÂç¿ô¤Î¥¹¥ï¥Ã¥×¥Õ¥¡¥¤¥ë¤¬¤¹¤Ç¤Ë»ÈÍѤµ¤ì¤Æ¤¤¤ë
237 (²¼µ­¤Î¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È)¡£
238 .\"O .SH "CONFORMING TO"
239 .SH ½àµò
240 .\"O These functions are Linux-specific and should not be used in programs
241 .\"O intended to be portable.
242 ¤³¤ì¤é¤Î´Ø¿ô¤Ï Linux ÆÃÍ­¤Ç¤¢¤ê¡¢°Ü¿¢¤ò°Õ¿Þ¤·¤¿¥×¥í¥°¥é¥à¤Ç¤Ï
243 »ÈÍѤ·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£
244 .\"O The second
245 .\"O .I swapflags
246 .\"O argument was introduced in Linux 1.3.2.
247 ÆóÈÖÌܤÎ
248 .I swapflags
249 °ú¤­¿ô¤Ï Linux 1.3.2 ¤«¤éƳÆþ¤µ¤ì¤¿¡£
250 .\"O .SH NOTES
251 .SH Ãí°Õ
252 .\"O The partition or path must be prepared with
253 .\"O .BR mkswap (8).
254 ¥Ñ¡¼¥Æ¥£¥·¥ç¥ó¤ä¥Ñ¥¹¤Ï
255 .BR mkswap (8)
256 ¤Ë¤è¤Ã¤Æ½àÈ÷¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
257
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
268 .\"O option
269 .\"O (which reserves two swap table entries for the page migration features of
270 .\"O .BR mbind (2)
271 .\"O and
272 .\"O .BR migrate_pages (2)).
273 »ÈÍѤǤ­¤ë¥¹¥ï¥Ã¥×¥Õ¥¡¥¤¥ë¤Î¿ô¤Ë¤Ï¾å¸Â¤¬¤¢¤ê¡¢¤½¤Î¾å¸Â¤Ï
274 ¥«¡¼¥Í¥ëÄê¿ô
275 .B MAX_SWAPFILES
276 ¤ÇÄêµÁ¤µ¤ì¤ë¡£
277 .B MAX_SWAPFILES
278 ¤ÎÃͤϡ¢¥«¡¼¥Í¥ë 2.4.10 ¤è¤êÁ°¤Ç¤Ï 8¡¢
279 ¥«¡¼¥Í¥ë 2.4.10 °Ê¹ß¤Ç¤Ï 32 ¤Ç¤¢¤ë¡£
280 ¥«¡¼¥Í¥ë 2.6.18 °Ê¹ß¤Ç¤Ï¡¢¥«¡¼¥Í¥ë¤¬
281 .B CONFIG_MIGRATION
282 ¥ª¥×¥·¥ç¥ó¤òÍ­¸ú¤Ë¤·¤ÆºîÀ®¤µ¤ì¤¿¾ì¹ç¡¢
283 ¤³¤Î¾å¸Â¤¬ 2 ¾¯¤Ê¤¤ÃÍ (¤Ä¤Þ¤ê 30) ¤È¤Ê¤ë
284 (¤³¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
285 .BR mbind (2)
286 ¤È
287 .BR migrate_pages (2)
288 ¤Î¥Ú¡¼¥¸¡¦¥Þ¥¤¥°¥ì¡¼¥·¥ç¥óµ¡Ç½ÍѤ˥¹¥ï¥Ã¥×¡¦¥Æ¡¼¥Ö¥ë¤Î¥¨¥ó¥È¥ê¡¼¤¬
289 Æó¤ÄͽÌ󤵤ì¤ë)¡£
290 .\"O .SH "SEE ALSO"
291 .SH ´ØÏ¢¹àÌÜ
292 .BR mkswap (8),
293 .BR swapoff (8),
294 .BR swapon (8)