Mac OS X

Waterroof is incredulous

I've been using WaterRoof, a frontend for ipfw on OS X. It's only a bit clunky and works well. What is particularly endearing, however, is its response when you have configured your rules and you tell WaterRoof that you want your computer to load them at startup:

AttachmentSize
Image icon waterroof.png31.83 KB
Topic: 

Moving Swap on OS X 10.5 Leopard

By default, OS X 10.5 stores its swapfiles in /private/var/vm:

$ ls -lh /private/var/vm
total 131072
-rw------T  1 root  wheel    64M May 28 10:32 swapfile0

Recently I've been having some fun with a Mac Pro that has 32GB (sic) of RAM. The machine is being used for some bioinformatics work which involves huge chunks of memory. Naturally we ran out of memory and started swapping, but we wanted to swap faster.

I created a RAID 0 (OS X calles it a striped set) using 32GB partitions across four disks for a 128GB RAID volume. Creatively, I called this volume swapraid0. I chose that size because Leopard can have a maximum of 64 2GB swap files (at least that's what Yves wrote). The first few swap files are smaller (Leopard creates 64MB, 128MB, ... 1GB files) so 128GB should be plenty.

I made this RAID 0 volume the first volume (and put the OS on the second volume) because some people reported trouble if swap was not on the first volume.

Then I copied the existing paging directory to the new volume:

$ sudo cp -Rp /private/var/vm /Volumes/swapraid0/.vm

I used a dot in the name so it wouldn't show up in the Finder. -R is recursive and -p means "preserve permissions".

If you simply edit /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist to point to your swap on the new volume, you run the risk of the volume not being mounted in time during startup. So I put the following at /sbin/dynamic_pager_init:

#!/bin/bash
#launch Apple's dynamic_pager only when the swap volume is mounted
#see http://forums.macosxhints.com/showpost.php?p=452409&postcount=14

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

Changed permissions on /sbin/dynamic_pager_init to make it executable:

sudo chmod ugo+x-w /sbin/dynamic_pager_init
sudo chown root:wheel /sbin/dynamic_pager_init

Double-checked:

$ ls -l /sbin/dynamic_pager_init
-r-xr-xr-x  1 root  wheel  388 Jun  1 20:41 /sbin/dynamic_pager_init

Next, I made a backup of the plist that launches the dynamic pager:

$ sudo cp -p /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist /Users/jvandyk/com.apple.dynamic_pager.plist

Then I edited the plist so that it would run the script at /sbin/dynamic_pager_init:

$ sudo nano -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

The result:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//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>ProgramArguments</key>
                <array>
                     <string>/sbin/dynamic_pager_init</string>
                </array>
                <key>OnDemand</key>
                <false/>
</dict>
</plist>

After rebooting, I ensured that the pager had actually launched:

$ ps aux | grep swap
root       161   0.0  0.0   610348   3504   ??  S    10:00AM   0:00.01 /sbin/dynamic_pager -F /Volumes/swapraid0/.vm/swapfile

Warnings/Caveats

1. You'd have to be nuts to do this. The existing pager settings work fine.

2. I am not responsible if you blow up your machine.

3. When I made a typo while I was experimenting, I found out what happens when the pager isn't actually running and you use all the memory. Ugly.

4. Certainly there are ways to improve this.

Sources

Pretty much all of this approach was taken from the posts by E James, whom I thank.

Also, read the dynamic pager man page:

$ man dynamic_pager
Topic: 

OS X: To Protect and Serve

Over the weekend an importer force attacked my Mac. Fortunately, even though the box was unattended at the time, Mac OS X retaliated, eliminating all traces of this hostile force.

I couldn't find much on the web about the "Importer force killed!" message other than Simone Manganelli's helpful tweet.

Topic: 

ImageMagick, MacPorts and MAMP

After installing ImageMagick from MacPorts, I ran into the following error in my MAMP Apache error log when trying to run PHP code that resized images:

Symbol not found: __cg_jpeg_resync_to_restart

To solve this, edit /Applications/MAMP/Library/bin/envvars to read:

DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_FALLBACK_LIBRARY_PATH=/Applications/MAMP/Library/lib
Topic: 

Pages

Subscribe to RSS - Mac OS X