How to increase the swap partition under Linux

Source: Internet
Author: User
Tags db2 linux

1, check the current partition situation (using FREE-M or cat/proc/swaps):

[Root@db2 root]# Free-m

Total used free shared buffers Cached

MEM:1006 84 922 0 11 38

-/+ buffers/cache:35 971

swap:0 0 0

2, increase the exchange of partition files and size:

Check for no swap, the following need to be added:

Determines the size of the new interchange file, multiplying the size by the size of the 1024来 decision block. For example, the block size of a 64MB swap file is 65536, and the following command is typed as root at the shell prompt, where count equals the desired block size.

[ROOT@DB2 root]# dd If=/dev/zero of=/home/swap bs=1024 count=1024000

1024000+0 Records in

1024000+0 Records out

[Root@db2 root]#

Use the following command to set up the swap file:

[Root@db2 root]# Mkswap/home/swap

Setting up Swapspace version 1, size = 1023996 KiB

3. Enable swap partition files:

To enable swap files now instead of automatically booting at boot time, use the following command:

[Root@db2 root]# Swapon/home/swap

Check for increased exchange:

[Root@db2 root]# Free-m

Total used free shared buffers Cached

mem:1006 994 12 0 4 929

-/+ buffers/cache:60 946

swap:999 0 999

To enable at boot time, edit the/etc/fstab file to include the following line (/home/swap swap defaults 0 0):

[Root@db2 root]# Vi/etc/fstab

This article URL address: http://www.bianceng.cn/OS/Linux/201410/45429.htm

label=//ext3 Defaults 1 1

Label=/boot/boot ext2 Defaults 1 2

None/dev/pts devpts gid=5,mode=620 0 0

NONE/PROC proc Defaults 0 0

NONE/DEV/SHM TMPFS Defaults 0 0

LABEL=/USR/USR ext3 Defaults 1 2

/dev/sda5 Swap Defaults 0 0

/dev/cdrom/mnt/cdrom iso9660 Noauto,owner,kudzu,ro 0 0

/dev/fd0/mnt/floppy Auto Noauto,owner,kudzu 0 0

/home/swap Swap Defaults 0 0

The next time the system boots, it will enable the new swap file

Check the added case again:

[Root@db2 oracledb]# Free-m

Total used free shared buffers Cached

1, check the current partition situation (using FREE-M or cat/proc/swaps):

[Root@db2 root]# Free-m

Total used free shared buffers Cached

MEM:1006 84 922 0 11 38

-/+ buffers/cache:35 971

swap:0 0 0

2, increase the exchange of partition files and size:

Check for no swap, the following need to be added:

Determines the size of the new interchange file, multiplying the size by the size of the 1024来 decision block. For example, the block size of a 64MB swap file is 65536, and the following command is typed as root at the shell prompt, where count equals the desired block size.

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.