Chen Kozhan
========================
Operating environment: Ubuntu Server 14.04 LTS
=========================
Brief introduction
1. What is a swap partition and what is the role of
2. How to set the swap partition
===================================================
1. What is a swap partition and what is the role?
Swap partition, swap partition, that is, when your physical memory is not enough, the space portion of the hard disk is freed up for the current program to run. For a program that is running for a long time without any action, these programs are temporarily stored in the freed space, swap partition, and then restore the data from the swap partition to memory when the program is again manipulated.
2. How to set the swap partition
1. First, we need to know the details of the swap partition before it is easy to set up:
Type the command: #free
Note: The default unit is K,-M, which means the unit is M,-G and the unit is G
2. View swap space files and partition information
# swapon-s or # Cat/proc/swaps
Note: filename-file name, partition-partition
3. increase swap space-increase swap space by creating swap files
1). Use root permissions
Su Root
2). Create a large file
# dd If=/dev/zero of=/swapfile bs=1024 count=500
Note: Create a swap file of size 500M, if= input file or device name, of= output file or device name,bs = bytes Simultaneously set the number of bytes read/write buffer (equal to set IBS and OBS) parameters, we can go to Baidu search DD command details
3). Convert/swapfile files to swap files
# Mkswap/swapfile
4). Activate/swapfile swap file now
# Swapon/swapfile
4). Set the system to automatically activate the/swapfile swap file
#vi/etc/fstab
Append write:/swapfile swap swap defaults 0 0
5). Execute free or cat/proc/swaps to see if the swap partition is enabled
4. Delete Swap space
1). Turn off swap partitions
#swapoff/swapfile
Parameters:
-A turns off all devices in the/etc/fstab file that are set to swap
-V Show More information
2). from /etc/fstab The code that was appended before the deletion, then delete the file, you can
Swap partition for Linux