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"