About Swap Space

Source: Internet
Author: User
Swap space, also known as virtual storage partition (partition), is primarily used to store program and program data that is contained in the main memory, which is a non-recurring requirement, to allow more concurrent process execution.

Swap space can be implemented by one or more logical partitions, one or more physical disks, swap files (swap file). During the installation of Ubuntu
You will be prompted to create a swap space, but you can also choose to install Ubuntu after creation, or not at all if you have enough physical memory:-)

1. How to choose the swap space implementation, is a logical partition or swap files.
The realization of logical partition is better than swap file, which has the advantages of faster and certain physical fault tolerance, but it also has some disadvantage of adjusting space size in future.

2. How to choose the size of swap space.
By older rules, the swap space is usually set to 2 to 3 times times the size of the physical memory ram, which is an old rule and a relatively simple rule, but it's also a good start:) The size of the swap space is mainly determined by the main use of Ubuntu, the physical memory of the machine, and the available disk space 3 factors.

The problem is not the result of the selection, but the choice. My machine has 1GB of RAM and also made a 1GB swap space, but I found that I would use a small (less than 200MB) swap space In addition to the suspend. So, I choose to use 512MBswap file to achieve swap space, if someone has the same choice as me, the following swap file to implement Swap space method can be used for reference.

STEP-1 Create swap file:
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288
Above BS * count = Swap space (Bytes), here is a 512MB swap file named Swapfile under/path, where swap files are not important.

Step-2 Set Swap space:
$ sudo mkswap/swapfile

Step-3 Configuring crontab Startup files:
First, to
$ sudo crontab-e
Set the crontab file to edit state; Second, add the following line of text to the crontab file
@reboot sudo swapon/swapfile

Step-4 restart

Step-5 detection of swap space usage:
can use
$ free-m
Or GKRELLM (a GUI detection tool) to detect the usage of swap space.
If you are not satisfied with the usage of the swap space, you can follow Step-6 and Step-7 to disable the swap space first, and then re-adjust the swap space by Step-1 to STEP4. The ability to easily adjust the size of the swap space is an advantage of using swap files to achieve swap space.

Step-6 Disable swap space:
First of all
$ sudo swapoff/swapfile
Next, delete the line of text that you added in Step-3.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.