LoginSignup
12
12

More than 5 years have passed since last update.

AmazonLinux2 でswap領域作成

Last updated at Posted at 2018-08-28

Attach SWAP area to AmazonLinux2

自分用のメモです。

環境

% cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

手順

1Gバイトのスワップファイルを /swapfile において、Linuxのスワップ領域として利用します。

% sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
% sudo chmod 600 /swapfile
% sudo mkswap /swapfile
% free
              total        used        free      shared  buff/cache   available
Mem:        1011064       91304       72464        3516      847296      746632
Swap:             0           0           0

# この時点でfreeしてもまだシステムに認識させてないので0ですよ^^;

% sudo swapon /swapfile
% free
              total        used        free      shared  buff/cache   available
Mem:        1011064       92348       70168        3516      848548      745592
Swap:       1048572           0     1048572

# 認識されました!!

という感じです。
あとは/etc/fstab に書いとけば再起動してもswap割当てられます。

/swapfile  swap        swap    defaults        0   0 # 追記

以上。

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12