linux 1. What is SWAP$ swapon -s Filename Type Size Used Priority /swap.img file 2097148 0 -2 Functionally, the swap partition is mainly used to swap part of the data in the memory to the swap space when the memory is insufficient, so that the system will not cause OOM or more fatal situations due to insufficient memory. Therefore, when there is pressure on memory usage and memory recycling begins to be triggered, swap space may be used. 2. What does swappiness adjust? The file $ cat /proc/sys/vm/swappiness 60 $ sysctl -q vm.swappiness vm.swappiness = 60 $ sysctl vm.swappiness=10 $ sysctl -q vm.swappiness vm.swappiness = 10 Persistent Operations $ vim /etc/sysctl.conf vm.swappiness=10 #To the last line, restart is required to take effect Defines how aggressively the kernel uses swap:
3. When will the swap operation be performed?There are two memory recycling mechanisms: kswapd cycle checking and direct memory recycling. When the requested memory is greater than the remaining memory, direct recycling will be triggered. So what are the conditions that trigger recycling during the kswapd process periodic check? From a design perspective, the kswapd process needs to periodically check the memory and start memory recycling when a certain threshold is reached. This so-called threshold can be understood as the current memory usage pressure. That is, although we still have remaining memory, when the remaining memory is relatively small, that is, when the memory pressure is high, we should start trying to reclaim some memory. This can ensure that the system has enough memory as much as possible for sudden memory requests. Kswapd decides whether to start reclaiming memory based on the memory water level mark. If the mark reaches low, it starts reclaiming until the remaining memory reaches high. View the current system memory watermark 4. Priority of swap partitionYou can use the -p parameter to specify the priority of the swap space. The larger the value, the higher the priority. The range of numbers that can be specified is from -1 to 32767. $ swapoff /dev/sdc1; swapon -p 0 /dev/sdc1 $ swapon -s Filename Type Size Used Priority /dev/sdc1 file 2097148 0 0 $ cat /proc/swaps Filename Type Size Used Priority /dev/sdc1 file 2097148 0 0 Put an entry in /dev/sdc1 swap swap pri=0 0 0 5. Start and stop swap$ swapoff -a stop $ swapon -a start 6. Create swap spaceCreate swap file dd if=/dev/sda3 of=./swapfile bs=1M count=1G mkswap ./swapfile Enable swap file $ swapon swapfile $ swapon -s Filename Type Size Used Priority /swap.img file 2097148 3340 0 /mnt/swapfile file 6388156 0 -2 Turn off swap space $ swapoff swapfile $ swapon -s Filename Type Size Used Priority /swap.img file 2097148 3156 0 The above is the detailed content of Linux swap partition (detailed explanation). For more information about Linux swap partition, please pay attention to other related articles on 123WORDPRESS.COM! , I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Div picture marquee seamless connection implementation code
>>: Solve the matching problem in CSS
1. Add the plug-in and add the following configur...
Abstract: MySQL provides a variety of storage eng...
Table of contents JSX environment construction In...
Table of contents Combining lookahead and lookbeh...
This article uses examples to illustrate the comm...
This article shares the specific code of Vue usin...
The elements in an HTML document are arranged one...
1. CSS3 triangle continues to zoom in special eff...
Downloaded an es image from docker hub, version 6...
Zero: Uninstall old version Older versions of Doc...
What is a container data volume If the data is in...
This article uses an example to describe how to a...
Regarding the connection method between Java and ...
This article example shares the specific code of ...
Sometimes, we need to use the hyperlink <a> ...