Ubuntu12.04 SWAP settings

Source: Internet
Author: User
When I installed Ubuntu12.04LTS, I did not set the SWAP partition during the installation due to disk partition problems. Later, when I was using it, the system sometimes failed to run smoothly, it seems that SWAP partitions are still needed. 1. Configure to use the newly created Swap partition Commandlist in Ubuntu: # Find the UUIDsudoblkid of the Swap partition # Add the new Swap partition sudogedit/In/ect/fstab/

When I installed Ubuntu 12.04 LTS, I did not set the SWAP partition during installation due to disk partitioning issues. Later, when I was using it, the system was sometimes not running smoothly, it seems that SWAP partitions are still needed.

1. Configure and use the newly created Swap partition in Ubuntu

Command list:

# Find the UUID of the Swap Partition

Sudo blkid

# Add a new Swap partition to/ect/fstab

Sudo gedit/etc/fstab

# Add the following content at the end. xxxx is the UUID of the Swap partition.

UUID = xxxx none swap sw 0 0

# Activate the Swap partition. The Swap partition is/dev/sda3.

Sudo swapon/dev/sda3

2. Use file in Ubuntu when swap

Command list:

# Create 1 1 GB file

Sudo dd if =/dev/zero of =/mnt/1GB. swap bs = 1 M count = 1024

# Format as Swap file

Sudo mkswap/mnt/1 GB. swap

# Add the swap file to the System

Sudo swapon/mnt/1 GB. swap

The preceding operation only temporarily adds one swap file. To add a swap file permanently, perform the following steps.

# Add a new Swap partition to/ect/fstab

Sudo gedit/etc/fstab

# Add the following content at the end

/Mnt/1 GB. swap none swap sw 0 0

3. Ubuntu swap Usage Policy

Command list:

# View memory/buffer/Swap usage.

Free

# View swap usage policies. Swap and memory account for of each

# The default value is 60, that is, Swap accounts for 60% and memory accounts for 40%.

Cat/proc/sys/vm/swappiness

# Modifying swap usage policies

# Valid only for this boot. The original value is restored after restart.

Sudo sysclt vm. swappiness = 20

# Modify the swap Usage Policy. Default Value:

# Takes effect only after the system is restarted

Sudo gedit/etc/sysctl. conf

# Add the following content at the end:

######################################## #########

# Set Swap usable availability

# Swap <-------> physical memory

# Default: 60% 40%

Vm. swappiness = 20

4. Disable swap

Sudo swapoff-

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

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.