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

10.3: Move swap to another partition in Panther System

This is a fairly old hint, but it bears updating for Panther, since previous methods either just plain don't work or fail after a forced reboot (Control - Command - Power Key) ... *and* once they fail, they never work again no matter how many normal reboots you do!

I want to emphasize this point before before I go on. "Panther-ready" utilities such as Xupport 2.0 b1 allow moving the swap, but fail on a forced reboot. And my original hint submission also failed after a few days of solid performance. This was due to my Swap volume overflowing (a 5 GB partition just didn't cut it!). And in both cases, I could not re-establish vm use of the Swap partition without heavy duty human intervention on my part! That said, let's go ahead change some system files! :-)

[robg adds: Read the rest of the hint for the how-to, which I have not tested. As with anything like this that modifies system files, please create a backup of your critical files before you start, just in case!]

The change now requires editing two system files instead of just one: /etc/rc and /etc/fstab. Oh, and as before, if you mess up /etc/rc, you can render your computer unbootable. That's two warnings now, so if you're even vaguely faint of heart or haven't backed up your hard drive in the last twenty minutes ... let the buyer beware!)

I have already created a separate partition named "Swap" and ... yep! ... I'll use that for the system swap files. Note that I have Journaling turned off for this partition. In order to mount this partition reliably, we need to get the device number. In the Terminal, execute the following command:


% df

Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/disk0s3          19477312   6994736  12287804  37% /
devfs                        1         1         0 100% /dev
fdesc                        1         1         0 100% /dev
<volfs>                    512       512         0 100% /.vol
/dev/disk0s7           5300848     79204   5221644   2% /Volumes/Swap

My Swap volume, named under the Mounted On column, is associated with the device /dev/disk0s7 which appears under the Filesystem column. Make sure to check your own, because my device in the Filesystem column will not be the same as yours!

Before we start editing, let's save off the two files we're going to change. As a rule, I always save original system files in the directory where I found them, just in case I have to access them via single user mode. Here's what I do:


% cd /etc
% sudo /bin/cp rc rc.save
% sudo /bin/cp fstab fstab.save

Now for the first -- and less dangerous -- change. Add the Swap volume to the file system mount table.


% sudo /usr/bin/vi /etc/fstab

Note that the every line in the file is commented out (ie does nothing). Place the following at the very end:


LABEL=Swap  /Volumes/Swap hfs         rw

The first entry is the name of the volume, and the second is where it will be mounted (OS X puts every mounted volume in /Volumes). The third entry means I formatted my Swap volume as HFS+ (note the plus here, but not in the entry!). And, finally, I want the volume mounted as read/write. Use :wq! to save your changes. Ready or not (okay, *only* if you're ready!) ... let's change the rc boot script.


% sudo /usr/bin/vi /etc/rc

Scroll down to the following chunk of code:


echo "Starting virtual memory"

swapdir=/private/var/vm
if [ "${netboot}" = "1" ]; then
...

You want to replace the following line...


swapdir=/private/var/vm

...with the following large chunk of code. Careful! You MUST insert your own device number that you found using the df command above. See the comment in the code below for instructions...


#--------- PASTE START
echo "Starting virtual memory"

#
# Make sure Swap is not mounted in case of hard reboot
# If a Swap directory does exist after a dismount, remove
# that because it's in the way of mounting Swap properly
#
umount -v /Volumes/Swap*
if [ -d /Volumes/Swap ]; then
    ConsoleMessage "** DELETING extant Swap directory(s) **"
    rm -rf /Volumes/Swap*
     mkdir /Volumes/Swap
fi

#
# MAKE YOUR CHANGE HERE!
#
# Replace /dev/disk0s7 to your own Swap volume device path.
# And no matter what you called your swap volume, leave
# the /Volumes/Swap portion as it is because it matches the
# above mkdir and the /etc/fstab entry.
#
#               vv-CHANGE-vv vvv-LEAVE-vvv
/sbin/mount_hfs /dev/disk0s7 /Volumes/Swap
sleep 1

swapdir=/Volumes/Swap/vm

#--------- PASTE END

Phew! You need to make one more change a little lower in the file. Go to the line that reads:


appprofiledir=/private/var/vm/app_profile

And replace it with:


appprofiledir=/Volumes/Swap/vm/app_profile

That's it. Now save your changes with ":wq!" and you're done.

While it's a bit more than a one-liner type of change, the beauty of this method is that it will work even if you force reboot (Command - Control - Power Key) your computer, something other methods fail on. In the event of a forced reboot, the system must check out all the volumes on the disk before mounting them. The /etc/fstab change guarantees that the check gets done to your Swap volume *in time* (this is key!). Only things in the /etc/fstab get checked at the beginning of the boot process. And you see, unless the disk has already been checked, mount_hfs will fail! If this happens, virtual memory ends up putting its swap files on the root volume (/). I believe the computer term for this is "screwed!".

To make things even more screwed, once your swap files are in the wrong place, they stay in the wrong place! This is why we need the extra code in /etc/rc -- it gets rid of these errant swap files.

Okay, so here it is in a nutshell... The /etc/fstab entry makes sure your disk gets checked in time (if needed), and the /etc/rc addition gets rid of old swap files that might be in the way. Swap mounts, and virtual memory merrily puts everything on the new partition!

And that, as they say, is that! So what are you waiting for? Go ahead and reboot!

    •    
  • Currently 2.00 / 5
  You rated: 1 / 5 (7 votes cast)
 
[35,446 views]  

10.3: Move swap to another partition in Panther | 43 comments | Create New Account
Click here to return to the '10.3: Move swap to another partition in Panther' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Move swap to another partition in Panther
Authored by: gvitale on Nov 13, '03 11:55:06AM

Someone might be interested to know that Swap Cop (http://www.versiontracker.com/dyn/moreinfo/macosx/13514) works just fine in Panther.



[ Reply to This | # ]
DO NOT USE Swap Cop!!! - NO LONGER SUPPORTED!!
Authored by: EatingPie on Nov 13, '03 11:23:52PM

I looked at the Swap Cop perl script and StartupItems. Interestingly, the author suggested his implementation as a change to Darwin's core, but it never was considered. The discussion of this can be found at the following URL:

http://www.opendarwin.org/pipermail/hackers/2002-August/000247.html

Swap Cop overrides the /etc/rc method entirely, but it MAY NOT WORK if your selected Swap volume isn't properly mounted.

AND after the above referenced discussion, the AUTHOR NO LONGER SUPPORTS SWAP COP!!!

This has danger written all over it!! Sure it may work in situation-normal, but in stress testing.... well go ahead and live dangerously!!

---
-Pie


[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: Frederico on Nov 13, '03 11:30:48PM

SwapCop does ***NOT*** work past OS X 10.1.x!!!

If you think you have SwapCop working in Jaguar or Panther, open Terminal and type:

[code]ps -auxww | grep dynamic_pager[/code]

It should return the PID and swapfile path; if it reads '/private/var/vm', then swap is set to the default. If it returns '/Volumes/yourSwapDrivename/private/var/vm' then SwapCop, by some miracle, is working.

If you get no return on your 'ps -auxww', your dynamic pager (i.e., your ability to swap) has crashed, possibly due to an outdated version of Memory Meters. Restart to correct.

FWIW, rumor has it that the source code for SwapCop is going to merge with SwapSwapVM, the latter of which the developer states is in final testing for public release "very soon".



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: gvitale on Nov 14, '03 05:03:41AM

I (and many others) DID HAVE Swap Cop properly manage swap file relocation in 10.1, 10.2 and now 10.3. Believe me, I know what I'm talking about.



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: gvitale on Nov 14, '03 05:06:12AM

Federico, here is the output of the command you suggest:
gvitale% ps -auxww | grep dynamic_pager
root 366 0.0 0.0 18080 284 ?? Ss 1:50PM 0:00.01 dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F /Volumes/Swap/.vm/swapfile
gvitale 627 0.0 0.0 8860 8 std R+ 11:05AM 0:00.00 grep dynamic_pager



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: Frederico on Nov 14, '03 03:39:35PM

If that's your output from Panther, then I would have to suggest you have some other mods going on; J. Schrier himself will tell you that SwapCop 1.1.2 will not function due to a change in load order of Startup Items versus RC code. If it's working, I'd guess it's because someone commented out the dynamic pager line in /etc/rc, or, you've still got your /etc/rc file from Jaguar.

I've just retested installing SwapCop under a virgin Panther, logged in as root, and it does not function. How did you get yours to work?

If you don't mind, how about posting the entire text of your /etc/rc file?



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: gvitale on Nov 14, '03 04:34:32PM

As I sed I (and others, people I know that is) have used SwapCop to successfully relocate swap file in 10.1, 10.2 and 10.3. Period.
You claim that the way this is achieved by SwapCop is the wrong way. Maybe.
The naked evidence is that SwapCop works fine when you use it to relocate the swap files to the first logical partition of a clean 10.1, 10.2 and 10.3 installation.
I have no clue why is not working in your hands Federico.
I will post my /etc/rc asap.
In any event, there is no real risk in using SwapCop: should anythink go wrong (it never did in my hands) boot in single user mode, mount / read-write, and mv /etc/hostconfig.backup.swapcop and /etc/rc.backup.swapcop to /etc/hostconfig and /etc/rc, respectively.
Easy, isn't it ;-)



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: EatingPie on Nov 14, '03 04:58:48PM
In any event, there is no real risk in using SwapCop
Lost data isn't much of a risk in my book either... :-)

---
-Pie


[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: gvitale on Nov 15, '03 03:17:44AM

Pie, you ain't funny, really...



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: EatingPie on Nov 18, '03 07:25:47PM

Am too!

---
-Pie
<http://www.storybytes.com>



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: Frederico on Nov 14, '03 07:52:00PM

I never meant to imply that using SwapCop was at all dangerous -- not sure where you read that into my statements -- indeed, SwapCop was not only a simple, elegant, easy to use solution in Jaguar, but Joshua Schrier and Scott Boone had the intelligence and foresight to allow SwapCop to fail gracefully in the event that the OS or /etc/rc file were to change in future. For most people under Panther, this is the case.

I'm also sensing some animosity towards me, or a sense that I am expressing animosity towards you; I assure you that I am only trying to explore this issue for the benefit of all. If I have somehow offended you, I'm sincerely sorry for having done so.

Regards

Frederico



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: gvitale on Nov 15, '03 03:40:16AM

Ok, let's get this straight: with my original post I did not mean to criticise the suggested strategy for swap relocation, but just point out an (easier) alternative that worked for me (and others); no animosity expressed or implied. That sed, I'm not knowledgeable enough of the OSX boot process to get into the technicality of the discussion. I DO NOT MEAN TO BE POLEMIC.
Federco, here is my Panther's /etc/rc (after running SwapCop, which I did after clean format-and-install Panther in the second 7GB logical partition of my 20 GB drive, to relocate swap to the first 700 MB logical partition; I'm using this setup since about 3 weeks and I haven't experienced no problems):

#!/bin/sh

##
# Multi-user startup script.
#
# Copyright 1997-2002 Apple Computer, Inc.
#
# Customize system startup by adding scripts to the startup
# directory, rather than editing this file.
##

stty intr undef
stty kill undef
stty quit undef
stty susp undef
stty start undef
stty stop undef
stty dsusp undef

. /etc/rc.common

stty status '^T'

##
# Handle arguments passed from init.
##

BootType=$1; shift;

if [ -z "${BootType}" ]; then
BootType="multiuser"
fi

VerboseFlag=""
SafeBoot=""

args=$(/usr/bin/getopt vx $*)
set -- ${args};
for option; do
case "${option}" in
-v)
VerboseFlag="-v"
;;
-x)
SafeBoot="-x"
;;
esac;
done;

if [ -d /System/Installation -a -f /etc/rc.cdrom ]; then
/etc/rc.cdrom ${BootType}
# We shouldn't get here; CDIS should reboot the machine when done
echo "CD-ROM boot procedure complete"
halt
exit 0
fi

netboot=$(/usr/sbin/sysctl -n kern.netboot)

# Mount essential local filesystems (according to /etc/fstab).
echo "Mounting local filesystems"

mount -vat hfs
mount -vat ufs
mount -t fdesc -o union stdin /dev
mkdir -p -m 0555 /.vol && chmod 0555 /.vol && mount_volfs /.vol

# 3281054 Cannot start up if /private/var/tmp is missing (system should recreate it)
mkdir -p -m 01777 /private/var/tmp

if [ -f /etc/rc.installer_cleanup ]; then
/etc/rc.installer_cleanup ${BootType}
fi

. /etc/rc.cleanup

BootCacheControl=/System/Library/Extensions/BootCache.kext/Contents/Resources/BootCacheControl
if [ ! -f $BootCacheControl ]; then
BootCacheControl=/usr/sbin/BootCacheControl
fi
if [ "${SafeBoot}" != "-x" -a -x "${BootCacheControl}" ]; then
${BootCacheControl} start
fi

# System tuning
sysctl -w kern.maxvnodes=$(echo $(sysctl -n hw.physmem) '33554432 / 512 * 1024 +p'|dc)
sysctl -w kern.sysv.shmmax=4194304
sysctl -w kern.sysv.shmmin=1
sysctl -w kern.sysv.shmmni=32
sysctl -w kern.sysv.shmseg=8
sysctl -w kern.sysv.shmall=1024
if [ -f /etc/sysctl-macosxserver.conf ]; then
awk '{ if (!index($1, "#") && index($1, "=")) print $1 }' < /etc/sysctl-macosxserver.conf | while read
do
sysctl -w ${REPLY}
done
fi

if [ -f /etc/sysctl.conf ]; then
awk '{ if (!index($1, "#") && index($1, "=")) print $1 }' < /etc/sysctl.conf | while read
do
sysctl -w ${REPLY}
done
fi

# Logs are important. Start syslogd after the boot disk becomes r/w but before
# everything else starts. In the future, we should launch this lazily when it
# is first needed.
ifconfig lo0 127.0.0.1 up
/usr/sbin/syslogd -s -m 0

# Create mach symbol file
rm -f /mach.sym
sysctl -n kern.symfile
if [ -f /mach.sym ]; then
rm -f /mach
ln -s /mach.sym /mach
else
rm -f /mach
ln -s /mach_kernel /mach
fi

if [ "${SafeBoot}" = "-x" ]; then
echo "Configuring kernel extensions for safe boot"
touch /private/tmp/.SafeBoot
kextd -x
else
echo "Configuring kernel extensions"
kextd
fi

# Load [ideally on demand] Mach bootstrap based services
/usr/libexec/register_mach_bootstrap_servers /etc/mach_init.d

# We hope to launch portmap on demand in the next major release of Mac OS X,
# but until then, we need to inline in here for reasons not worth going into in
# this file. Static reasons to run portmap today include:
#
# - if there are NFS exports, or
# - if NFS locking is on (NFSLOCKS=-YES-), or
# - if there are NetInfo domains other than "local", or
# - if the local domain has any non-loopback values for "trusted_networks".
# - if xinetd has a portmap based service
#
# Explicitly setting NETINFOSERVER=-YES- forces portmap to run.
#
# If portmap is not started now, it will be started later if
# NFSLOCKS=-AUTOMATIC- and an NFS locking request is made.
##
if [ "${RPCSERVER:=-AUTOMATIC-}" = "-AUTOMATIC-" ]; then
RPCSERVER=-YES-
nfs_exports_ni=$(nicl -raw /var/db/netinfo/local.nidb -list /exports 2> /dev/null | wc -w)
nfs_exports_etc=$(grep -v '^[[:space:]]*\(#\|$\)' /etc/exports 2> /dev/null | wc -l)
nfs_exports=$(($nfs_exports_ni + $nfs_exports_etc))
ni_not_local=$(/bin/ls -1d /var/db/netinfo/*.nidb | sed 's:/var/db/netinfo/local.nidb::' | wc -w)
ni_local_export=$(nicl -raw /var/db/netinfo/local.nidb -read / trusted_networks 2>&1 | sed 's/trusted_networks://' | sed 's/127[^ ]*//g' | wc -w)
total=$(($nfs_exports + $ni_not_local + $ni_local_export))
[ "${total}" -eq 0 ] && RPCSERVER=-NO-
[ "${NFSLOCKS:=-AUTOMATIC-}" = "-YES-" ] && RPCSERVER=-YES-
[ "${NETINFOSERVER:=-NO-}" = "-YES-" ] && RPCSERVER=-YES-
[ "${NISDOMAIN:=-NO-}" != "-NO-" ] && RPCSERVER=-YES-
grep -ri rpc /etc/xinetd.d >/dev/null 2>&1 && RPCSERVER=-YES-
fi

if [ "${RPCSERVER}" = "-YES-" ]; then
portmap
fi

# We would also like to start "netinfo" on demand too, but we can't for various
# reasons at the moment. Start it here for now:
#
# Create local NetInfo database if it doesn't exist
if [ ! -d /var/db/netinfo/local.nidb ]; then
echo "Creating local NetInfo database"
mkdir -p /var/db/netinfo
/usr/libexec/create_nidb
rm -f /var/db/.AppleSetupDone
fi

# nibindd is required if there are NetInfo domains other than "local", or
# if the local domain has any non-loopback values for "trusted_networks".
if [ "${NETINFOSERVER:=-AUTOMATIC-}" = "-AUTOMATIC-" ]; then
NETINFOSERVER=-YES-
ni_not_local=$(/bin/ls -1d /var/db/netinfo/*.nidb | sed 's:/var/db/netinfo/local.nidb::' | wc -w)
ni_local_export=$(nicl -raw /var/db/netinfo/local.nidb -read / trusted_networks 2>&1 | sed 's/trusted_networks://' | sed 's/127[^ ]*//g' | wc -w)
total=$(($ni_not_local + $ni_local_export))
if [ "${total}" -eq 0 ]; then
NETINFOSERVER=-NO-
fi
fi

# If nibindd is not required, we just start the local NetInfo daemon.
if [ "${NETINFOSERVER}" = "-YES-" ]; then
nibindd
else
cd /var/db/netinfo
netinfod -s local
cd /
fi

if [ ! "${netboot}" = "1" ] ; then
if [ ! -f /System/Library/Extensions.mkext -o \
/System/Library/Extensions.mkext -ot /System/Library/Extensions ]; then

if [ "${SafeBoot}" != "-x" ]; then
echo "Updating kernel extensions cache"
rm -f /System/Library/Extensions.mkext
/usr/sbin/kextcache -elF -a `arch`
fi
fi
fi

update

echo "Starting virtual memory"

swapdir=/private/var/vm
if [ "${netboot}" = "1" ]; then
sh /etc/rc.netboot setup_vm ${swapdir}
fi

# Make sure the swapfile exists
if [ ! -d ${swapdir} ]; then
echo "Creating default swap directory"
mount -uw /
mkdir -p -m 755 ${swapdir}
chown root:wheel ${swapdir}
else
rm -rf ${swapdir}/swap*
fi

#dynamic_pager -F ${swapdir}/swapfile

appprofiledir=/private/var/vm/app_profile

if [ ! -d ${appprofiledir} ]; then
if [ -f ${appprofiledir} ]; then
mv -f ${appprofiledir} "${appprofiledir}_"
fi
mkdir -p -m 711 ${appprofiledir}
chown root:wheel ${appprofiledir}
fi


if [ "${SafeBoot}" != "-x" -a -x "${BootCacheControl}" ]; then
${BootCacheControl} tag
fi

# Set language from CDIS.custom - assumes this is parse-able by sh
if [ -f /var/log/CDIS.custom ]; then
. /var/log/CDIS.custom
fi

# Start the Language Chooser. This code should be able to go away as far as I
# know once loginwindow becomes dynamic and SystemStarter exits the GUI
# business.
STARTPBS="/System/Library/CoreServices/pbs" # apps stall w/o
BUDDYCOOKIE="/var/db/.AppleSetupDone"
LCACOOKIE="/var/db/.RunLanguageChooserToo"
STARTLCA="/System/Library/CoreServices/Language Chooser.app/Contents/MacOS/Language Chooser"

if [ -x "$STARTLCA" -a -x "$STARTPBS" -a ! -f "$BUDDYCOOKIE" -a -f "$LCACOOKIE" ]; then
"$STARTPBS" &
pbspid=$!
"$STARTLCA"
kill $pbspid # XSelect does this independently
fi

if [ ! -s "/var/log/CDIS.custom" ]; then
echo "Language Chooser seems to have failed; defaulting to English"
echo "LANGUAGE=English" > "/var/log/CDIS.custom"
fi

export LANGUAGE

SystemStarter -gr ${VerboseFlag} ${SafeBoot}

exit 0

Upon request I can post Jaguar's /etc/rc obtained as described above.

Sorry for the long post and best regards.
gaetano



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: gvitale on Nov 15, '03 03:47:17AM

For the sake of completeness, this is /etc/hostconfig (the second file that SwapCop modifies in your system):

##
# /etc/hostconfig
##
# This file is maintained by the system control panels
##
# Network configuration
HOSTNAME=-AUTOMATIC-
ROUTER=-AUTOMATIC-
# Services
AFPSERVER=-NO-
AUTHSERVER=-NO-
AUTOMOUNT=-YES-
CUPS=-YES-
IPFORWARDING=-NO-
IPV6=-YES-
MAILSERVER=-AUTOMATIC-
NETINFOSERVER=-AUTOMATIC-
NFSLOCKS=-AUTOMATIC-
NISDOMAIN=-NO-
RPCSERVER=-AUTOMATIC-
TIMESYNC=-NO-
QTSSERVER=-NO-
WEBSERVER=-NO-
SMBSERVER=-NO-
DNSSERVER=-NO-
COREDUMPS=-NO-
VPNSERVER=-NO-

VIRTUALMEMORY="/Volumes/Swap/.vm"
CRASHREPORTER=-YES-



[ Reply to This | # ]
overly complicated
Authored by: daniel_steffen on Nov 13, '03 01:16:00PM
actually you don't need to modify /etc/rc nearly as much on Panther, since it already contains the followin line (which will also check volumes in case of a force reboot)
mount -vat hfs
the -a flag mounts any filesystems in /etc/fstab referenced via /dev/disk* directly, i.e. put the following in /etc/fstab:
/dev/disk0s7 /Volumes/Swap hfs rw 1 2
and make sure /Volumes/Swap exists (BTW, it doesn't matter if a directory used as a mountpoint contains anything, no need to remove it).

the newer reference forms LABEL= and UUID= in /etc/fstab are only understood by autodiskmount which I have been unable to get to run in /etc/rc in Panther (used to work in Jaguar).

With this, the only changes necessary in /etc/rc are then to swapdir and appprofiledir as above.

[ Reply to This | # ]

overly complicated
Authored by: daniel_steffen on Nov 14, '03 07:32:22AM
one additional detail: if your filesystems in /etc/fstab are not all HFS journaled, you need to ensure fsck is run on them in before the mount -vat in /etc/rc; as, unfortunately, unlike mount, fsck has still not been fixed to respect /etc/fstab, even though its manpage says it does...

For instance the following will emulate the advertised behaviour of fsck:

--- /etc/rc.boot.orig   Thu Sep 18 14:29:41 2003
+++ /etc/rc.boot        Fri Nov 14 18:12:24 2003
@@ -113,6 +113,9 @@
        case $? in
          0)
            # No problems
+            awk '/^\/dev\// && $4=="rw" && $6>0 {
+                 if($3=="hfs") system("fsck_hfs -dp "$1)
+                 else system("fsck -p "$1)}' /etc/fstab
            ;;
          2) 
            # Request was made (via SIGQUIT, ^\) to complete fsck
with this change, any read-write volumes referenced via /dev/disk* in /etc/fstab (and with a fs_passno field > 0) will get mounted at startup in /etc/rc regardless of whether they have been unmounted cleanly. (with _no_ changes required to /etc/rc)

[ Reply to This | # ]
overly complicated
Authored by: daniel_steffen on Nov 14, '03 08:33:59PM
looks like GeekLog has garbled the patch, the should be a backslash preceding both the '/' surrounding the dev:
awk '/^\/dev\// &&


[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: EatingPie on Nov 13, '03 08:42:00PM

I will check both of these methods and update accordingly. But let me throw out a few comments first... my purpose is to welcome discussion here, not to be critical.

BTW, it doesn't matter if a directory used as a mountpoint contains anything, no need to remove it.

The reason for the removal is not for a *correctly* mounted Swap volume. If your Swap FAILS to mount, the vm system will create a swap directory in "/Volumes/Swap" but this will be on your root volume. Then when the Swap Volume *does* mount, it will mount as "/Volumes/Swap 1". This means your Swap is mounted in the wrong place, and the swap files *still* go on your root volume (now into a directory named "/Volumes/Swap")! AND... since that directory exists between reboots, your swap volume will NEVER mount on "/Volumes/Swap" and your vm files will NEVER go onto the separate volume! Ack!

So the removal code occurs to fix a (possible) previous failure.

See, the trick is not to get this to work when all things are happy and normal. It's to cover your OSes ass! That's why the removal occurs, and so on. *Without checking* (that's a caveat), this is why I believe Swap Cop will not work either. Yeah, in situation normal. But what if you force reboot? Or what if your Swap Volume gets corrupted? Maybe it does work, but, again, I am suspect. Why? For the plain and simple fact that most early Swap-moving implementations in Jaguar didn't work when stress tested as well. (And c'mon, we all have to force reboot sometime or another... and it's unacceptable for this to permanently disable your swap move!)

I will check Swap Cop though to see what it does. I will also try the different mount syntax. I'm all for simplicity, and I would have definitely preferred a *smaller* solution. But I think the mount syntax change will only be a... well... mount syntax change! I am dubious on it actually helping. But we'll see...

BTW... Feel free to comment on what I've said. If this leads to a better solution, that would rock!

What I'm saying here may be scaring some people away at this point. So let me say this: I have thoroughly tested this solutuon. THOROUGHLY. I even destroyed my Swap volume (accidentally), and this method was STILL able to recover and get my swap running on it without any intervention on my part.

So I am *very* confident of its stability, otherwise I would not have posted it!

---
-Pie


[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: daniel_steffen on Nov 13, '03 10:56:18PM
Pie,
my purpose is to welcome discussion here, not to be critical.
sure, no prob
The reason for the removal is not for a *correctly* mounted Swap volume. If your Swap FAILS to mount, the vm system will create a swap directory in "/Volumes/Swap" but this will be on your root volume. Then when the Swap Volume *does* mount, it will mount as "/Volumes/Swap 1".
I do understand this and know the problem from Jaguar but I don't believe this can occur anymore in Panther with my setup above, a mount as /Volumes/Swap 1 can only occur if mount -vat hfs fails but autodiskmount -va later on (in StartupItems) is successful at mounting the volume. This sort of thing used to happen on 10.1/10.2 but with better support for fstab on Panther it doesn't seem to happen anymore as far as I've seen, but further testing would cetainly be useful to confirm this.

See, the trick is not to get this to work when all things are happy and normal. It's to cover your OSes ass!
most early Swap-moving implementations in Jaguar didn't work when stress tested as well.
I agree w.r.t Jaguar, where I know this problem well (the best way to workaround it there was to run autodiskmount in /etc/rc)

However, this seems much improved in Panther, _if_ you use fstab as above; which makes all the precautions that were needed for Jaguar unnecessary in my experience.

FWIW I haven't seen any of the Jaguar style problems with my technique across numerous hard reboots and panics in many seeds of Panther as well as the final release.

But I think the mount syntax change will only be a... well... mount syntax change!
the important thing to understand is that the existing, early mount -vat hfs in /etc/rc has no effect with fstab formatted as in your original hint, whereas it does indeed cause the mount and disk check if explicit /dev/disk* is used. That's what makes all the difference and makes your use of mount_hfs unnecessary.

Let me note that it is possible that the improved behaviour vs Jaguar I'm seeing is related to use of journaled HFS which doesn't cause fsck to run, but I doubt it since I had the same volume journaled under 10.2 (not a swap volume btw) and I needed the autodiskmount workaround.



[ Reply to This | # ]

autodiskmount does work in Panther rc script... BUT don't use it!!
Authored by: EatingPie on Nov 13, '03 10:46:10PM

To get autodiskmount to work in Panther, you need to sleep after the call. IE


/sbin/autodiskmount -d
sleep 1

In Panther, a lot of stuff in the /etc/rc script runs in parallel. The /etc/rc script executes it, but does not wait for it to return before going on to the next step. Doing the sleep ensures that autodiskmount completes before the /etc/rc script gets too far afield.

Note that my original version of this hint used autodiskmount rather than mount_hfs. But once my swap overflowed the partition (ooh bad!), that method never worked again without intervention on my part... and was flakey from then on.

I still overflowed my swap after implementing the mount_hfs method, and much to my surprise it did recover... without any intervention on my part. And still works!

So I do not recommend using autodiskmount in Panther's /etc/rc script! And I say this as one of the original people who suggested it for use in Jaguar, so I'm not making this statement lightly.

---
-Pie


[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: EatingPie on Nov 14, '03 02:10:26AM
I do understand this and know the problem from Jaguar but I don't believe this can occur anymore in Panther with my setup above, a mount as /Volumes/Swap 1 can only occur if mount -vat hfs fails but autodiskmount -va later on (in StartupItems) is successful at mounting the volume.

Yeah I'm pretty sure you're right here. (I don't have my 10.3 computer because it's getting fixed so I can't check this directly.) But this leads to the nagging question: what happens if the directory at your mount point exists, and has stuff in it? Will the "mount -vat hfs" work? With other UNIX variants, mount DOES, but it hides what's there already. That means if you have existing swap files at in the "/Volumes/Swap" *directory* on your root partition, they get hidden by the new "/Volumes/Swap" *Volume* being mounted there. This makes the files in the directory you've mounted over inaccessible, and you can't delete them. So you've got at least 64MB (1 swap file) of wasted disk space on your root that you can never axe.

That's what I *think* might happen, anyway! Like I said, I can't test to see. But *if* this is the case, it still makes the delete section of the rc script necessary.

Okay moving on...

[T]he existing, early mount -vat hfs in /etc/rc has no effect with fstab formatted as in your original hint, whereas it does indeed cause the mount and disk check if explicit /dev/disk* is used. That's what makes all the difference and makes your use of mount_hfs unnecessary.

You're right here... with one little correction. The mount call does not cause the disk check (fsck) to occur. Moreso, if fsck hasn't occured, mount will fail! The /etc/fstab entry -- either of ours -- causes an fsck to occur, but it happens in the "/etc/rc.boot" file. The root file system gets checked by default (if necessary) in "/etc/rc.boot" *and* any filesystem specified in /etc/fstab. I'm betting this also happened in your testing as well. Then, when you hit the "mount -vat hfs" the fsck has been done, and all is well, so the mount occurs. If the fsck had *not* been done, the mount would have actually failed (with journaling off anyway).

And you are also right about my entry for /etc/fstab not working with mount -vat hfs. But, ironically enough, I don't want it to!!!

Let's look at when a *populated* "/Volumes/Swap" *directory* exists -- for example, in case a previous boot's mount failed... and my swap overflow issue does cause it to fail! Here, I want to delete all the unneccessary system-created garbage in that directory, and do so at boot time... before I mount my *real* Swap volume. I don't care wheether the existing "/Volumes/Swap" is a directory that blocks a mount, or simply contains files that get hidden by the "real" Swap volume once it's mount. In either case, I need to delete that bogus "/Volumes/Swap" directory.

In order for me to do so, the *real* "/Volumes/Swap" *Volume* can NOT be mounted (it's hiding those big 'ol swap files that we never use). That's why I added the umount call in my /etc/rc script -- just for this contingency. But it'd be better (performance-wise) if the volume wasn't mounted at all... that way it doesn't have to be unmounted! (Though the performance hit of mount/unmount/mount is probably negligable during the Panther boot process.) Anyway, that's why I don't care if the mount -vat hfs works: I *always* unmount later so I can get to any extant garbage lying around... and then do the *real* mount afterward so VM works all fine and dandy.

Well, I hope I my explanation made sense... it *is* getting late. I still am loathe to excise the code that deletes old "/Volumes/Swap" garbage, even if your code works as advertised. There's a perfect world, then there's Panther... or any other OS for that matter. And when I code, I just like to make sure I've covered all the bases.

---
-Pie


[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: daniel_steffen on Nov 14, '03 08:11:18AM
But this leads to the nagging question: what happens if the directory at your mount point exists, and has stuff in it? Will the "mount -vat hfs" work?
yes it does; as you mention, it indeed just hides the contents of the directory. If you also want to see the contents of the dir underlying the mountpoint, use a union mount, c.f. man fstab

So you've got at least 64MB (1 swap file) of wasted disk space on your root that you can never axe.
but as long as /Volumes/Swap is empty before you install your changes to /etc/fstab this will never become a problem.
The root file system gets checked by default (if necessary) in "/etc/rc.boot" *and* any filesystem specified in /etc/fstab..
that's what I though too, and what the fsck manpage leads one to believe; unfortunately it's not the case, fsck still ignores /etc/fstab on Panther :-( (it only uses netinfo which is not running yet in /etc/rc.boot of course).

I had not seen the effects of this because the filesystem referenced in my /etc/fstab was journaled, where it doesn't matter that fsck has not been run, as it always mounts cleanly.

Luckily, there is an easy fix to /etc/rc.boot that emulates the advertised behaviour of fsck for non-journaled filesystems, c.f. patch in my new comment above.

I *always* unmount later so I can get to any extant garbage lying around... and then do the *real* mount afterward so VM works all fine and dandy.
as mentioned, I don't think this is necessary, there will never be any unwanted contents in /Volumes/Swap as long as fsck is run as above, because the mount will then always succeed.

If you wanted to clear /Volumes/Swap even so, you'd be better off using a union mount rather than unmounting and remounting the volume.

The overall disadvantage of your method is that you have to put explicit /dev/disk* values into /etc/rc; whereas with my method, the unique place the Swap partition is referenced by device name is in /etc/fstab. This simplifies maintenance.

Note that the usual caveats about referencing partitions via direct device names apply: you're essentially only safe referencing a partition on your boot drive(which will alwyas be /dev/disk0) in this way , partitions on other drives can change their device name depending on e.g. what removable drives are plugged in.

I use the present technique on various machines not for a separate swap partition but for a separate partition containing _all_ user modified files (for backup ease & sharing by different OS boot partitions); in particular /Library/Preferences is symlinked to a dir on that partition; and files in that directory are needed during the startup process before autodiskmount has run (e.g. to setup networking).
If the volume containing my /Library/Preferences were not mounted cleanly in /etc/rc, it would immediately become apparent to me as networking would not work. This has certainly not been the case across many hard reboots & panics, and with the patch above, it now also works for non-journaled filesystems referenced in /etc/fstab.

[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: EatingPie on Nov 14, '03 12:05:57PM

It is sounding like both methods do the job, and do it right. I will give yours a shot when I get my computer back from Apple (soon... Please!!!)

But in the mean time....

[T]hat's what I though too, and what the fsck manpage leads one to believe; unfortunately it's not the case, fsck still ignores /etc/fstab on Panther :-( (it only uses netinfo which is not running yet in /etc/rc.boot of course).

I had not seen the effects of this because the filesystem referenced in my /etc/fstab was journaled, where it doesn't matter that fsck has not been run, as it always mounts cleanly.

Hmm. But as I mentioned, I am not using journaling. And the fsck is most definitely getting done. Nothing I tried re-mounted the Swap partition after a forced reboot. It was only after I checked the /etc/rc.boot and added the /etc/fstab entry that it worked.

I do know that adding an /etc/fstab entry in Jaguar didn't work... though what version of Jaguar, I can't remember (all probably!). But in Panther, the entry is causing the fsck to get done, and it's behaving during boot exactly as expected.

---
-Pie


[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: EatingPie on Nov 14, '03 05:03:18PM
The overall disadvantage of your method is that you have to put explicit /dev/disk* values into /etc/rc; whereas with my method, the unique place the Swap partition is referenced by device name is in /etc/fstab. This simplifies maintenance.

Agreed! I would be happy for a simpler method... though even with your given arguments, I am still loate to eliminate the code the extricates errant swap files on the root volume....

That said, can you please post a full explanation of your solution. IE, what files to change, and exactly how. I have a good idea from your posts already, but something explicit would be handy.

TIA!

---
-Pie


[ Reply to This | # ]

D'oh -- Nevermind -- It's Pretty Clear in your First Post....
Authored by: EatingPie on Nov 14, '03 05:05:26PM

Sorry.

---
-Pie
<http://www.storybytes.com>



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: EatingPie on Nov 14, '03 11:26:35AM

Yes, Swap Cop has been reported to work. But it moves your swap THE WRONG WAY. How do we know?

(1) It may cause vm to crash, leaving you with no vm... the AUTHOR says this in the link I posted earlier.
(2) It may start too late to work right... yeah it's started, but WAY late in the boot process.
(3) It may not start at all.
(4) It may LOOK LIKE it's working, but it probably ISN'T working right!

Okay, so here it is in a nutshell: DO NOT USE SWAP COP!!!!

---
-Pie


[ Reply to This | # ]

10.3: Move swap to another partition in Panther
Authored by: milhouse on Nov 14, '03 08:02:44PM

Xupport can successfully move swap files in Panther. I moved mine and using "ps -auxww | grep dynamic_pager" in the terminal reveals the active swap file on the new swap partition .

YMMV



[ Reply to This | # ]
Force Reboot Breaks Xupport
Authored by: EatingPie on Nov 18, '03 07:23:52PM

The current version of Xupport (beta5?) MAY NOT WORK if you force reboot. I contacted the author about this but received no response.

The method he is using is for Jaguar, and his Panther fix is to simply sleep 5 seconds after calling autodiskmount. Problem one is that this slows your reboot process. Problem two is that 5 seconds is arbitrary and simply may not work: if your Swap is larger than a certain size, autodiskmount will take longer than 5 seconds to fsck the partition... And thus it won't mount, and your screwed... FOREVER. (Well, until you fix it yourself.)

YMMV indeed!

---
-Pie


[ Reply to This | # ]

Caveat - Swap Partition Overflow
Authored by: EatingPie on Nov 19, '03 02:44:17PM

If you do move your swap to a new partition with Panther, you must make sure that partition is large enough to not overflow.

I tested with a 5GB partition and 1GB RAM. This partition size will always (eventually) overflow, causing random application crashing.

After thorough monitoring of Panther's VM, I believe you need at least 8GB, with 10GB or larger being an even safer bet.

This varies with the number of applications you run, but in my testing I ran just enough to fill my 1GB RAM. Here is the list of applications I started:

Finder
Classic
Terminal
Safari
X11
iTunes
iPhoto (w/1200 photos)
Sherlock
Eudora 6
ircle 3.1f2
Fire
Photoshop
Graphic Converter
Activity Monitor

Using Activity Monitor, it shows my RAM as almost full, and 6.3GB of VM allocated. But this is without doing any real work in these applications... I just started them until my RAM filled. Once I begin working with these apps, my VM will need room to grow.

---
-Pie


[ Reply to This | # ]

No fstab file and concerns about losing files on the partition
Authored by: bergschrund on Nov 27, '03 03:42:24PM
I would like to try this solution, having had problems both with SwapCop (leftover from Jaguar days) and with Xupport (which as mentioned fails after a hard reboot). However I have two concerns.

1) I have no fstab file in the /etc/ dir. I do have a fstab.hd file which is essentially blank. I assume that it would be okay to create the fstab file - with root permissions, but want to make sure before I do this.

2) I do not have a dedicated swap partition, but would like to move the swap files over to a much larger (and more accommodating) partition. In the code that is placed in the rc file, it appears that with a hard reboot the script would erase the partition volume entirely. Is this correct? Would it be possible to modify this so that it simply removes the old vm files?

Thanks for your help.

[ Reply to This | # ]
No fstab file and concerns about losing files on the partition
Authored by: hard-mac on Dec 09, '03 06:56:17PM

No /etc/fstab file here either. I presume it is fine if I just create one? Can anyone confirm this?


hm

---
-------------------------------------
Hardening Your Macintosh
http://hardmac.blog-city.com



[ Reply to This | # ]
No fstab file - Tried creating - Bad mistake
Authored by: apr400 on Dec 10, '03 06:00:43AM
I have no fstab, but I do have fstab.hd which has this non-commented text in about the file:

IGNORE THIS FILE.
This file does nothing, contains no useful data, and might go away in future releases. Do not depend on this file or its contents.


I tried creating an fstab and my machine wouldn't boot. I didn't even get to the gray screen, just a couple of lines of text which I will remember to write down next time I see them. Didn't get far enough to write errors to the log either, so I'm guessing that it was the presence of fstab rather than the change to rc. Given that, it would be useful if someone could post a copy of their fstab. I know it's supposed to be all commented, but maybe it has a shebang at the top.

I booted off a backup and checked the alterations I'd made to fstab and rc but they were all fine. So for the moment I've reverted to the old rc and deleted fstab.

When I get a chance I might try the same thing with fstab.hd, and am also trying to figure out why I have no fstab. My Panther is an upgrade install on top of 10.2.8. I have a colleague who did a clean install and does have fstab so maybe that's the difference - Anyone confirm that?

Also does anyone know if this Jaguar hint (http://www.macosxhints.com/article.php?story=20021011053443661) for creating an fstab and adding it to netinfo still works in Panther?

[ Reply to This | # ]
No fstab file - Solution
Authored by: apr400 on Dec 16, '03 09:18:47AM

In the end, I backed up, and then did an Archive install. Less painful than I expected.

That gave me an fstab to work with, and I was able to make the swapfile change. One oddity was that vm and the swapfile didn't appear in my new swap partition to start with. But after deleting swapfile0 in private/var/vm, and restarting again everything was okay.



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: ptwithy on Nov 30, '03 04:31:20PM

I just added the following line to my fstab. In Panther, this seems to be sufficient to put my swap on a separate partition without any other modifications. I create a partition that I intend to use only for swap.


/etc/fstab:
UUID=8AE855ADC404CC8D	/private/var/vm         hfs	rw	1 2
I used the hints elsewhere to discover the UUID that Disk Utility assigns to partitions and use the UUID so that I can name my partition .Swap, which will cause it not to be visible in the Finder. By mounting the volume where the default swap directory is, I don't have to munge /etc/rc.

[NOTE: I have not tested this in Jaguar, previous attempts in Jaguar using LABEL= did not work. I believe that Panther fixes some issues with mount that caused the line in /etc/rc that tries to mount all the disks in fstab to fail in Jaguar.]

Having a separate swap partition may be less of an issue these days as there does seem to be a mechanism that prevents you from filling your drive with swap files ... in Jaguar when this happened, open Apps, such as Mail, would not be able to write their prefs out because they would get a 'disk full' error. Panther seems to warn you to quit some apps before you get to this state.



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: oink on Nov 30, '03 08:21:07PM

UUID is definitely better than using LABEL. The computer crashes everytime you mount a disk image or external drive with the same LABEL. Very easily done when you use CCC for backup.



[ Reply to This | # ]
10.3: Move swap to another partition in Panther
Authored by: oink on Dec 12, '03 10:09:54PM

I made a few modifications, namely:

Moved the swap location to a bigger partition (not a dedicated partition), named "aaa"
instead of rm /Volumes/aaa if found! (Yes, scarry eventhough logically correct), I used: mv /Volumes/aaa /aaa
instead of using label in the fstab, I used the uuid code

I have used this with much success until 2 days ago. I seem to get the crash screen at start up very regularly now. Disk Warrior fixed some rather minor errors, and one "overlapped extent allocation" (safari related). Using my backup rc file seems to always solve it. I wonder if any one else is experiencing the same.

While on the swap file issue, after each fix, my system seem to boot up without using any swap file. Somehow it feels the same. I wonder if there is going to be problem if I stop the dynamic pager from loading and skip the swap file for a while at least while I am trying to solve this crash issue.

I have a 10 gig hard disk and regularly I would max it while working. I usually have to restart every 5 hours or so to get rid of the growing swap files. I would really like to have a dedicated swap partition, at least it would stop it from growing, no? I have 512mb of ram, and a slowish G4 400mhz Ti Book

Thanks in advance



[ Reply to This | # ]
Web site documenting a similar approach
Authored by: syzygies on Dec 24, '03 10:12:26AM
I found this hint and the commentary very helpful in updating my swapfile mechanism for 10.3. I've written a novice-friendly web page describing my synthesis of what I learned, Moving the swapfile in Mac OS X 10.3 (Panther). All comments are welcome.

[ Reply to This | # ]
Re: 10.3: Move swap to another partition in Panther
Authored by: syzygies on Dec 25, '03 11:32:33AM

This hint is fairly but not completely robust, and works in 10.3. It makes several essential observations: the use of fstab, the use of umount and mount_hfs, and the importance of examining the behavior during forced reboots.

I would gently critique this hint as follows:

1. As noted in earlier comments, "/dev/disk0s14" is a better syntax than "LABEL=Swap" for the fstab entry, because the swap partition will then usually mount in time without help, saving the time spent on every boot waiting for mount_hfs. The umount and mount_hfs should be tried conditionally.

2. Even after all the measures taken in this hint, the swap partition can in rare instances fail to mount. One experiences this regularly while experimenting, because experiments can throw the system seriously out of whack. However, it is wrong to assume that this can't also happen for unknown reasons. Relocating the swapfile should be done conditionally, only if the swap partition successfully mounts. The only reason for the code to remove swap directories is to clean up after botched attempts to move the swapfile. Instead, never make botched attempts, and remove the obsolete swap files from /private/var/vm, as rc also does before modification.

3. There is no need to actually replace lines in /etc/rc. Redefining swapdir after the original definition has the same effect, and one can then revert by simply deleting clearly labeled insertions.

4. Anyone who needs a lesson in order to use a command line editor would be far better off downloading the demo or pay version of BBEdit, choosing Open Hidden... from its File menu, showing All Files, and editing in a familiar manner.

5. The fstab one-liner in the comments to instead mount the swap partition at /private/var/vm is very clever. However, this may only work if one substitutes the "/dev/disk0s14" syntax, and it does not work after forced reboots.

6. The single sentence take-away message from this hint is "Does your swapfile strategy work after forced reboots?", yet most comments ignore this question. Various authors then diplomatically ask followup questions, gently trying to get others to address this issue, and then slip away in frustration when they fail to get their message across. There remains no credible evidence that any off-the-shelf program moves the swapfile as robustly as a carefully custom-crafted hack. If someone wants to counter this assertion, they should explicitly describe the tests that they have carried out, knowing that others are examining their choice of words to assess their understanding, like an orals committee in grad school. Simply asking to have one's word believed won't convince anyone, given the poor signal-to-noise ratio on the internet.

I welcome a similar critique of the advice offered in my tutorial, Moving the swapfile in Mac OS X 10.3 (Panther), which documents what I was able to confirm by experiment after reading this and other web pages, having moving my swapfile in each release of OS X. There, I offer code that I believe to be more robust.



[ Reply to This | # ]
Re: 10.3/4GB Swapfile Partition size?
Authored by: cyberflyer on Dec 30, '03 06:50:12PM

I'm breaking in and setting up a new Dual G5 with 4 GB of ram, a 72 Gig 10Krpm System/boot disk and a 250 Gig 7.2Krpm Swap/Users work disk.

Currently I'm thinking:

72 Gig Fast Boot Disk:

20 GB - OS X 10.3
10 GB - OS X Dev Tools
10 GB - OS Classic
32 GB - Scratch for Photoshop, 3D rendering etc.

250 Gig Work Disk:

10 GB - Swapfile Partition
20 GB - OS X 10.3 (backup clone)
10 GB - OS X Dev Tools (backup clone)
10 GB - OS Classic (backup clone)
190 GB - Users (work, tunes, etc.)

The plan is to redirect the user folders to the users partition and the swapfile to its partition and keep the OS, Apps and scratch disks on the high speed drive.

Then set up a cron file to periodically backup the current state of my fast drive to the work drive. Worst case my fast drive burns up I can operate from the work drive.

I'd REALLY love a critque of this scheme. I'm an experienced Mac user, but only just getting into the guts of OS X now that Panther is here.

One concern is the size of the swap file partition. I read that 500 Mb will do it but that is an old post for a 512 Kb ram system. Then I read that 5 Gb is needed, 10 GM is recommended to avoid overflow, but that's for a 1 GB ram set up and I already have 4 GB of ram and can reasonably expect to upgrade to 8 GB of ram in the future. Then I read that with enough ram, swapfiles don't get used.

Can anyone provide me with experience on this issue?

How big should a swapfile partition be for a 4 GB ram OS 10.5 system running on a dual 1.8 G5?

What am I about to do wrong that I don't realize?

Thanks in Advance.

Cy.



[ Reply to This | # ]
Re: 10.3/4GB Swapfile Partition size?
Authored by: EatingPie on Dec 30, '03 07:34:07PM

Wow this thread has really grown!

I can't comment on any real-world metrics beyond the 1GB RAM range (I really wish I could afford to!!). However, given my experience in Panther with swap, I would say you want 10GB swap per 1GB RAM. But I can't say for sure.!

I do, however want to comment on this...

... Then I read that with enough ram, swapfiles don't get used.

With Panther, this isn't true! I always have at least one swap file in Panther... but that's still not the whole story!

In my 1GB RAM/5GB Partition scheme, applications started crashing. BUT... my swap files themselves still had not reached 512 MB total! Yet VM use showed above 5GB using Activity Monitor! (Hence my apps dropping like flies.)

I'm not sure what's going on in the kernel, but you cannot depend on small swap files telling the whole story!!

Panther is a lot more persnickity about swap than Jaguar, so the best advice I can give is be careful, and make the biggest swap partition you can!!

---
-Pie


[ Reply to This | # ]

Re: Swapfile Partition/RAM size?
Authored by: cyberflyer on Dec 30, '03 10:01:49PM

> In my 1GB RAM/5GB Partition scheme, applications
> started crashing. BUT... my swap files themselves still
> had not reached 512 MB total! Yet VM use showed
> above 5GB using Activity Monitor! (Hence my apps
> dropping like flies.)

OK. This gives me the sensation that there is another parameter that needs to be adjusted in High RAM configurations. It seems that 512 MB of swap file space is generally plenty. The swapfiles run 80MB a piece, how many are you going to need at once?

Something else is making the apps crash, I suspect. 10MB of SwapDisk per 1 MB of RAM is overkill. The best older reccommendation I could find is 2:1 Disk:RAM.

If I install 4 GB of RAM, I'd need 40 GB of swap disk, which is, well, somehow excessive for 80 MB swap files when more RAM is supposed to reduce the amount of swapping VM bothers to do.

I bet there is another parameter in the Startup process that needs to be tweeked when you get up past 1 GB of RAM to smooth this problem out, but I'm not the guy to find it.

Anyone want to track this down?



My one gig Powerbook Pismo shows VM at:
VM: 4.68G + 77.5M 156(0) pageouts

My three (one gig is in the shop) Dual G5 shows VM at:
VM: 3.13G + 70.2M 0(0) pageouts



Cy.



[ Reply to This | # ]
Re: 10.3/4GB Swapfile Partition size?
Authored by: syzygies on Dec 31, '03 01:34:20AM

Most of my experience with virtual memory and swapping is with large math computations, a single process on Unix using more than physical memory. No matter how big swap is, the process starts seriously slogging when it starts swapping. We generally bail and find a bigger machine long before swap runs out. I've also had Apple hardware since 1980, but the Mac is Unix now, my swap intuitions finally apply.

A memory leak has a very different signature from a process that is page-thrashing. By its nature the unreclaimed leaking memory is never used again, the process careens along with NO performance hit until swap runs out, then splat.

No one has the patience to watch a page-thrashing process run out of swap. No one realizes anything is wrong, on the other hand, until a leaking process goes splat.

Add to this mix confirmed reports of memory leaks in 10.3, and I'd bet that anyone needing a swap 10x memory has a leak.

What is less painful to watch is two processes taking turns with physical memory, whose combined usage exceeds physical memory. This is the sort of thing a swap 2x memory is good for.



[ Reply to This | # ]
How to put swap on a different drive in Panther
Authored by: TigerKR on Jan 01, '04 11:31:06PM
I have a DP1.25 MDD tower.

It has a 2 bus SCSI card. Attached to the first SCSI bus are two drives. Attached to the second SCSI bus is one drive. There are no other SCSI drives in the tower, and there are no IDE drives in the tower (just two ATA optical drives - but that's irrelevant).

SCSI0:
•DriveA
•DriveB

SCSI1:
•DriveC

Here's the problem. When I first installed Panther, when I typed df in the terminal, the drives were ordered as such:

/dev/disk1s10 DriveA
/dev/disk2s10 DriveB
/dev/disk3s10 DriveC

Now, after a few days, they're ordered differently:

/dev/disk1s10 DriveA
/dev/disk2s10 DriveC
/dev/disk3s10 DriveB

This is a problem, because DriveB has my swap, and DriveC has my Users (properly set in netinfo).

In order to use DriveB for my swap, I thought that I had to add a line to my /etc/fstab file:

/dev/disk2s10 /Volumes/swap hfs rw 1 2

When the system decided (randomly) that it wanted to switch B and C, then /dev/disk2s10 pointed not to my swap, but to my users - and it mounted my users as the swap! Not only that, but it recreated a new /Users folder! Then it mounted swap as "swap 1".

I had to fix everything, and I was concerned that it would flip-flop again (randomly).

And in fact, from this discussion :

>Using fstab for moving the swap is a bad idea.
>You have absolutely no assurance that what was
>/dev/disk1s2 (for example) one day will still
>be /dev/disk1s2 the next time you boot.

In other words, from this discussion :

>Character device description files (such as
>/dev/rdisk0s10) are created at boot time and
>do not survive a shutdown. Unless the boot
>volume is a CD, disk0 should contain the boot
>volume, but all other numbers cannot be assumed
>to remain stable.

A lot of people suggested that I use LABEL or UUID in /etc/fstab . But that wouldn't work because autodiskmount is supposedly loaded after VM.

Anyway, I think that I found the answer to the problem. Apparently, Panther doesn't mount non-IDE drives until the user logs in (and then unmounts them when the user logs out). This not only has implications for swap, but also being able to ssh into a computer where there is no user logged in.

You're going to need to have a swap partition formatted and ready to go, then edit /etc/rc with sudo. Here's the code to stick into your /etc/rc file. After it says "swapdir=/private/var/vm" paste this (this is a slightly altered version of syzygies code - which is linked above):

#------------------------------------- below inserted locally
newswap=/Volumes/swap
oldswapdir=${swapdir}

if [ ! -d ${newswap}/.Trashes ]; then
	swapcount=1
	ConsoleMessage "Waiting for ${newswap} to mount"
	while [ "$swapcount" -le 30 ]; do
		sleep 1
		if [ -d ${newswap}/.Trashes ]; then
			ConsoleMessage "${newswap} mounted after $swapcount seconds"
			break
		fi
		swapcount=`expr $swapcount + 1`
	done
fi

if [ -d ${newswap}/.Trashes ]; then
	swapdir=${newswap}/.vm
	ConsoleMessage "Using ${newswap} for swapfile"
	if [ -f ${oldswapdir}/swapfile0 ]; then
		rm -rf ${oldswapdir}/swap*
    echo "Removing old swapfiles from ${oldswapdir}"
	fi
else
	ConsoleMessage "Unable to use ${newswap} for swapfile"
fi
#------------------------------------- above inserted locally


And then if you're using non-IDE drives for swap, in the terminal, type:

sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisksWithoutUserLogin -bool true


There's no need to alter the /etc/fstab file.

References:

http://www.sciencequest.org/support/computers/mac/repair_topics/application_specific/osx/swapswapvm.html

http://www.macosxhints.com/article.php?story=20031104150206554

http://www.math.columbia.edu/~bayer/OSX/swapfile.html

http://discussions.info.apple.com/WebX?128@143.yzG8aPqmqaH.2@.599ea35e

http://www.macosxhints.com/article.php?story=20031103155828117

[ Reply to This | # ]
Swap Relocator seems to work fine with Panther after a forced reboot
Authored by: tom stratton on Jul 31, '04 01:14:02AM

I was looking at this hint and thinking that someone had to have done the work for me.

didn't find that, but there was a program called swap relocator that advertised itself as a startup item.

I installed it and it ran a terminal script.

I restarted and ran the "ps -auxww | grep dynamic_pager"

All was sell


Forced Reboot - TWICE

Still comes up Roses...

Good Luck!



[ Reply to This | # ]