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

Click here to return to the 'How to put swap on a different drive in Panther' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
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).



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

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

if [ -d ${newswap}/.Trashes ]; then
	ConsoleMessage "Using ${newswap} for swapfile"
	if [ -f ${oldswapdir}/swapfile0 ]; then
		rm -rf ${oldswapdir}/swap*
    echo "Removing old swapfiles from ${oldswapdir}"
	ConsoleMessage "Unable to use ${newswap} for swapfile"
#------------------------------------- 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.


[ Reply to This | # ]