#!/bin/sh # By Scott Boone and # Joshua Schrier for SwapCop # May 14, 2002 . /etc/rc.common ## # First check to be sure the pager isn't already running. # It might be if /etc/rc was changed. (OSX upgrade perhaps?) # The dynamic_pager line should be commented out in /etc/rc # (In simpler terms, insert a # at the beginning of the line.) # Added benefit: leaving /etc/rc VM actions intact will automatically # clear the default swapfiles for us at next reboot ## PAGERPID=`ps -ax | grep dynamic_pager | grep -v grep | awk '{print $1}'` if [ ! $PAGERPID ]; then ## # Start the virtual memory system. ## # This is basically Apple's code, except: # 1- the addition of quotes around the variables # (to allow for spaces in volumes and folders in the swapfile path) # 2- set swapdir based on a VIRTUALMEMORY variable in /etc/hostconfig # VIRTUALMEMORY="/Volumes/Your Volume Here/.vm" # (note the quotes--they are important, see above...) # If /etc/hostconfig gets altered, VM will default automatically ## ConsoleMessage "Custom Starting virtual memory" swapdir="${VIRTUALMEMORY:=/private/var/vm}" # Make sure the swapfile exists if [ ! -d "${swapdir}" ]; then ConsoleMessage "Creating alternative swap directory" mount -uw / mkdir -p -m 755 "${swapdir}" chown root:wheel "${swapdir}" else rm -rf "${swapdir}"/swap* fi # Default: 80MB # dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F "${swapdir}"/swapfile # Custom: 512MB dynamic_pager -H 268435456 -L 1073741824 -S 536870912 -F "${swapdir}"/swapfile else ConsoleMessage "Check /etc/rc -- VM already running!" fi