Create a swap partition manually

Source: Internet
Author: User

Swap partition Swap
Recommended Size mem*2
Physical memory greater than 4G Swap=mem

In addition to the size of the swap space required by special software,
As long as the swap is frequent and data exchange occurs,
Then it means you're running out of memory.

When the system memory is low, the memory needs to be freed.
If the files in memory are not released,
Then you need to swap the in-memory files in the swap partition,
When the process calls the data again, recall the memory usage from the swap partition

Linux tends to use more memory to buffer

Creating a swap partition can be used: partitioning; Block file (DD)

01 dividing a physical partition/DEV/SDB5---2G
#fdisk/dev/sdb
t-->5-->82
#partx-A/dev/sdb

02 convert SDB5 into swap format (virtual memory paging)
#mkswap/DEV/SDB5

03 Viewing the current swap partition
#swapon-S

04 Start a new swap partition/DEV/SDB5
#swapon/DEV/SDB5

05 See Swapon-s again

06 Make sure the swap partition is automatically used for power on
#blkid
#vi/etc/fstab
uuid=****** swap swap Defaults,pri=1 0 0

The original swap space in the system, you can set these two swap partitions to
The same priority pri=? (0~32767)
The larger the number, the higher the priority,
The same priority, which is called parallel swap

* Parallel swap does not have any meaning on the same disk.

07 Restart tests whether a new swap partition is available.
#swapon-S
#free
-----------------------------
Use a block file as a swap partition
-----------------------------

#mkdir/swap
#dd If=/dev/zero of=/swap/swapfile bs=1m count=512
#mkswap/swap/swapfile
#swapon-P 1/swap/swapfile
#vi/etc/fstab

Create a swap partition manually

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.