Linux Add swap partition

Source: Internet
Author: User

"Introduction to Operations"

To increase the Swap partition method:

1. Create a new disk partition as a swap partition

2. Use the file as a swap partition (easier to operate, I'm more used)

These two methods are described below: (both must be rooted, and the procedure should be handled with caution.) )

A. Create a new disk partition as a swap partition

1. Enter the console as root (login system), enter

# swapoff-a #停止所有的swap分区

2. Use the Fdisk command (example: # FDISK/DEV/VDB) to partition the disk, add a swap partition, create a new partition, and use the "T" command in Fdisk to change the newly added partition ID to ". Linux swap Type". Finally, the operation is actually written to the hard disk with W (the operation is not valid until W is useless).

3. # mkswap/dev/vdb2 #格式化swap分区, the sdb2 here depends on the actual partition device name displayed after you add the P command

4. # SWAPON/DEV/VDB2 #启动新的swap分区

5. In order for the system to start automatically enable this swap partition, you can edit/etc/fstab, add the following line

/DEV/VDB2 swap swap defaults 0 0

Second, use the file as a swap partition

1. Create a file to be a swap partition: increase the 1GB size of the swap partition, the command is written as follows, where count equals the number of blocks you want (bs*count= file size).

# dd If=/dev/zero of=/tmp/swapfile bs=1m count=1024

2. Format the swap partition file:

# Mkswap/tmp/swapfile #建立swap的文件系统

3. Enable the Swap partition file:

# Swapon/tmp/swapfile #启用swap文件

4. Make the system self-enabled when booting, add a line in file/etc/fstab:

/tmp/swapfile swap swap defaults 0 0

Authentication

Free-m See if the add succeeds.

Linux Add swap partition

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.