Here’s the way I added swap file in AWS EC2 , t2.medium. At that time, I was using Jenkins in the computer, and Jenkins didn’t work because of less swap area.
Procedure
Create a file for swapping. I created 4GB file.
$ sudo dd if = / dev / zero of = / var / swapfile bs = 1M count = 4096
4096 + 0 records in
4096 + 0 records out
4294967296 bytes ( 4.3 GB ) copied , 57.8032 s , 74.3 MB / s
Format the file for swap.
$ sudo mkswap / var / swapfile
Setting up swapspace version 1 , size = 4194300 KiB
no label , UUID = b32db3ee - 02db - 4e1c - 9a7a - 06b5aa19b790
Change permission of the file.
$ sudo chmod 600 / var / swapfile
Enable swapping.
$ sudo swapon / var / swapfile
Check swapping.
cat / proc / swaps
Filename Type Size Used Priority
/ var / swapfile file 4194300 0 - 1
Modify /etc/fstab
for auto mounting.
LABEL = / / ext4 defaults , noatime 1 1
tmpfs / dev / shm tmpfs defaults 0 0
devpts / dev / pts devpts gid = 5 , mode = 620 0 0
sysfs / sys sysfs defaults 0 0
proc / proc proc defaults 0 0
swap / var / swapfile swap defaults 0 0
Readers who viewed this page, also viewed:
Post navigation
A Life Summary of an Gypsy