首页 > 代码库 > Centos 系统swap虚拟内存添加与删除配置
Centos 系统swap虚拟内存添加与删除配置
[forlong401@dfdsfdsfs ~]# cd /var/
[forlong401@dfdsfdsfs var]# dd if=/dev/zero of=swapfile bs=1024 count=2048000
记录了2048000+0 的读入
记录了2048000+0 的写出
2097152000字节(2.1 GB)已复制,61.357 秒,34.2 MB/秒
[forlong401@dfdsfdsfs var]# mkswap swapfile
mkswap: swapfile: warning: don‘t erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2047996 KiB
no label, UUID=fdafdsfdsb-3sfdb-4sfdc-bfdfd7-8sdfsafds89
[forlong401@dfdsfdsfs var]# swapon swapfile
[forlong401@dfdsfdsfs var]# swapon -s
Filename Type Size Used Priority
/var/swapfile file 2047996 0 -1
[forlong401@dfdsfdsfs var]# echo "/var/swapfile swap swap defaults 0 0">>/etc/fstab
[forlong401@dfdsfdsfs var]# free -m
total used free shared buffers cached
Mem: 488 478 10 0 4 132
-/+ buffers/cache: 341 147
Swap: 1999 0 1999
[forlong401@dfdsfdsfs var]# top -a
top - 21:04:55 up 3 days, 21:06, 2 users, load average: 0.05, 0.25, 0.13
Tasks: 113 total, 1 running, 112 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3%us, 0.0%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 52423423k total, 424234232k used, 942343k free, 523424k buffers
Swap: 2047996k total, 0k used, 2047996k free, 136088k cached
首先停止swap分区
swapoff /swap/swap
删除swap分区文件
rm -rf /swap/swap
删除"/etc/swap"指定文件
sed -i "/‘\/swa\/swap swap swap defaults 0 0‘//" /etc/fstab
Centos 系统swap虚拟内存添加与删除配置