Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1691787
  • 博文数量: 136
  • 博客积分: 10021
  • 博客等级: 上将
  • 技术积分: 3261
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-22 11:26
文章分类

全部博文(136)

文章存档

2010年(1)

2009年(26)

2008年(109)

我的朋友

分类: LINUX

2008-12-11 21:59:35

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
阅读(1635) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~