MacOS X

dynamic_pagerを入れ換えてSwapの抑制(とSwapの移動)


MacOS X Leopard - dynamic_pager を骨抜きに をやってみた+α。

[ Makefile ]
----------------------
#
# $Id: Makefile,v 1.1 2008/08/24 21:11:32 dankogai Exp dankogai $
#
# see the URL below!!
#
# http://cestdelamerde.com/archives/22-Killing-Mac-OS-X-Swapping-How-To-Disable-dynamic_pager.html
#

CFLAGS = -no-cpp-precomp -DNO_DIRECT_RPC -framework CoreFoundation \
-framework IOKit -lSystem.B -R -DNO_DIRECT_RPC dynamic_pager.c \
-I/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers \
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/include

all: dynamic_pager

dynamic_pager.c:
curl -O http://cestdelamerde.com/uploads/dynamic_pager.c

i386.out: dynamic_pager.c
cc -arch i386 $(CFLAGS) -o i386.out

ppc.out: dynamic_pager.c
cc -arch ppc $(CFLAGS) -o ppc.out

dynamic_pager: i386.out ppc.out
lipo -create i386.out ppc.out -o dynamic_pager

clean:
rm i386.out ppc.out dynamic_pager

install: dynamic_pager
mv /sbin/dynamic_pager /sbin/dynamic_pager.apple && \
/bin/cp -p /sbin/dynamic_pager.apple . && \
install -m 0555 -o root -g wheel dynamic_pager /sbin

uninstall: dynamic_pager.apple
/bin/chmod +w /sbin/dynamic_pager && \
/bin/rm -f /sbin/dynamic_pager && \
/bin/cp -p ./dynamic_pager.apple /sbin/dynamic_pager && \
/bin/chmod +w ./dynamic_pager.apple && \
/bin/rm -f ./dynamic_pager.apple
[EOF]
----------------------

Xcodeをインストール。
適当なディレクトリーを作成し、Makefileをコピペ。
make
sudo make install

ついでにSwapファイルも移動させます。

sudo mkdir /Volumes/disk2/.vm
sudo ln -s /Volumes/disk2/.vm /private/var/vm

sudo touch /sbin/dynamic_pager_init
sudo vi /sbin/dynamic_pager_init

[ dynamic_pager_init ]
-----------------
#!/bin/bash
#launch Apple's dynamic_pager only when the swap volume is mounted

if [ "x`df -H | grep /Volumes/disk2`" = "x" ]; then
echo "Waiting for Swap volume to mount";
else
echo "Launching dynamic pager on volume Swap";
/sbin/dynamic_pager -F /private/var/vm/swapfile;
fi
[ EOF ]
-----------------

sudo chmod +rx /sbin/dynamic_pager_init

sudo vi /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

[ com.apple.dynamic_pager.plist ]
----------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.apple.dynamic_pager</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<!--
- <string>/sbin/dynamic_pager</string>
- <string>-F</string>
- <string>/private/var/vm/swapfile</string>
-->
<string>/sbin/dynamic_pager_init</string>
</array>
</dict>
</plist>
[ EOF ]
----------------------

再起動


このページの先頭へ