FreeBSD加大swap大小

来源:互联网 发布:whats up软件 编辑:程序博客网 时间:2024/05/04 04:33

 

Example 11-1. Creating a Swapfile on FreeBSD

  1. Be certain that your kernel configuration includes the memory disk driver (md(4)). It is defaultin 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


# 參考官網上如何加大 swap 方式
adding-swap-space

#先確認你的 FreeBSD kernel 有無開啟 md
#cd /usr/src/sys/i386/conf
#vi GENERIC
device md # Memory "disks"

# 查看 swap 的大小資訊
#swapinfo
Device 1K-blocks Used Avail Capacity
/dev/ad0s1b 524288 0 524288 0%

#在 /usr/swap0 中建立一個 512M 大小的虛擬 swap 記憶體空間 1024k x 512 = 536870912 約 512M
#dd if=/dev/zero of=/usr/swap0 bs=1024k count=512
512+0 records in
512+0 records out
536870912 bytes transferred in 32.979217 secs (16279068 bytes/sec)

# 更改權限只能讀
#chmod 0600 /usr/swap0

# 手動啟用新的 swap 空間
#mdconfig -a -t vnode -f /usr/swap0 -u 0 && swapon /dev/md0

# 查看新增加的 swap 是否加大
#swapinfo
Device 1K-blocks Used Avail Capacity
/dev/ad0s1b 524288 372 524288 0%
/dev/md0 524288 0 524288 0%
Total 1048576 372 1048204 0%

#將新 swap 空間加入開機自動啟動
#vi /etc/rc.conf
swapfile="/usr/swap0"