Swap Memory On Amazon AWS(Linux Servers)
Hi ,
Although this is my first blog , Please excuse me , if I am wrong some where .
I am experienced Junior Software Developer with a demonstrated history of working in the computer software industry in Mumbai. Skills include analytical
thinking ,creative problem solving ,PHP frameworks and Server Engineering. Proficient with database programs including MongoDb and MYSQL
Server.
I will post commands to create a swap memory in aws .
This Below command will show you the existing swap memory in the server .
total used free shared buff/cache available
Mem: 983M 284M 150M 768K 549M 545M
Swap: 0B 0B 0B
You can see this this when you run the command, If you dont have any swap memory we can see is 0 byte
- sudo free -h
This will create a swap file in the server this above command will create a swap memory of 4 gb .
I will explain how it works :
4096K * 1024 | 4gb * 1
The swap memory must be the size of the ram - not more nor less (We are assuming we are having a ram size of 4 GB. )
- sudo dd if=/dev/zero of=/swapfile bs=4096K count=1024
Give the 600 permission to the swap file you will create.
- sudo chmod 600 /swapfile
Creation of the swap space
- sudo mkswap /swapfile
Enables the swap partition you created.
- sudo swapon -a /swapfile
After the above the command you will see the swap memory created , but its temporary swap memory because , One you restart your server the swap memory will be lost , So we need to add the command , when every time the system boots , swap memory should be initialised.
Go into etc folder and use you favourite editor to open the fstab file & add the line provided below. Those lines will initialise the swap memory after booting every time.
- sudo vi /etc/fstab
- swapfile swap swap defaults 0 0
Thank You for visiting my blog , if any doubts please comment down .
Cheers ✌
Very important notes on swap memory. Thank you. I'm looking forward for more blogs like this.
ReplyDelete