OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / 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 .\"*******************************************************************
38 .\"
39 .\" This file was generated with po4a. Translate the source file.
40 .\"
41 .\"*******************************************************************
42 .TH SWAPON 2 2010\-11\-15 Linux "Linux Programmer's Manual"
43 .SH 名前
44 swapon, swapoff \- ファイル/デバイスへのスワップを開始/停止する
45 .SH 書式
46 \fB#include <unistd.h>\fP
47 .br
48 \fB#include <asm/page.h> /* PAGE_SIZE を見つけるため */\fP
49 .br
50 \fB#include <sys/swap.h>\fP
51 .sp
52 \fBint swapon(const char *\fP\fIpath\fP\fB, int \fP\fIswapflags\fP\fB);\fP
53 .br
54 \fBint swapoff(const char *\fP\fIpath\fP\fB);\fP
55 .SH 説明
56 \fBswapon\fP()  は \fIpath\fP で指定されたファイルやブロック・デバイスにスワップ領域を設定する。 \fBswapoff\fP()  は
57 \fIpath\fP で指定されたファイルやブロック・デバイスへのスワップを停止する。
58 .PP
59 \fBswapon\fP() の \fIswapflags\fP 引き数に \fBSWAP_FLAG_PREFER\fP フラグが指定された場合、
60 新しいスワップ領域はデフォルトよりも高い優先度を持つ。
61 優先度は以下のように変換されて \fIswapflags\fP に指定する。
62 .br
63 .sp
64 \fI(prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK\fP
65 .br
66 .PP
67 \fBSWAP_FLAG_DISCARD\fP フラグが \fBswapon\fP() の \fIswapflags\fP 引き数に指定された場合、
68 スワップデバイスが破棄 (discard) 操作や trim 操作をサポートしている場合には、
69 解放されたスワップページは再利用される前に破棄される
70 (これにより、SSD (Solid State Device) によっては性能が向上することがあるが、
71 たいていは性能の向上はない)。
72 「注意」も参照のこと。
73 .PP
74 これらの関数は特権プロセス (\fBCAP_SYS_ADMIN\fP ケーパビリティ (capability) を持つプロセス) のみが使用できる。
75 .SS 優先度
76 それぞれのスワップ領域は高 (high) と低 (low) のどちらかの優先度を持つ。 デフォルトの優先度は低である。
77 低い優先度の領域において、新しい領域は古い領域よりさらに低い 優先度を持つ。
78 .PP
79 \fIswapflags\fP が設定されたものは全て高い優先度となり、デフォルトよりも高い優先度を持つ。 使用者はそれらに負でない値が指定できる。
80 大きな数字は高い優先度を意味する。
81 .PP
82 高い優先度の領域から順にスワップ・ページとして使用される。 より低い優先度の領域を使用する前により高い優先度の
83 領域を使い切る。もし二つ以上の領域が同じ優先度を持ち、 使える中で一番高い優先度であれば、それらのページは間で ラウンド・ロビン方式で配分される。
84 .PP
85 Linux 1.3.6 において、カーネルは通常はこれらの規則に従っている。 しかし例外も存在している。
86 .SH 返り値
87 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
88 .SH エラー
89 .TP 
90 \fBEBUSY\fP
91 (\fBswapon\fP()  において) 指定された \fIpath\fP が既にスワップ領域として使用されている。
92 .TP 
93 \fBEINVAL\fP
94 ファイル \fIpath\fP は存在するが、通常のファイルもブロック・デバイスも参照していない。 または \fBswapon\fP()  において、指定された
95 path のファイルが有効なスワップの署名 (signature) を 含んでいないか、tmpfs のようなインメモリ (in\-memory)
96 のファイルシステム 上にある。 または \fBswapoff\fP()  において、 \fIpath\fP が現在のところスワップ領域でない。
97 .TP 
98 \fBENFILE\fP
99 オープンされたファイルの総数がシステム全体の上限に達していた。
100 .TP 
101 \fBENOENT\fP
102 ファイル \fIpath\fP が存在しない。
103 .TP 
104 \fBENOMEM\fP
105 スワップを開始するのに十分なメモリーがシステムにない。
106 .TP 
107 \fBEPERM\fP
108 使用者が \fBCAP_SYS_ADMIN\fP ケーパビリティを持っていない。 もしくは、最大数のスワップファイルがすでに使用されている
109 (下記の「注意」の節を参照)。
110 .SH 準拠
111 これらの関数は Linux 特有であり、移植を意図したプログラムでは 使用してはいけない。 二番目の \fIswapflags\fP 引き数は Linux
112 1.3.2 から導入された。
113 .SH 注意
114 パーティションやパスは \fBmkswap\fP(8)  によって準備されていなければならない。
115
116 使用できるスワップファイルの数には上限があり、その上限は カーネル定数 \fBMAX_SWAPFILES\fP で定義される。
117 \fBMAX_SWAPFILES\fP の値は、カーネル 2.4.10 より前では 8、 カーネル 2.4.10 以降では 32 である。 カーネル
118 2.6.18 以降では、カーネルが \fBCONFIG_MIGRATION\fP オプションを有効にして作成された場合、 この上限が 2 少ない値 (つまり
119 30) となる (このカーネルでは、 \fBmbind\fP(2)  と \fBmigrate_pages\fP(2)
120 のページ・マイグレーション機能用にスワップ・テーブルのエントリーが 二つ予約される)。 カーネル 2.6.32 以降では、カーネルが
121 \fBCONFIG_MEMORY_FAILURE\fP オプションを有効にして作成された場合、 この上限がさらに 1 少ない値となる。
122
123 .\" To be precise: 2.6.35.5
124 スワップページの破棄は、カーネル 2.6.29 で導入され、その後カーネル 2.6.36 で
125 \fBSWAP_FLAG_DISCARD\fP フラグが指定された場合にだけ実行されるようになったが、
126 今でも、このフラグビットが指定されていない場合であっても、
127 \fBswapon\fP が呼び出された際にスワップ領域全体の破棄が行われる。
128 .SH 関連項目
129 \fBmkswap\fP(8), \fBswapoff\fP(8), \fBswapon\fP(8)