Home > Article > System Tutorial > Centos7 add delete Swap exchange partitions
Swap means: swap partition, similar to Windows virtual memory, but when the physical memory is insufficient, part of the hard disk space is used as virtual memory, thereby solving the problem of insufficient physical memory capacity.
Advantages: Cost saving.
Disadvantages: Inadequate performance.
This method is not limited to Centos 7 and can be used on all Linux systems.
Operating user: root.
使用dd命令创建swap交换分区文件/dev/mapper/centos-swap,大小为2G: $ dd if=/dev/zero of=/dev/mapper/centos-swap bs=1024 count=2048000 格式化swap分区: $ mkswap /dev/mapper/centos-swap 设置交换分区: $ mkswap -f /dev/mapper/centos-swap 激活swap分区: $ swapon /dev/mapper/centos-swap 设为开机自动启用: $ vim /etc/fstab 在该文件底部添加如下内容: /dev/mapper/centos-swap swap swap default 0 0
Stop the swap partition in use:
$ swapoff /dev/mapper/centos-swap 删除swap分区文件: $ rm /dev/mapper/centos-swap 删除或注释在/etc/fstab文件中的以下开机自动挂载内容: /dev/mapper/centos-swap swap swap default 0 0
The above is the detailed content of Centos7 add delete Swap exchange partitions. For more information, please follow other related articles on the PHP Chinese website!