Linux swap partitions similar to Windows virtual memory, in the case of insufficient hard disk space, can be solved by creating a swap partition, the following small series will introduce you how to create and Delete the swap partition.
1.swap Overview
Swap partition, i.e. exchange zone Swap space action may be simply described as: when the system's physical memory is not enough, it is necessary to physical memory A portion of the space is freed for use by the currently running program. The freed space may come from programs that haven't been manipulated for a long time. These freed spaces are temporarily saved to the Swap space, and when those programs are running, the saved data is restored from Swap to memory. In this way, the system always performs Swap exchange when the physical memory is insufficient. In fact, Swap's tuning is critical to the performance of Linux servers, especially Web servers. By adjusting Swap, you can sometimes overcome system performance bottlenecks and save system upgrade costs.
2.Create a swap
An error occurred when monitoring the server using zabbix because of the forgotten creation of the swap partition when installing the Centos 6.0 operating system. At this time, I found that the swap partition was not created. So you need to create a swap partition, the operation is as follows:
First, use the user with ROOT permission to log in remotely via SSH or the local terminal to log in to the system to create a swap partition
dd if=/dev /zero of=/swap/swap bs=1024 count=1024000
if //input
of //output
bs //block size
count //total size
Create Linux swap file
mkswap /swap/swap
Activate /swap/swap swap file now
swapon /Swap/swap
See if it works
[root@webserver ~]# free -m
total used free shared buffers cached
Mem: 2007 140 1867 0 8 35
-/+ buffers/cache: 96 1911
Swap: 972 0 972
As you can see from the above output, the swap partition has been successfully created.
Set to permanent effect
Although it is now in effect, wait for the next server restart. The swap virtual disk will be invalid. To ensure permanent validity, you need to add the following command set to the /etc/fstab file:
echo “/swap/swap swap swap defaults 0 0” 》” /etc/fstab< Br>
So far, the swap partition has been created.
2. Delete the swap partition
Sometimes you may need to delete the swap partition, how to delete the partition correctly?
Stop the swap partition first
swapoff /swap/swap
Delete the swap partition file
rm -rf /swap/swap
Delete “/etc/swap”specify files
This allows you to manually add and remove swap partitions.
The code is as follows:
sed -i “/‘\\/swa\\/swap swap swap defaults 0 0’//” /etc/fstab
Is the way to create and delete the swap partition in Linux introduced, if you just want to delete a file in the swap, see how the system home Linux deletes the specified file in the swap, I hope to help you.
In Linux systems, the usual things are bash shells, so many users dont know Zsh ver
Recently, many Linux users have experienced problems when using OpenSSH. The soluti
In Linux system operation, sometimes you need to check the usage of cpu, which requires the use of L
The FIFO pipeline is a file type. It is very easy to create a FIFO on Linux. The FI
What shortcuts do Linux systems use with Visual Studio?
Linux system how to configure multi-path
How Linux uses Eclipse to build Android development environment
How does the Linux shell call another script file
Linux system how to prevent CC attack
What should I do if the Windows file shows garbled characters on Ubuntu?
Introduction to the Linux file system
What should I do if the Linux runlevel is set to 6 and then restart infinitely?
Logrotate tool usage summary in Linux system
Linux installation and deployment of LXC method details
20 special execution commands under Windows (1)
How to cancel the power-on password and power-on login box
Windows 8 easy way to install rich language packs
Win10 system changes the notification message location method
How to disable or uninstall the touchpad
How to fix Windows 7 vulnerability patch uninstallation failure
Windows 8 system IE10 can not install Flash Player plugin