Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Move swap to another partition, revisited again' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Move swap to another partition, revisited again
Authored by: aschmidtm on Jun 17, '05 10:52:15PM

Will this work if I use .swap?

---
[-[-[A]-]-]



[ Reply to This | # ]
Move swap to another partition, revisited again
Authored by: MacManiac on Jun 18, '05 02:40:03PM
Re: ...will this work with .swap?

I haven't gone back to that naming convention since it was "broken" for us in Panther.....I had been using ".swap" as the name for my swap partition in previous releases of OS X, but somewhere along the line in Panther that became an illegal option --- It may be acceptable in Tiger again, but when I implemented this hint, I didn't try that.

I use a coupla fine-tuning modifications to this method of moving the swap directory. First, I've found that making an fstab to mount the partition early has worked well. There has been some discussion that the OS can change the actual /dev/disk assignment on the fly, but I haven't seen that on my installations.....so for my fstab, I simply query the Terminal with df to find the device listing for my swap directory, then use that info to make my fstab as follows:

more /etc/fstab

/dev/disk0s10 /Volumes/swap ufs rw 1 2
Second, as you can see above, I use the Unix File System for my swap partition....this makes the partition invisible in OS 9 and seems to take care of a whole host of secondary issues such as fragmentation.

Third, I add one additional line to the rc.swap file shown above so that it will use fsck to "preen" the swap directory in the event of an unusual shutdown.....this works really well.

The additional line goes right after the swapcount=1 line as shown below:

swapvolume=swap

RMRF_ITEMS="${swapdir}/swap*"
if [ ! -d /Volumes/${swapvolume}/.Trashes ]; then
    swapcount=1
    fsck -p /dev/disk0s10
    echo "Waiting for ${swapvolume} to mount"
    while [ "$swapcount" -le 10 ]; do
        sleep 1
        if [ -d /Volumes/${swapvolume}/.Trashes ]; then
            echo "${swapvolume} mounted after $swapcount seconds"
            break
        fi
        swapcount=`expr $swapcount + 1`
    done
fi

if [ -d /Volumes/${swapvolume}/.Trashes ]; then
    swapdir=/Volumes/${swapvolume}/.vm
    echo "Using ${swapdir} for swapfile"
else
    echo "Unable to use ${swapvolume} for swapfile"
fi
So I now have a separate swap directory formatted in ufs on a different drive that mounts early and self repairs if shutdown abnormally.

ymmv, but this technique has been working for me on a single drive with a dedicated swap partition in ufs since the introduction of Panther.....and now in Tiger!

[ Reply to This | # ]