Open swap for installed Linux (virtual memory)

Source: Internet
Author: User

The tech blog uses a Aliyun server, the lowest-configured type (only 512M of RAM). When installing the latest version of MARIADB, it always fails to install because of insufficient memory. So tech decided to turn on swap.

Since opening swap reduces disk IO performance, it can be removed after use.

1. Create an interchange partition file

DD If=/dev/zero Of=/home/swap bs=1m count=512

qq20160115-0

The size of the Bs:block,


The number of Count:block can be customized.

/home/swap: Technical Ann Custom swap file location

It's a 512M swap, technically.

2, set the swap file

Mkswap/home/swap

Qq20160115-1

3. Enable Swap Now

Swapon/home/swap

Qq20160115-2

If there are swapoff-a in the/etc/rc.local that need to be modified into swapon-a

4, according to the need can set whether to boot

echo '/home/swap swap defaults 0 0 ' >>/etc/fstab

5. View Swap

Free-m

Classic Case ECS Linux open swap (virtual memory)
 
  
  
1, creating a file for swap partitions
#dd if=/dev/zero of=/mnt/swap bs=block_size count=number_of_block   /div>
Note: block_size, number_of_block size can be customized, such as bs=1m count=1024 to set 1G size swap partition
2, set swap partition file
#mkswap/mnt/swap
PS://IMG.ALICDN.COM/TFSCOM/TB16MSYHXXXXXBXXVX Xxxxxxxxx.jpg "/>
3, immediately enable the swap partition file
#swapon/mnt/swap
if in/e Tc/rc.local swapoff-a needs to be modified to swapon-a 
4, setting auto-enable swap at power-on The partition
requires to modify the swap line in the file/etc/fstab.
Add/mnt/swap swap defaults 0 0
Note:/mnt/swap path can be modified, depending on the created swap file Diameter to configure.
 
settings can perform free-m command view effect

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.