Linux system modifies swap partition "Go"

Source: Internet
Author: User

Modify the size of the swap partition (two methods) after you install the Linux system

After installing the Linux system, the swap partition is too small, how can I expand the swap partition? There are two ways, one is to create a new swap partition, and one to increase the swap partition. These two methods are described below:
First you must have root authority, the process must be very careful, accidentally destroyed the entire hard disk data, perform the following process before you need to think twice, the consequences of the wrong operation by the performer himself.
New Swap partition

1. Enter the console as root, input
 # swapoff-a          #停止交换分区
 
2. Use the FDISK command to add the swap partition's drive letter, (example: # Fdisk/dev/sdb) to remove the swap partition, enter D to delete the swap partition, and then n Add the partition (the hard disk must have free space when added, Then use T to change the newly added partition ID to a (Linux swap type), and then use W to actually write the operation to the hard drive (the operation that didn't work with W is invalid).
 
3. # mkswap/dev/sdb2       #格式化swap分区, here's sdb2 to see the actual partition device name displayed after you add the P command
&NBSP
4. # swapon/dev/sdb2      #启动新的swap分区
 
5. To enable the Swap partition to be enabled automatically when the system starts, you can edit/ Etc/fstab, add the following line
/dev/sdb2       swap         swap        defaults        0 0 
 
6. Complete
Add swap partition



1. Create the Swap partition file: Increase the 1G size of the swap partition, the command is written as follows, where the count equals the desired block size.
# dd If=/dev/zero of=/home/swapfile bs=1m count=1024

2. Set the swap partition file:
# Mkswap/home/swapfile #建立swap的文件系统

3. Enable swap partition files now:
# Swapon/home/swapfile #启用swap文件

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

5. Complete

Linux system modifies swap partition "Go"

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.