株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

AWSだったりAzureだったりのインスタンスで安い奴だとswap領域なしのものがあるよね。
そういう場合は、OS側で作ってしまえばいいみたい。

始めはない

[root@ip-172-31-38-16 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:            985          68          62           0         854         752
Swap:             0           0           0

1GBのswap領域を作る場合

[root@ip-172-31-38-16 ~]# dd if=/dev/zero of=/swap bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 14.3841 s, 74.6 MB/s
[root@ip-172-31-38-16 ~]#

[root@ip-172-31-38-16 ~]# mkswap /swap
mkswap: /swap: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=98a1a8c3-3446-4df0-88ad-22b099e35b07


[root@ip-172-31-38-16 ~]# swapon /swap
swapon: /swap: insecure permissions 0644, 0600 suggested.


[root@ip-172-31-38-16 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:            985          75          71           0         837         744
Swap:          1023           0        1023

<スポンサーリンク>

2 Comments

2 Records

  1. on 2019年5月2日 at 10:46 AM
    たに wrote:

    RedHatから、swap領域の推奨サイズが公開されているので、参考にするとよいかと思います。
    swap領域は、パーミッションを600にすることをおすすめします。
    また、この状態では、swap領域の自動起動が設定されていないので、必要に応じて、自動起動の設定をします。

    https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-swapspace

    返信
    • on 2019年5月17日 at 5:39 AM
      yuta wrote:

      ありがとうございます。
      AWSとかで安いインスタンス借りて、こっちで勝手にswap作ればやっぱ節約できてるんですかね。

      返信

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)