Linux create/delete swap partition

Linux create swap partition

Swap exists as the virtual memory of the Linux system. When the physical memory of the system is not enough, part of the space in the physical memory needs to be released for use by the currently running program. The freed space may come from some programs that have not operated for a long time. These freed resources are temporarily saved in the Swap space. When the programs are to run, the saved data can be restored from the Swap to the memory. Physical memory and virtual memory accounted for 8G physical memory swap of my server is also 8G, the following is the creation command (the server does not have a swap partition in advance)

创建
dd if=/dev/zero of=/swapfile1 bs=1024 count=8388608
//创建swap文件系统
mkswap /swapfile1
//启用交换分区文件
swapon /swapfile1
//系统启动启用swap 最后一行添加  /swapfile1 swap swap defaults 0 0
vi /etc/fstab
卸载删除
// 卸载swap文件 
swapoff /swapfile1 
//修改/etc/fstab文件 去掉最后一行  /swapfile1 swap swap defaults 0 0
vi /etc/fstab
//删除文件
rm -rf /swapfile1 

Guess you like

Origin blog.csdn.net/u011445756/article/details/87799019