4

swap使用-FreeBSD

 1 year ago
source link: https://garywu520.github.io/2022/07/22/swap%E4%BD%BF%E7%94%A8-FreeBSD/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

swap使用-FreeBSD

2022-07-22

字数统计: 121字

  |   阅读时长≈ 1分

$ dd if=/dev/zero of=/usr/swap0 bs=1M count=1024
$ chmod 0600 /usr/swap0

#立即使用swap
$ mdconfig -a -t vnode -f /usr/swap0 -u 0
$ mdconfig -l -v
md0 vnode 2048M /usr/swap0
$ swapon /dev/md0

#如何删除md?
#mdconfig -d -u 0

开机自动挂载swap

cd /usr/local/etc/rc.d

cat > auto_swap <<EOF
#!/bin/sh
mdconfig -a -t vnode -f /usr/swap0 -u 0 && swapon /dev/md0
EOF

chmod +x auto_swap
cat > /etc/rc.local <<EOF
#!/bin/sh
sh /usr/local/etc/rc.d/auto_swap
EOF

chmod +x /etc/rc.local
#验证
$ swapinfo -k
$ htop

扫一扫,分享到微信


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK