How to add a new swap partition to the RHEL System

Source: Internet
Author: User
How to add a new swap partition to the RHEL system-Linux general technology-Linux technology and application information. The following is a detailed description. Solution: 1. if you want to add a swap partition (if you want to add/dev/hdb5 as the swap partition), the hard disk cannot be in use (that is, the partition cannot be loaded, the swap space is not activated ). The partition table cannot be modified during use, because the kernel may not be able to correctly identify the changes in the partition table. In this way, data may be written to wrong partitions, which leads to data overwrite and loss, because the Partition Table maintained by the kernel is inconsistent with the partition table on the hard disk. The easiest way to solve this problem is to direct the system to the emergency mode for operations. If you are prompted to scan and load the file system, skip this step. If no partition on the hard disk is used, you can unmount the partition and use the swapoff command to disable all swap partitions on the hard disk.

2. Use parted to create a swap Partition

Run as root: parted/dev/hdb
At the parted command prompt, enter print to view the current Partition Table and free space. The unit of the start and end values is MB. Then, you can calculate the amount of free space and the amount of space you want to divide into swap partitions.

At the parted prompt, enter mkpartfs part-tyep linux-swap start end. Here, the part-type is primary, extend, or logical. Start indicates the start point of the partition, and end indicates the end point of the partition.

Enter exit to exit parted

3. Now you have created a swap partition. Use the mkswap command to set the swap partition:
Mkswap/dev/hdb2

4. to activate the swap partition immediately, enter the following command:
Swapon/dev/hdb2

5. To activate it at startup, add the following content to/etc/fstab:
/Dev/hdb2 swap defaults 0 0
The swap partition is automatically activated at the next startup.

6. After a new partition is added and activated, you can check whether the swap partition is working through cat/proc/swaps or free.

Answers from Red Hat engineers
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.