- 论坛徽章:
- 0
|
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 |
|