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
Managing files on your Amazon EC2 instances can often feel like navigating a complex maze, especially when you prefer a…
Welcome to the world of database management with MySQL Workbench! If you're new to databases or looking for a powerful,…
Setting up a favicon for your website might seem like a small detail, but in 2025, it's more crucial than…
Due to the growing demand for artificial intelligence, two names stand out as titans in the realm of conversational AI:…
Search engines are evolving rapidly, and they’re equivalent to refining their algorithms to sort the user experience. A significant manifestation…