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

Source: Internet
Author: User

After installing the Linux system to modify the size of the swap partition (two ways) after the installation of the Linux system, the swap partition is too small, how to 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, must be very careful in the process, accidentally destroy 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. Create a new Swap partition 1. Enter the console as root and enter # Swapoff-a #停止交换分区 2. Use the FDISK command to add the swap partition's drive letter, (example: # fdisk/dev/sdb) 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 Swap type), and finally the operation is actually written to the hard disk with W (the operation is not valid until W is useless). 3.# mkswap/dev/sdb2 # format swap partition, here the SDB2 to see you add after the P command display the actual partition device name 4.# swapon/dev/sdb2 # start a new swap partition 5. In order for the system to start automatically enable the swap partition, you can edit/etc/fstab, add the following line/DEV/SDB2 swap swap defaults 0 0 6. Complete adding swap partition 1. Create Swap partition file: Increase the 1G size of the swap partition, the command is written as follows, where count equals the desired block size. # dd If=/dev/zero of=/home/swapfile bs=1m count=1024 2. Set swap partition file: # Mkswap/home/swapfile #建立swap的文件系统 3. Enable swap partition file now: # SWAPO N/home/swapfile #启用swap文件 4. Make the system self-enabled when booting, add a line in file/etc/fstab:/home/swapfile swap defaults 0 0 5. Complete

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

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.