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