Swap addition and optimization for system switching in Ubuntu

Source: Internet
Author: User
Tags file system

The Ubuntu system adds the swap partition step:

Add this partition a little advantage: can increase the memory size of 32-bit system recognition (no this section only identify 3G, add this section to recognize 4G)

1, check the status of the current swap partition:

Cat/proc/meminfo

swaptotal:0 KB

swapfree:0 KB

If the above two items are 0, there is no swap partition, if not 0, then this section

2, check the/root directory and how much space is available:

System-> System Management-> System Monitor-> file system

Look at the amount of free space, the size of the swap can be based on the size of the root available space, the more free space, swap can be set up a little bit, swap space is divided from the root directory

This column more highlights: http://www.bianceng.cn/OS/Linux/

At the same time can look at: System Monitor-> system, kernel and memory information to see if the kernel is upgraded to more than 4G of memory can be recognized? If the memory size is displayed as 3.8G, the kernel recognizes 4G memory.

3, if there is currently a swap partition, you need to adjust the size of the swap, you must first do the following:

A, find the directory where Swap.disk is located

B. The directory where the CD enters the Swap.disk

C. sudo swapoff swap.disk

D. sudo rm swap.disk

4. Reassign the swap size (if there is no Swap.disk directory before, it is recommended to enter the "/" root directory to execute the following instructions):

A. sudo dd if=/dev/zero of=swap.disk bs=1m count=6k (count=1k create 1G swap, count=6k if you want to create 6G; This step is slower)

B. sudo mkswap-f swap.disk

C. sudo swapon swap.disk

5, see the distribution of the swap after the situation:

swaptotal:6291452 KB

swapfree:6291452 KB

Ubuntu system optimized swap partition step:

In Ubuntu, the size of the swappiness value has a big connection to how the swap partition is used. Swappiness=0 the maximum use of physical memory, and then the swap space, swappiness=100 when the positive use of the swap partition, and the memory of the data in a timely manner into the swap space. Two extremes, for Ubuntu's default setting, this value is equal to 60, and the recommended modification is 10. To do this specifically:

1. View the swappiness in your system

$ cat/proc/sys/vm/swappiness

No surprises, you should see it's 60.

2. Modify Swappiness value to 10

$ sudo sysctl vm.swappiness=10

But this is just a temporary change, you will restore the default 60 after you reboot the system, so you have to do one more step:

$ Gksudo gedit/etc/sysctl.conf

At the end of this document, add this line:

vm.swappiness=10

Then save and reboot. OK, your settings are in effect. You will find that the rabbit is running faster now!

Of course, you can use other editors to modify, such as Kate,vi,vim,nano ... Just have to replace gedit with them OK! Because considering the GNOME desktop that most people use, write the gedit.

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.