Reviews and Daily News with a  Difference!
Select a Topic Area To See a List of Related Reviews & Articles
Systems  | CPU Upgrades  | SCSI | IDE | Firewire  | Video  | Audio  | Games  | Misc/OS  | Archives  | Search
6/28/01 Thursday's News: Story DetailReturn to News Page

Click for Mini Pro Dual Drive!
Click for Mini Pro Dual Drive!

Notes/Warnings/Tips on Dedicated OS X Swap File Partition and /etc/fstab:
Published: 6/28/2001
Last Update: 9/25/2002 (for Jaguar/10.2 info)

Swap Cop Swapfile Utility: I've not used it personally, but there's a freeware utility for moving/changing the swapfile location available at http://homepage.mac.com/jschrier/.
** Note ** as of version 1.1.2 it's not designed to work for OS X 10.2, but the author says you can request that by making a donation on his wishlist page.

OS X 10.2/Jaguar Update: A reader sent a note that the summer 2001 info (using 10.0.x) does not work for Jaguar/10.2. Here's his info on using a swap partition with Jaguar:

" I have created a mod to the jaguar /etc/rc that works perfectly and would be happy to share it. The following change has been tested. It requires the creation of a swap partition and the creation of the appropriate directory inside that partition: e.g.
mkdir /Volumes/Swap/.vm

The following is a much safer version of the changes to the rc file since it allows for netbooting and the possibility that the Swap partition does not mount

# Start the virtual memory system.

ConsoleMessage "Starting virtual memory"
#Set swapdir for a netboot situation only

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

## Autodiskmount version of setting up swap, copied from
## /System/Library/StartupItems/Disks/Disks

     if [ ! -f /var/db/volinfo.database ]; then 
Uninitialized_VSDB=-YES-; fi

     ConsoleMessage "Checking disks"
     /sbin/autodiskmount -va

     if [ "${Uninitialized_VSDB:=-NO-}" = "-YES-" ]; then vsdbutil -i; fi

     ConsoleMessage "Setting up Swap"

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

dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F 

Mike McNeil "

I have not tested the above personally. (I no longer run a separate swap partion in OS X. I personally didn't see any real benefit of it with my Macs that have 512MB to 1GB of installed ram.)

(NOTE: This article was first posted in dated summer 2001 -The info below was used with 10.0.x., not the August 2002 released Jaguar (10.2.x) version.)

Custom MacOS Startup Item for Swapfile: (Also see the notes/warnings originally posted farther down back in June.)

" I know that this is topic is a little old, but I have only just got OS X. I read with interest at the time the thoughts on a separate swap partition. I did this, but used a custom Mac OS X StartupItem. My instructions follow:

Firstly create a partition (HFS+ or UFS) and call it "swap". Mine was 1GB. Open up a Terminal and enter the following:

    sudo mkdir /Volumes/swap/.vm

.vm will then be invisible to the OS X Finder.

Now get the file "swap.tar.gz". This contains the StartupItem "VirtualMemory" (a folder) and a replacement rc file. This rc file is identical to the default Mac OS X file, except the commands for VM have been commented out.

Back up your original rc file:

    sudo cp /etc/rc /etc/rc.old

Now decompress the archive, and move the files to the proper places:

    gunzip swap.tar.gz
    tar -xvf swap.tar
    cd swap
    sudo cp -r VirtualMemory /System/Library/StartupItems
    sudo cp rc /etc/rc

Now when you reboot, the swapfile will be created on the swap volume in the hidden .vm directory. To conserve disk space you can then remove the old swapfiles:

    sudo rm -rf /private/var/vm/swap*

Note on the boot sequence, a new startup message "Initializing Swapfile" will appear briefly after "Checking Disks"

If anything goes wrong, you can always remove the VirtualMemory StartupItem and restore the rc file:

    sudo rm -rf /System/Library/StartupItems/VirtualMemory
    sudo mv /etc/rc.old /etc/rc

Finally, as a request for help, my foreign language skills do not stretch to properly localizing the StartupItem. If anyone could contribute with translations of "Initializing Swapfile" to their local tongue I would be grateful.
Roland Burton "

Note: On 7/26/2001 I tried the above on with a 100GB drive upgrade in a G4/450 Cube (3 partitions, one for the swap (first partiton), one for OS X and one for OS 9. I saw only a 84MB swap file created (visible in OS 9.1 on the swap partition) but apparently this is normal. See this page on OS X Swap File sizes for more info and links to other info on OS X virtual memory.

(Original 6/28/2001 info follows)
Yesterday's news had a reader report on improved performance with a dedicated swap file partition in OS X. Two readers replied to that post with a note about an issue to be aware of based on a post in the darwin mail list. One reader also noted a workaround to address this issue.

" I found this message by Peter Bierman.
I'm not postitive that it is the same on OSX as on Darwin but it seems likely. In short if you do the swap disk (like I have on my PBG4, prevents swap fragmenting) using fstab and the disk respond in a different order it can really screw things up. Regards

------ Forwarded Message
From: Peter Bierman <bierman@apple.com>
Date: Wed, 27 Jun 2001 00:00:46 -0700
To: darwinos-users@lists.apple.com
Subject: warning: /etc/fstab doesn't do what you think

I've seen a bunch of messages here lately that describe using /etc/fstab to mount volumes at boot.

You don't want to use /etc/fstab on darwin.

Drives are detected and mounted asychronously, which means that the same physical disk might be assigned a different /dev/diskN node depending on how quickly other devices respond to bus probing.

Put simply, /dev/disk2s5 for example, might not be the same partition two boots in a row. It usually will be, but isn't required to be.

If you want to put your VM files on a dedicated partition, reorder the startup items dependencies so that VM is started after volumes are mounted. Have VM specify the swapfiles by the full path /Volumes/somedisk/somewhere.

Or use the fstab, and hope that the drives always respond to bus probes in the same order.
darwinos-users mailing list
------ End of Forwarded Message "

Eugene Chan also sent a warning about this issue and a workaround:

" I think it's important to note some issues with the particular method you referenced on your website:

1) Darwin/Mac OS X tries not to use fstab, so adding and fstab file just adds more complexity to the subsystem.

2) The device location is usually static, but *not always* . Since the /etc/fstab file binds a device location to a mount point, this is not a good idea. A disk at /dev/disk0sXX could be located at /dev/disk0sYY the next time you boot.

Here's where I got the warning from:
[He noted the same post from Peter Bierman as noted above so I didn't repeat it here-Mike]

For a workaround, I have a method that is just as easy if not easier.

1) Back-up your /etc/rc file, because that is the file that we will be editing.
2) As root, open /etc/rc in a text editor and find the section that begins with:

# Start the virtual memory system.

ConsoleMessage "Starting virtual memory"


3) Because OS X/Darwin normally mounts other disks *after* setting up swap, you must open /System/Library/StartupItems/Disks/Disks in a text editor and copy/paste the following lines to /etc/rc just before the section shown above:

# Mount any remaining filesystems

if [ ! -f /var/db/volinfo.database ]; then Uninitialized_VSDB=-YES-; fi

if [ "${AUTODISKMOUNT:=-YES-}" != "-NO-" ]; then

    ConsoleMessage "Mounting media" 

    case ${AUTODISKMOUNT} in 

        autodiskmountflags="-a" ;; # Mount removeable media 
        autodiskmountflags="" ;; 

    autodiskmount -v ${autodiskmountflags} 

if [ "${Uninitialized_VSDB:=-NO-}" = "-YES-" ]; then vsdbutil -i; fi 

4) Now change the line 'swapdir=/private/var/vm' to the desired drive location...It should begin with /Volumes/. I've placed mine in /Volumes/harp/DO_NOT_TOUCH/.vm ... harp is the name of the volume. The directory DO_NOT_TOUCH is a visible warning, and the directory that will actually contain the swapfiles is invisible to the Finder because it has a "." in front of it.

I hope that makes sense...And don't get rid of the
/System/Library/StartupItems/Disks/ because other start-up items are dependent on it. Alternatively, you could probably create an OS X style StartupItem for starting up swap, but I'd rather have my swap ready earlier in the boot process.
Eugene Chan "

Return to Main News Page

Click for Wireless Networking Upgrades!

(Ad/Sale items)

= UPGRADES by Mac =
Upgrades just for

= Used Macs =
(Click for List)

SSDs from under $50!
Fast SSDs for Most Macs/PCs

= ThunderBolt =
Drives & More

Up to 6 TB HDs!
Hitachi, WD, Seagate, Samsung HDs

= 2.5in HDs & SSDs =
Notebook Hard Drives and DIY drive/case kit bundles

Lifetime warranty RAM Upgrades!

Internal and External Superdrives/Blu-Ray drives

Graphics cards, TV tuners, DVR, adapters and more.

Apps, Utilities, OS, VM, Games and more

WiFi and Bluetooth Devices/Adapters/More

= Repair Service =
for iPhone, iPad, Macs

= iPad/iPhone/iPod =
Accessories, Cases, Repairs & More

NuGuard iPhone Case *Extreme* Drop Tested!

XLR8YourMac T-Shirts


Help Fight Hunger

= back to www.XLR8YOURMAC.com =

= Other Site Topic Areas =
Mac Mods/Upgrades | CPU Upgrades | Storage | Video | Audio/HT | Misc/Software | Search | Recent

Copyright © , 1997-2014. All Rights Reserved
All brand or product names mentioned are properties of their respective companies.

Legal: Site Privacy and terms/conditions of use.