查看swap
a:
- sudo swapon -s
b:
- free -m
文件方式:
1. 生成
生成一个1Gb(bs*count)的文件
- [root@localhost ~]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000
2. 标记
强制执行
- mkswap -f /home/swap
3. 开启
- swapon /home/swap
附:
- [root@localhost ~]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000
- 1024000+0 records in
- 1024000+0 records out
- 1048576000 bytes (1.0 GB) copied, 4.21348 s, 249 MB/s
- [root@localhost ~]# mkswap /home/swap
- mkswap: /home/swap: warning: don't erase bootbits sectors
- on whole disk. Use -f to force.
- Setting up swapspace version 1, size = 1023996 KiB
- no label, UUID=25e27794-76f4-4a0f-9a6a-9f90692396cf
- [root@localhost ~]# mkswap -f /home/swap
- Setting up swapspace version 1, size = 1023996 KiB
- no label, UUID=9eb85935-9021-4f51-bec2-38928d426aaa
- [root@localhost ~]# swapon /home/swap
- [root@localhost ~]#
注意:::
永久增加:
- sudo vi /etc/fstab
在文件尾,增加如下内容:
- /home/swap none swap sw 0 0