Home > System Tutorial > LINUX > body text

Centos7 add delete Swap exchange partitions

WBOY
Release: 2024-09-02 13:50:43
Original
592 people have browsed it

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.

Add swap partition space
使用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
Copy after login
Delete swap partition

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

Copy after login

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!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!