What is swap?
Swap space is the area on a hard disk which is part of the Virtual Memory of your machine, which is a combination of accessible physical memory (RAM) and the swap space. Swap space temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory for active processes and there is insufficient unused physical memory available. If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses. Note that the access time for swap is slower therefore do not consider it to be a complete replacement for the physical memory. Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
We will create a file called swapfile
in our root (/) directory. The file must allocate the amount of space we want for our swap file.
Create the Swap File on Ubuntu 12.04
1) Using the dd command
sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k
2) Prepare the swap file by creating a linux swap area:
sudo mkswap /swapfile
3) The results display:
Setting up swapspace version 1, size = 262140 KiB no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb
4) Activating the swap file:
sudo swapon /swapfile
As the demand for virtual private servers (VPS) continues to grow, businesses and individuals are faced with a crucial decision:…
Web hosting is a large industry, as many other factors help any web hosting provider to form a company. The…
Welcome to the complete guide to WordPress security best practices in 2024. As technology evolves rapidly, implementing strong security measures…
Hey, wanted to learn about web hosting? Or do you want to start a new website and need hosting? Questions…
In today's digital world, the threat of DDoS attacks has become increasingly prevalent. These types of attacks have the power…