Go to main content

マニュアルページ セクション 8: システム管理コマンド

印刷ビューの終了

更新: 2022年7月27日
 
 

swap(8)

名前

swap - スワップ管理インタフェース

形式

/usr/sbin/swap -a swapname [swaplow] [swaplen]
/usr/sbin/swap -d swapname [swaplow]
/usr/sbin/swap -l [-h | -k | --scale[=item1,item2,...]]
/usr/sbin/swap -s [-h | --scale[=item1,item2,...]]

説明

swap ユーティリティーは、メモリーマネージャーが使用するシステムスワップ領域を追加、削除、および監視する方法を提供します。

オプション

サポートしているオプションは、次のとおりです。

–a swapname [swaplow] [swaplen]

指定されたスワップ領域を追加します。このオプションは、File System Management 権利プロファイルまたは root を割り当てられた管理者のみが使用できます。swapname は、スワップ領域または通常ファイルの名前です。ZFS ファイルシステムを実行しているシステムでは、/dev/zvol/dsk/rpool/swap などの ZFS ボリュームをスワップ領域として指定します。ZFS ファイルシステムでは、スワップに通常ファイルを使用することはできません。さらに、スワップ領域とダンプデバイスの両方に同じ ZFS ボリュームを使用することはできません。

swaplow は、ファイル内でスワップ領域を開始する場所のオフセット (512 バイトブロック単位) です。swaplen は、スワップ領域の望ましい長さ (512 バイトブロック単位) です。swaplen の値を 16 より小さくすることはできません。たとえば、n ブロックが指定された場合は、(n-1) ブロックが実際のスワップの長さになります。swaplen は、少なくとも 1 ページの長さにする必要があります。メモリーのページのサイズは、pagesize コマンドを使用して決定できます。See pagesize(1).If the swap file is not a ZFS volume or lofi device the first page of a swap file is automatically skipped, and as a swap file needs to be at least one page in length, the minimum size should be a multiple of 2 pagesize bytes.メモリーのページのサイズは、マシンに依存します。

swaplow + swaplen は、スワップファイルのサイズ以下にする必要があります。swaplen が指定されていない場合は、swaplow から始まり、指定されたファイルの最後まで拡張された領域が追加されます。If neither swaplow nor swaplen are specified, the whole file or device will be used.For swap files that are not ZFS volume or lofi devices the first page is skipped to protect any label that might be present.

スワップ領域は、システムの起動中に svc:/system/swap サービスによって自動的に追加されます。このサービスは、/etc/vfstab ファイルで指定されたすべてのスワップ領域を追加します。これらの指定の構文については、vfstab(5) のマニュアルページを参照してください。

ZFS volumes used as a swap device will always be encrypted regardless of the value of the encryption property for the ZFS volume.See zfs_encrypt(8).

NFS またはローカルファイルシステム swapname を使用するには、最初に mkfile(8) を使用してファイルを作成するようにしてください。ローカルファイルシステムのスワップファイルの場合は、swap –a コマンドを実行するだけで、稼働中のシステムに追加できます。NFS マウントされたスワップファイルの場合は、サーバーがファイルをエクスポートする必要があります。これを行うには、次の手順を実行します。

  1. NFS サーバーでこれを実行します。

    share -F nfs -o  \
    rw=clientname,root=clientname directory-with-swap-file 
  2. クライアントで、次の行を /etc/vfstab に追加します。

    server:directory-with-swap-file -
    local-path-to-directory nfs    -   yes   -
    local-path-to-directory/swap-file -  -
    swap   - no    - 
  3. クライアントで NFS クライアントサービスを有効にします。

    svcadm enable nfs/client
  4. Reboot the client.

–d swapname

指定されたスワップ領域を削除します。This option can only be used by an administrator who is assigned the File System Management rights profile or by root. swapname is the name of the swap file: for example, /dev/dsk/c0t0d0s1 or a regular file. swaplow is the offset in 512-byte blocks into the swap area to be deleted.swaplow が指定されていない場合は、第 2 ページから領域の削除が開始されます。このコマンドが完了すると、この領域からスワップブロックを割り当てることはできなくなり、以前このスワップ領域で使用されていたすべてのスワップブロックがほかのスワップ領域に移動されています。

–h

すべてのサイズが人間の読める形式にスケーリングされます。The –h option is equivalent to using the –scale=max,1024 option.

–k

ファイルサイズを 1024 バイトの単位で出力します。

–l

すべてのスワップ領域のステータスを一覧表示します。The output has these columns:

path

スワップ領域のパス名。

dev

ブロック特殊デバイスの場合は、メジャー/マイナーデバイス番号 (10 進数)。それ以外の場合は 0。

swaplo

領域の swaplow 値 (512 バイトブロック単位)。

blocks

領域の swaplen 値 (512 バイトブロック単位)。

free

この領域内で現在割り当てられていない 512 バイトブロックの数。

encrypted

Shows yes if the device is encrypted and no otherwise.

この空間は特定のスワップ領域には関連付けられていないため、このリストには物理メモリーの形式でのスワップ空間は含まれません。

If swap –l is run while swapname is in the process of being deleted (by swap –d), the string INDEL will appear in a seventh column of the swap stats.

–s

全体のスワップ空間の使用量および利用可能量に関するサマリー情報を出力します。

allocated

バッキングストアとして使用するように現在割り当てられているスワップ空間の合計容量 (バイト単位)。

reserved

現在は割り当てられていないが、あとから使用できるようにメモリーマッピングによって確保されているスワップ空間の合計容量 (バイト単位)。

used

割り当て済みまたは予約済みのスワップ空間の合計容量 (バイト単位)。

available

あとから予約や割り当てに使用可能な合計スワップ空間 (バイト単位)。

These numbers include swap space from all configured swap areas as listed by the –l option, as well as swap space in the form of physical memory.

–scale[=item1,item2,...]

すべてのサイズが人間の読める形式にスケーリングされます。Scaling is done by repetitively dividing by 1024, unless otherwise specified.

–scale specified without arguments enables default scaled output, and is equivalent to –scale=max,1024.

–scale can be specified with the following arguments.

binary

Scaling is done by repetitively dividing by a scale factor of 1024.The use of binary scaling is indicated by the addition of an 'i' modifier to the suffix (Ki, Mi, Gi, ...).

max

Values are scaled to the largest unit for which the result retains a non-zero integer part.Up to 2 decimal places of fractional output may be shown.

min

Values are scaled to the smallest unit capable of showing the full value within the allotted space of 5 columns, and displayed without the use of fractional output.

minwide

Values are scaled to the smallest unit capable of showing the full value within the allotted space of 8 columns, and displayed without the use of fractional output.

1000

Scaling is done by repetitively dividing by a scale factor of 1000.

1024

Scaling is done by repetitively dividing by a scale factor of 1024.

使用法

2 ギガバイトを超えるブロックデバイスは、263 マイナス 1 バイトまでのスワップに完全に使用できます。

環境変数

swap の実行に影響を与える環境変数 LC_CTYPE および LC_MESSAGE については、environ(7) を参照してください。

属性

属性についての詳細は、マニュアルページの attributes(7) を参照してください。

属性タイプ
属性値
使用条件
system/core-os

関連項目

pagesize(1), getpagesize(3C), vfstab(5), attributes(7), mkfile(8), shareall(8), zfs(8), zfs_encrypt(8)

For information about setting up a swap area with ZFS, see the book Managing ZFS File Systems in Oracle Solaris 11.4.

警告

追加されるスワップ領域が既存のファイルシステムとオーバーラップするかどうかかの確認は行われません。

History

Support for the –scale option was added to the swap command in Oracle Solaris 11.4.30.

The encrypted column was added to the output of the –l option in Oracle Solaris 11.4.24.

The –h and –k options were added to the swap command in Oracle Solaris 11.0, thanks to a contribution by Yann Poupet to the OpenSolaris project.

The swap command; with support for the –a, –d, –l, and –s options; was added to Solaris in the Solaris 2.0 release, replacing the swapon command used in SunOS 4.