知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

Linux下Swap空间的添加

发布时间:2014-09-05 15:55:03作者:知识屋


***************************** 
Linux下Swap空间的添加 
环境:CentOS 6.2
author:  youseesan 
******************************
 
mkdir /var/swap  www.zhishiwu.com  
---创建指定大小的文件file.swp  1024字节 65536/1024=64M 
[root@localhost ~]# dd if=/dev/zero of=/var/swap/file.swp bs=1024 count=65536 
记录了65536+0 的读入 
记录了65536+0 的写出 
 
67108864字节(67 MB)已复制,1.05399 秒,63.7 MB/秒 
[root@localhost ~]#
----UUID=7b2d46b8-6448-43d5-86e0-fffa0c798965作为卷标 
[root@localhost ~]# mkswap /var/swap/file.swp 
mkswap: /var/swap/file.swp: warning: don't erase bootbits sectors 
        on whole disk. Use -f to force. 
Setting up swapspace version 1, size = 65532 KiB 
no label, UUID=7b2d46b8-6448-43d5-86e0-fffa0c798965
 
vi /etc/fstab --添加下面一行,系统启动后自动加载 
--------------------------------------------------------------------------------- 
/var/swap/file.swp         swap         swap    defaults        0 0 
---------------------------------------------------------------------------------
  www.zhishiwu.com  
[root@localhost ~]# free -m 
             total       used       free     shared    buffers     cached 
Mem:          1266        364        901          0         17        181 
-/+ buffers/cache:        165       1100 
Swap:         2918          0       2918 
[root@localhost ~]#
 
---开启swap添加 
[root@localhost ~]# swapon /var/swap/file.swp 
[root@localhost ~]# free -m 
             total       used       free     shared    buffers     cached 
Mem:          1266        364        901          0         17        181 
-/+ buffers/cache:        165       1100 
Swap:         2982          0       2982 
[root@localhost ~]#
  www.zhishiwu.com  
---关闭swap添加 
[root@localhost ~]# swapoff /var/swap/file.swp 
[root@localhost ~]# free -m 
             total       used       free     shared    buffers     cached 
Mem:          1266        364        901          0         17        181 
-/+ buffers/cache:        165       1100 
Swap:         2918          0       2918 
[root@localhost ~]#
 
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜