hdd3にswap

スワップファイルの作成

以下を実行して64MBのスワップファイルを作成。

# dd if=/dev/zero of=/hdd3/.swapfile bs=1024 count=65536
65536+0 records in
65536+0 records out
# mkswap /hdd3/.swapfile 
Setting up swapspace version 0, size = 67104768 bytes
# swapon /hdd3/.swapfile 
# free
              total         used         free       shared      buffers
  Mem:        62036        60768         1268            0          620
 Swap:        65532            0        65532
Total:       127568        60768        66800

自動マウント

  • /etc/rc.d/init.d/swapfileとして以下のファイルを作成
#!/bin/sh

case "$1" in
    start)
	/sbin/swapon /hdd3/.swapfile
	;;
    stop)
	/sbin/swapoff /hdd3/.swapfile
	;;
    restart)
	$0 stop
	$0 start
	;;
    *)
	echo "Usage: $0 (start|stop|restart)"
	exit 1
	;;
esac

exit 0
  • 権限を変更。
# chmod 755 /etc/rc.d/init.d/swapfile
# cd /etc/rc.d/rc5.d/
# ln -s ../init.d/swapfile S49swapfile
# cd /etc/rc.d/rc6.d/
# ln -s ../init.d/swapfile S49swapfile

再起動してfreeで利用できるか確認。