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
Index merging is an intelligent algorithm provide...
Although I have run some projects in Docker envir...
Table of contents 1. Modify the my.cnf file of se...
1. Before configuring the IP address, first use i...
Without further ado, here is a demo picture. The ...
This article example shares the specific code of ...
Preface For security reasons, the root user of My...
When the created tab label exceeds the visible ar...
How to host two or more sites on the popular and ...
What is a covering index? Creating an index that ...
The process packets with the SYN flag in the RFC7...
Table of contents Preface 1. Cause of the problem...
TOP Observation: The percentage of CPU time occup...
1. Introduction After MySQL is started, BufferPoo...
1. Cancel the blue color of the a tag when it is ...