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 quickly expand sawp Partition

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

Share

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

This article mainly introduces the relevant knowledge of "how to quickly expand sawp partition". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this "how to quickly expand sawp partition" article can help you solve the problem.

When physical memory is running out, Linux uses sawp partitions. Swap is similar to virtual memory under wiondows. When the swap is also exhausted, linux will follow the kernel mechanism and kill some memory that takes up high memory resources as soon as possible, so it is generally necessary to expand the capacity.

1. Check the size of the existing swap space

If you want to check the size of your existing virtual memory, use the command 'free-m'

[root@chenfancentos] # free-m total used free shared buffers cachedMem: 988 164823 026 48 Melody + buffers/cache: 90 898Swap: 1999 0 1999

According to the size of the existing swap space, choose the appropriate expansion size.

two。 Create a suitable swapfile

We can often use the "dd" command to create a file, use "if" to specify the source, basically can not write anything other than "/ dev/zero", and / dev/zero is a file unique to the UNIX system. "of" specifies the target file, "bs" defines the size of blocks, and "count" defines the number of blocks, the number of these two parameters determines the size of the target file.

[root@chenfancentos ~] # dd if=/dev/zero of=/tmp/swapfile bs=300M count=1 recorded 1'0 read in and 1'0 write out 314572800 bytes (315 MB) replicated, 13.9027 seconds, 22.6 MB/ seconds [root@chenfancentos ~] # du-h / tmp/swapfile300M / tmp/swapfile

You can see that a new swapfile file is generated with a size of 300m.

3. Format the swapfile [root@chenfancentos ~] # mkswap-f / tmp/swapfileSetting up swapspace version 1 you just created, size = 307196 KiBno label, UUID=c4e2a8b1-fa09-41ab-bcbf-63c273ed9598

You can see the successful UUID message after formatting

4. Realize automatic mounting of exchange files when booting

If we add the entry / tmp/swapfile swap swap defaults 00 to / etc/fstab, we will be able to boot and mount automatically.

[root@chenfancentos ~] # cat / etc/fstab# / etc/fstab# Created by anaconda on Sat Apr 2 19:37:01 2016 June # Accessible filesystems, by reference, are maintained under'/ dev/disk'# See man pages fstab (5), findfs (8) Mount (8) and/or blkid (8) for more info#UUID=301b2f9f-91d3-47dd-8a43-d377cba1cd5c / ext4 defaults 1 1UUID=812455f9-a63f-4b09-9336-05e3ada6f9a7 / boot ext4 defaults 1 2UUID=416480d0-662c-406c-a328-b4c2f370577b swap swap defaults 0 0tmpfs / dev/shm tmpfs defaults 0 0devpts / dev/pts devpts gid=5 Mode=620 0 0sysfs / sys sysfs defaults 0 0proc / proc proc defaults 0 0/tmp/swapfile swap swap defaults 0 0

In this way, even if it is restarted later, it can be mounted automatically.

5. Enable swapfile to view the virtual memory size [root@chenfancentos ~] # swapon / tmp/swapfile [root@chenfancentos ~] # free-m total used free shared buffers cachedMem: 988 136 852 0 10 50 Muhammad + buffers/cache: 74 913Swap: 2299 0 2299

It is exciting to see that compared to the initial virtual memory, there is now an increase of 300m.

This is the end of the introduction to "how to quickly expand sawp partitions". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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