I’ve managed to move the swapfile - the virtual memory (VM) file - of my new Mac OS X 10.4 “Tiger” installation onto another drive. I’ve done this for several reasons.
I have lots of RAM in my new Blue& White G3 Powermac - I’ve transplanted the 768M from my old Beige machine, a generous gift from
autopope and
feorag - but I currently don’t have that much disk space, only 2 x 8.5G UltraSCSI disks. Classic is on disk #0 and OS X on #1.
I wanted to move the VM from the OS X boot drive onto the other disk (#0) partly because I wanted the space back and disk 0 is underused, partly because it might stop disk 0 going to sleep all the time and partly because having VM on a separate physical drive is good for performance on all operating systems that use VM.
I used to use SwapCop to do this but it carries warnings about not being supported on 10.3 - I don’t want to risk it any more. Its author, J Schrier, gave his code to the SwapswapVM team, who haven’t updated in 2.5yr.
SwapCop:
http://homepage.mac.com/jschrier/
SwapSwapVM:
http://www.sciencequest.org/support/computers/mac/repair_topics/application_specific/osx/swapswapvm.html
How to do it
I tried the technique detailed at
Before you continue with the technique I detail, study Prof. Bayer's page closely and make sure that you understand it and its ramifications. I have not duplicated all the information from there here!
Mine is a crude hack which I do not really recommend and for which I make no guarantees whatsoever. However, if you are keen or desperate, it might work for you, and it might provide the basis for someone else to produce a more elegant and fail-safe method.
Omitting several false starts and silly mistakes, here’s what I did.
As per the webpage, I repartitioned and created a dedicated swap partition of size 2 x physical RAM (1.5GB in my case) in unjournalled HFS+ format, ensuring that it had no spaces in the volume name. Like the example given, mine is called “Swap” and so mounts at:
The volume called Swap in my example is the 5th line in the table. It's mounted at /Volumes/Swap and its name, from the first column, is /dev/disk0s12. Make a note of your exact disk name and insert it exactly as it was shown.
Stage 0 - preparations
As Prof. Bayer’s webpage warns, you should know how to boot your Mac in verbose mode and into single-user mode and get out of it again. I also recommend:
• enabling the root user (Google for details, this is trivially easy);
• disabling auto-login (System Preferences | Accounts);
• knowing how to log in to the console, minus Quartz/Aqua (at the login box, click “Other” then enter a login name of
• knowing how to cleanly reboot from the console (hint: “shutdown -r now”)
These last 2 measures saved me a lot of time!
Stage 1
Open Terminal and su to root. I’ve shown the prompts here; in future I’ll just show what you type.
Stage 2
Back up the existing /etc/rc script in case of disaster:
Stage 3
Edit rc - I used vi but Unix novices might prefer pico.
Stage 4
Look for the line that reads:
I changed the swapdir variable to point to my planned drive/directory and inserted a line explicitly mounting that drive on its desired mountpoint. Replace my diskname with the name of your swap volume.
[1] I have used a folder named .vm as this hides it from the Finder. Prefixing a filename with a dot is the Unix way to mark a hidden system file.
[2] I found that it was necessary to explicitly state the format of the disk with the -t switch; OS X mount does not, it seems, auto-detect the disk format and I presume that it is defaulting to its native UFS format.
Also, I left the app_profile file where it was, but inserted some lines at the end of the VM initialisation section to display a message telling me where it was swapping:
One reboot later and all seems to be working. The default size of the file is only 64MB but that is enough to tell me it’s working, as is the fact that I was able to delete the original one from the default VM folder:
However, with 768M RAM, it’s not actually *using* any swap, so the drive still keeps going to sleep...
Comments, additions, addenda etc. are welcome and encouraged.
EDIT: "pico vi" corrected to "pico rc". Oops! [Blush]
I have lots of RAM in my new Blue& White G3 Powermac - I’ve transplanted the 768M from my old Beige machine, a generous gift from
I wanted to move the VM from the OS X boot drive onto the other disk (#0) partly because I wanted the space back and disk 0 is underused, partly because it might stop disk 0 going to sleep all the time and partly because having VM on a separate physical drive is good for performance on all operating systems that use VM.
I used to use SwapCop to do this but it carries warnings about not being supported on 10.3 - I don’t want to risk it any more. Its author, J Schrier, gave his code to the SwapswapVM team, who haven’t updated in 2.5yr.
SwapCop:
http://homepage.mac.com/jschrier/
SwapSwapVM:
http://www.sciencequest.org/support/computers/mac/repair_topics/application_specific/osx/swapswapvm.html
How to do it
I tried the technique detailed at
http://www.math.columbia.edu/~bayer/OSX/swapfile/... But as per its warning, it does not work with 10.4. However, it emboldened me to try hacking directly on /etc/rc and I appear to have triumphed.
Before you continue with the technique I detail, study Prof. Bayer's page closely and make sure that you understand it and its ramifications. I have not duplicated all the information from there here!
Mine is a crude hack which I do not really recommend and for which I make no guarantees whatsoever. However, if you are keen or desperate, it might work for you, and it might provide the basis for someone else to produce a more elegant and fail-safe method.
Omitting several false starts and silly mistakes, here’s what I did.
As per the webpage, I repartitioned and created a dedicated swap partition of size 2 x physical RAM (1.5GB in my case) in unjournalled HFS+ format, ensuring that it had no spaces in the volume name. Like the example given, mine is called “Swap” and so mounts at:
/Volumes/SwapYou need to know the disk name of your VM partition. Open a Terminal and type:
df -hYou should see something a little like this:
Filesystem Size Used Avail Capacity Mounted on /dev/disk1s5 8.5G 2.6G 5.8G 31% / devfs 104K 104K 0B 100% /dev fdesc 1.0K 1.0K 0B 100% /dev <volfs> 512K 512K 0B 100% /.vol /dev/disk0s12 1.4G 72M 1.3G 5% /Volumes/Swap automount -nsl [126] 0B 0B 0B 100% /Network automount -fstab [132] 0B 0B 0B 100% /automount/Servers automount -static [132] 0B 0B 0B 100% /automount/static /dev/disk0s10 6.9G 1.0G 5.9G 15% /Volumes/MacOS 9 7GB
The volume called Swap in my example is the 5th line in the table. It's mounted at /Volumes/Swap and its name, from the first column, is /dev/disk0s12. Make a note of your exact disk name and insert it exactly as it was shown.
Stage 0 - preparations
As Prof. Bayer’s webpage warns, you should know how to boot your Mac in verbose mode and into single-user mode and get out of it again. I also recommend:
• enabling the root user (Google for details, this is trivially easy);
• disabling auto-login (System Preferences | Accounts);
• knowing how to log in to the console, minus Quartz/Aqua (at the login box, click “Other” then enter a login name of
>console... and OS X drops into text mode and asks you to authenticate the old-fashioned way, with a login prompt);
• knowing how to cleanly reboot from the console (hint: “shutdown -r now”)
These last 2 measures saved me a lot of time!
Stage 1
Open Terminal and su to root. I’ve shown the prompts here; in future I’ll just show what you type.
machinename:~ username$ su
Password: [type root password]
machinename:/Users/username root#
Stage 2
Back up the existing /etc/rc script in case of disaster:
cd /etc
cp rc rc.bak
Stage 3
Edit rc - I used vi but Unix novices might prefer pico.
vi rcor
pico rc
Stage 4
Look for the line that reads:
echo “Starting virtual memory”Back up any lines you change by copying the original unchanged lines and inserting a # mark in front of them to comment them out. Also put in comments - starting with a # - detailing what you did. One day, you might not remember!
I changed the swapdir variable to point to my planned drive/directory and inserted a line explicitly mounting that drive on its desired mountpoint. Replace my diskname with the name of your swap volume.
# following lines LGHP 10-Dec-2005Notes:
swapdir=/Volumes/Swap/.vm
mount -t hfs /dev/disk0s12 /Volumes/Swap
# swapdir=/private/var/vm
[1] I have used a folder named .vm as this hides it from the Finder. Prefixing a filename with a dot is the Unix way to mark a hidden system file.
[2] I found that it was necessary to explicitly state the format of the disk with the -t switch; OS X mount does not, it seems, auto-detect the disk format and I presume that it is defaulting to its native UFS format.
Also, I left the app_profile file where it was, but inserted some lines at the end of the VM initialisation section to display a message telling me where it was swapping:
# following lines LGHP 10-Dec-2005
echo “Swapping onto:”
echo ${swapdir}
# end insertion
appprofiledir=/private/var/vm/app_profile
One reboot later and all seems to be working. The default size of the file is only 64MB but that is enough to tell me it’s working, as is the fact that I was able to delete the original one from the default VM folder:
/private/var/vm
However, with 768M RAM, it’s not actually *using* any swap, so the drive still keeps going to sleep...
Comments, additions, addenda etc. are welcome and encouraged.
EDIT: "pico vi" corrected to "pico rc". Oops! [Blush]