3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[メモ] swapファイルの作り方

Last updated at Posted at 2018-02-06

swapファイルの作り方

AWS の EC2 で t2.micro 使っていて、ついビルドしようとしたらメモリが少し足りなかったので、インスタンスタイプ変えるのもありですけど swapファイル追加しちゃおうという時のメモです。

1. swapファイルの作り方

# swapon -s
# dd if=/dev/zero of=/swapfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 15.7361 s, 68.2 MB/s
# chmod 600 /swapfile
# mkswap /swapfile
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=20d6eaf0-adca-41a7-b8bd-0f03d7bbbfaf

2. swapファイルの追加

# swapon /swapfile
# swapon -s
Filename                                Type            Size    Used    Priority
/swapfile                               file            1048572 0       -1

3. swapファイルの削除

# swapoff /swapfile

4. /etc/fstabの場合

/swapfile        swap        swap    defaults        0 0
3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?