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 to create a swap file

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

I have been in contact with this swap since I installed the system. As mentioned earlier, it is similar to the virtual memory of windows. The size of the partition is usually 2 times the size of memory. If your memory is more than 4G, then it seems unnecessary for you to divide 8G. 4G is enough for daily exchange. However, there are also situations where there is insufficient virtual memory. If you do, do you have to redistribute the disk? Of course not! Then let's add a virtual disk.

The basic idea is to set up swapfile, format it into swap format, and enable the virtual disk

# dd if=/dev/zero of=/tmp/newdisk bs=40K count=102400

Use dd to create a 4G file / tmp/newdisk, where if represents which file to read from, / dev/zero is a unique 0 generator under linux, of indicates which file to output, bs is the block size, and count defines how many blocks there are.

# mkswap / tmp/newdisk

The mkswap command is specifically formatted for partitions in swap format

# swapon / tmp/newdisk enable the virtual disk

Use the free command to view system memory and virtual memory usage, and the-m option is viewed in the form of M. You can see the current system's. And swapon is to enable our newly created swap file, and then use free to check and find that there is more than 400m.

# swapoff / tmp/newdisk

We can also use swapoff to close the enabled swap file.

Easy to use, artifact.

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

Network Security

Wechat

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

12
Report