Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Linux expands swap Space

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Linux how to expand swap space", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "Linux how to expand swap space" this article.

We have already established the swap partition when we installed the system. Swap partition is usually called swap partition, which is a special hard disk space, that is, when the actual memory is insufficient, the operating system will take part of the temporarily unused data from memory and put it in the swap partition, thus freeing up enough memory space for the currently running program.

Let's first check the size of the existing swap space / partition, using the command free-m or swapon-s

Expand swap Space on Linux system expand swap Space on Linux system

My swap partition size is 2 GB, and we will extend the swap space to 1GB.

Step 1: use the following dd command to create an exchange file with the size of 1GB

The code is as follows:

[root@linuxtechi] # dd if= http://www.3lian.com/dev/zero of= http://www.3lian.com/swap_file bs=1G count=11+0 records in1+0 records out1073741824 bytes (1.1GB) copied, 414.898 s, 2.6MB/s [root@linuxtechi] #

Replace the size of bs and count according to your needs.

Step 2: set the swap file permissions to 600

The code is as follows:

[root@linuxtechi ~] # chmod 600 / swap_file

Step 3: open the exchange area (swap_file) with a file

Open the exchange area with the mkswap command

The code is as follows:

[root@linuxtechi ~] # mkswap / swap_fileSetting up swapspace version 1, size = 1048572 KiBno label, UUID=f7b3ae59-c09a-4dc2-ba4d-c02abb7db33b [root@linuxtechi ~] #

Step 4: add an exchange file entry to the fstab file

Add the following entry to the fstab file so that the exchange file can continue to use each other after each restart.

The code is as follows:

/ swap_file swap swap defaults 0 expand swap space on Linux system expand swap space on Linux system

Step 5: enable swap files with the command 'mkswap on'.

Copy the code

The code is as follows:

[root@linuxtechi ~] # swapon / swap_file

Step 6: check the swap space now

Expand swap Space on Linux system expand swap Space on Linux system

Note: to avoid unexpected situations, turn it off using the swapoff command as shown below, and re-enable the swap file using the swapon command shown in step 5 only if you need it.

The code is as follows:

[root@linuxtechi] # swapoff / swap_file above is all the content of this article "how Linux expands swap space". 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report