CentOS An example of adding a swap partition

Source: Internet
Author: User
Tags centos

Create a swap partition using the DD command

[Root@localhost Desktop] #dd if=/dev/zero of=/home/swap bs=1024 count=1048576

Calculated formula for Count: count=size*1024 (SIZE in MB)

This creates a/home/swap partition file with a size of 1G, and then you need to format the new swap partition:

[Root@localhost desktop]# Mkswap/home/swap

Then use the Swapon command to turn this file partition into a swap partition.

[Root@localhost Desktop] #swapon/home/swap
(Turn off the swap command: [root@localhost Desktop] #swapoff/home/swap)

With Free-m, you can see that the swap is enlarged.

To enable swap to mount automatically, modify the/etc/fstab file


At the end of the file, add

/home/swap Swap default 0 0
This way, the swap partition is not manually mounted, even if the system is restarted.

Related Article

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.