Swapfiles
You can create a file of a specified size to use as a swap file. In our example here we will use a 64MB file called /usr/swap0. You can use any name you want, of course.
Example 11-1. Creating a Swapfile on FreeBSD
1. Be certain that your kernel configuration includes the memory disk driver (md(4)). It is default in GENERIC kernel.
device md # Memory "disks"
2. Create a swapfile (/usr/swap0):
# dd if=/dev/zero of=/usr/swap0 bs=1024k count=64
3. Set proper permissions on (/usr/swap0):
# chmod 0600 /usr/swap0
4. Enable the swap file in /etc/rc.conf:
swapfile="/usr/swap0" # Set to name of swapfile if aux swapfile desired.
5. Reboot the machine or to enable the swap file immediately, type:
# mdconfig -a -t vnode -f /usr/swap0 -u 0 && swapon /dev/md0
6. 查看
#pstat -T
676/32808 files
0M/2023M swap space
=====以下是老版本的加入步骤============
系统是FreeBSD 4.8
# cat GENERIC |grep pseudo-device
pseudo-device md # Memory "disks"
三、在156上的操作步骤及运行情况
1、建一个 vn-device 设备
# cd /dev
# sh MAKEDEV vn0
2、创建一个交换文件
# dd if=/dev/zero of=/usr/swap0 bs=1024k count=1024(增加1G)
# ls -lh /usr/swap0
-rw------- 1 root wheel 1G Aug 29 11:50 /usr/swap0
3、赋予它(/usr/swap0)一个适当的权限
# chmod 0600 /usr/swap0
4、在 /etc/rc.conf 中启用交换文件
# vi /etc/rc.conf
swapfile="/usr/swap0"
5、命令使交换文件立刻生效
# vnconfig -e /dev/vn0b /usr/swap0 swap
6、查看
# pstat -T
或top
# pstat -T
60/8136 files
0M/2032M swap space
# top
Mem: 7996K Active, 11M Inact, 13M Wired, 4K Cache, 5216K Buf, 467M Free
Swap: 2032M Total, 2032M Free
评论