In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to add and delete Swap swap partition method in Centos7, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Swap introduction:
Linux divides physical memory into memory segments, called pages. Swapping is the process in which memory pages are copied to a predetermined hard disk space (called swap space) in order to free up memory for the pages. The total size of physical memory and swap space is the total amount of virtual memory available.
Swap: swap partitions, similar to the virtual memory of Windows, but when there is insufficient physical memory, part of the hard disk space is used as virtual memory, thus solving the shortage of physical memory.
Advantages: cost savings.
Disadvantages: insufficient performance.
This method is not limited to Centos 7 and can be used on Linux systems.
Operation user: root.
1. Add swap swap Partition Space
Use the dd command to create a swap swap partition file / dev/mapper/centos-swap with a size of 2G:
$dd if=/dev/zero of=/dev/mapper/centos-swap bs=1024 count=2048000
Format the swap partition:
$mkswap / dev/mapper/centos-swap
Set up the swap partition:
$mkswap-f / dev/mapper/centos-swap
Activate the swap partition:
$swapon / dev/mapper/centos-swap
Set to enable automatically when powered on:
$vim / etc/fstab
Add the following at the bottom of the file:
/ dev/mapper/centos-swap swap swap default 0 0
two。 Delete swap swap partition
Stop the swap partition that is in use:
$swapoff / dev/mapper/centos-swap
Delete the swap partition file:
$rm / dev/mapper/centos-swap
Delete or comment the following boot auto-mount content in the / etc/fstab file:
/ dev/mapper/centos-swap swap swap default 0 0
The great task has been completed!
Increase swap partition size under Centos7
If the system runs out of physical memory, the system will run slowly but still run; if the Swap space is used up, the system will have an error. For example, when the Swap space is used up, the service process cannot be started, and a "application is out of memory" error usually occurs, which in serious cases will cause a deadlock of the service process. Therefore, the allocation of Swap space is very important, usually the size of Swap space should be 2-2.5 times the size of physical memory.
This method is not limited to centos,linux.
The following commands need to be operated under the root account
1. First use free-m to check the size of swap
two。 Use the dd command to create a partition file like / home/swap. The size of the file is 512000 block, and normally 1 block is 1K, so the space here is 512m.
# dd if=/dev/zero of=/home/swap bs=1024 count=512000
3. Then change this partition to the swap partition.
# / sbin/mkswap / home/swap
4. Then use this swap partition. Make it a valid state.
# / sbin/swapon / home/swap
Now take a look at the memory and swap partition size with the free-m command, and you can see that 512m of space has been added.
Note that when the computer restarts, it is found that the swap is still as big as before, and the new swap does not start automatically, but manually. Then we need to modify the / etc/fstab file by adding the following line
# vi / etc/fstab / home/swap swap swap defaults 0 0
These are all the contents of this article entitled "how to add and remove Swap swap partitions in Centos7". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.