免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1270 | 回复: 0
打印 上一主题 下一主题

Linux - 增加 Swap 方法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-11 21:59 |只看该作者 |倒序浏览
vbird介绍,增加 Swap 的方法有两种:
  * 增加一块硬盘,并将其中的某个分区划归为 Swap 文件系统.
  * 建立一个虚拟内存文件
由于测试环境有限,我只测试了一下建立虚拟内存文件的方法.
# 1. 以dd指令建立400m的 swapfile (swapsize=bs*count=4k*100000=400000k=400m)
[root@localhost etc]# dd if=/dev/zero of=/tmp/swap bs=4k count=100000
读入了 100000+0 个块
输出了 100000+0 个块
[root@localhost etc]# ll /tmp/swap
-rw-r--r--  1 root root 409600000 12月 11 21:40 /tmp/swap
# 2. 以mkswap将swapfile格式化为swap文件格式
[root@localhost etc]# mkswap /tmp/swap
Setting up swapspace version 1, size = 409595 kB
# 3. 以swapon启用该文件,使之成为swap
[root@localhost etc]# free
             total       used       free     shared    buffers     cached
Mem:       1034608    1015496      19112          0      36856     725492
-/+ buffers/cache:     253148     781460
Swap:      1044184          0    1044184
[root@localhost etc]# swapon /tmp/swap
[root@localhost etc]# free
             total       used       free     shared    buffers     cached
Mem:       1034608    1015768      18840          0      36912     725520
-/+ buffers/cache:     253336     781272
Swap:      1444176          0    1444176
# 4. 以wwapoff关闭该文件
[root@localhost etc]# swapoff /tmp/swap
[root@localhost etc]# free
             total       used       free     shared    buffers     cached
Mem:       1034608    1030548       4060          0      38016     729368
-/+ buffers/cache:     263164     771444
Swap:      1044184          0    1044184
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/30637/showart_1714532.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP