Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Old 08-27-2002, 08:01 PM   #1
9KILLER
Triple-A Player
 
Join Date: Aug 2002
Location: Yellville, AR
Posts: 52
need help Moving swap file under 10.2

I only have a 450MHz G4 Sawtooth at work, so I need every performance edge I can get. I enjoyed being able to move my swap files off the boot drive (IDE) to a separate disk (SCSI) in 10.1.x, but can't seem to get it to work in 10.2 - does anybody have any info on this?

I suspect the issue lies with the system looking for the swap directory before it actually mounts the SCSI or Firewire drive, but since I don't have a second IDE drive in that box, I can't test it.

Currently, when I modify fstab and rc to mount and use /Volumes/swap (for example) I end up with a folder called swap that contains the swap files, but is actually on the boot drive. And the "swap" volume is mounted as "swap 1" in /Volumes.

Under 10.1.x, this would happen after a warm reboot, but could be remedied by totally shutting down and doing a cold restart. But that doesn't work, anymore.

This isn't a critical issue under Jag since it's so much faster, but I run a lot of big-gun graphics and development tools at the same time, and have already had a couple of incidents where my disk was thrashing and slowing me down, temporarily.

Any insights into this will be greatly appreciated.
9KILLER is offline   Reply With Quote
Old 08-29-2002, 10:51 PM   #2
WillyT
Major Leaguer
 
Join Date: Jan 2002
Location: Midwest Not quite Normal
Posts: 416
Jaguar Local filesystem seems to be early in rc?

hmmm...

I added swapdir=/Volumes/SWAP/vm to rc but it didn't seem to take?

Mount local filesystems is early in rc so this should work.

I had to move it ahead of swapdir line in 10.1.

Will investigate further.

Willy
WillyT is offline   Reply With Quote
Old 08-29-2002, 11:23 PM   #3
9KILLER
Triple-A Player
 
Join Date: Aug 2002
Location: Yellville, AR
Posts: 52
I've been fiddling with it off and on, and I think it has to do with the fact that fstab no longer works. So when rc tries to put the swap file on /Volumes/swap, there isn't a drive there, so it ends up making a "swap" directory, and putting a "vm" directory in it, and putting the swapfile there. And all of this is actually on the boot drive.

Since there already is a /Volumes/swap in existence, when it's time to mount the disk, the OS adds the real swap drive as /Volumes/swap 1

The trick is to get the drive mounted before rc lays down the swapfile to disk. The only way I knew to do this, before, was with fstab.

What's the new way? Is it something in NetInfo?
9KILLER is offline   Reply With Quote
Old 08-30-2002, 12:14 AM   #4
petey
All Star
 
Join Date: Feb 2002
Location: peteyville
Posts: 794
you need an explicit mount call

here's the code in my rc file. obviously, you need to change the volume location as to where the disk or partition is on your machine (it's 'disk0s9' on mine.)

it works for me under 10.2

---

ConsoleMessage "Starting virtual memory"

mount -t hfs /dev/disk0s9 /Volumes/Swap
swapdir=/Volumes/Swap/vm
petey is offline   Reply With Quote
Old 08-30-2002, 08:27 PM   #5
9KILLER
Triple-A Player
 
Join Date: Aug 2002
Location: Yellville, AR
Posts: 52
Is that the only change you made? Adding the "mount" line in rc?

It's still not working for me. I wonder if it's because I don't have a second IDE drive or volume. Just a SCSI drive (on a PCI card) and an external FireWire Drive. I've been able to move swap files to these under 10.0.x and 10.1.x, but not now, for some reason. Still the same symptoms.

Maybe I need to get a small IDE drive for a swap drive.
9KILLER is offline   Reply With Quote
Old 08-31-2002, 12:29 AM   #6
WillyT
Major Leaguer
 
Join Date: Jan 2002
Location: Midwest Not quite Normal
Posts: 416
Talking Works for me

petey

thanks,
I'm seeing the mount local file systems things crash with a bus error but its scrolling by too fast to catch it all.

Nice to have swap partition working again, even tho the new spinning lolipop looks pretty, I still don't want to see it.

Willy
WillyT is offline   Reply With Quote
Old 08-31-2002, 01:08 PM   #7
jasonxz
Triple-A Player
 
Join Date: Feb 2002
Location: Foster City, CA
Posts: 63
Sawp Cop?

Does Swap Cop not work under Jag? The developer's site doesn't say, unfortunately.
jasonxz is offline   Reply With Quote
Old 08-31-2002, 01:20 PM   #8
9KILLER
Triple-A Player
 
Join Date: Aug 2002
Location: Yellville, AR
Posts: 52
I tried swap cop, too, but it's the same story.

I'll just try to find a spare IDE drive when I get back to the office, Tues., and see if I can get it to work with that.
9KILLER is offline   Reply With Quote
Old 09-05-2002, 11:01 AM   #9
spnyc
Prospect
 
Join Date: Jan 2002
Location: new york city
Posts: 1
Petey had the answer

i was having the same dirty double mounting problem until i commented out the "/dev/disk0s9 /Volumes/swap hfs rw 1 2" line in my fstab file. that combined with petey's explicit mount solution, a reboot and all was good

you can check by opening the terminal and typing:
ps -ax | grep dynamic_pager

if all went well it should point to your swap partition
spnyc is offline   Reply With Quote
Old 09-27-2002, 04:47 PM   #10
skinlayers
Prospect
 
Join Date: Jan 2002
Posts: 4
Question new fstab format

Interesting...

It looks like fstab is still used, it just had a different format of
LABEL=Partition_Name /Mount_Point hfs rw 1 2

where Partition_Name is the name of the parition and Mount_Point is the location to be mounted.

http://www.kung-foo.tv/blog/archives/000193.html

This seems to work for moving the Users folder to a different parition, but I haven't had much luck with it and moving the swap file. I tired

LABEL=Swap /private/var/vm hfs rw 1 2

but that didn't seem to work. The dynamic_pager is running but doesn't list a directory.

Hope this helps with regards to moving the swap file without editing rc.

skinlayers
skinlayers is offline   Reply With Quote
Old 10-31-2002, 12:00 PM   #11
Elvis
Prospect
 
Join Date: Oct 2002
Location: Lymington
Posts: 3
moving swap in Jaguar

I have only just done this but this seems like the easiest way to move your swap file.

Forget about /etc/fstab
Forget about editing the swapdir - leave it at /private/var/vm

further up the rc:-------------------------------------------------------

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

ConsoleMessage "Mounting local filesystems"

mount -t hfs /dev/disk0s9 /private/var/vm

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

--------------------------------------------------------------------------------

obviously my volume to mount is disk 0 slice 9 but this seems to work with a single drive...

... unless someone else knows better!
Elvis is offline   Reply With Quote
Old 10-31-2002, 07:51 PM   #12
9KILLER
Triple-A Player
 
Join Date: Aug 2002
Location: Yellville, AR
Posts: 52
I know how to do it, now.

It's easiest to do this in BBEdit, or some other GUI text editor that will not alter the nature of the file. (Make sure BBEdit is set to save it as a UNIX file, not a mac file.)

Log into the finder as root, then open /etc/rc

move the "Start the virtual memory system" part to the end of the file, after the "start system services" section.

Add a "mount -a" line right before the line that points to your swap file. Then alter that swap file line to point to the new location for your swap file.

Reboot.

Here's the new end of my rc file:

##
# Start System Services
##

# Set language from CDIS.custom - assumes this is parse-able by sh
. /var/log/CDIS.custom
export LANGUAGE

SystemStarter -g ${VerboseFlag} ${SafeBoot}

##
# Start the virtual memory system.
##

ConsoleMessage "Starting virtual memory"
mount -a
#swapdir=/private/var/vm
swapdir=/Volumes/Swap/vm
if [ "${netboot}" = "1" ]; then
sh /etc/rc.netboot setup_vm ${swapdir}
fi

# 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}
else
rm -rf ${swapdir}/swap*
fi

dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F ${swapdir}/swapfile

exit 0
9KILLER is offline   Reply With Quote
Old 11-02-2002, 02:59 PM   #13
EatingPie
Triple-A Player
 
Join Date: Jan 2002
Posts: 63
Another... Better(?)... Answer

Hi.

>> move the "Start the virtual memory system"
>> part to the end of the file, after the "start
>> system services" section.

This solution could be a bit sketchy because some of those system services may need virtual memory! (Note the "may" in that sentence.)

I *believe* the solution is that the external disc needs to be marked clean before its mounted. A plain mount will fail if the disk isn't flagged as clean, hence the (correct) fstab and mount additions not working.

The way I do it is to call Apple's autodiskmount utilitiy which "does all the right stuff" to mount a disk.... Including fsck to mark the disk clean if necessary.

Replace Line 178, which reads...
swapdir=/private/var/vm
with the follwoing:

/sbin/autodiskmount
swapdir=/Volumes/Swap/private/var/vm

This works without an /etc/fstab for me, but I am working with a local disc. You may need to add an entry for your disc (in the new format, as discussed previously).

If this works, I would consider it safer than moving everything below "start system services."

Good luck.

-Pie
EatingPie is offline   Reply With Quote
Old 11-02-2002, 06:18 PM   #14
petey
All Star
 
Join Date: Feb 2002
Location: peteyville
Posts: 794
9killer is correct

moving the "Start the virtual memory system" section to the end of the RC file is a GOOD thing.

---

before i moved the code, using an explicit mount call, the swap would land in the right place about half the restarts.

since moving the VM code to the end of the RC file, it works 100% of the time for me.
petey is offline   Reply With Quote
Old 11-02-2002, 07:51 PM   #15
9KILLER
Triple-A Player
 
Join Date: Aug 2002
Location: Yellville, AR
Posts: 52
yeah, my version is based on a tip I saw on the regular macosxhints site. Do a search for "swap" and you'll see the post in question. The guy who figured it out wasn't 100% sure what he did that got to work, but posted all the things he tried. I simply tested it a bit, and refined it down to the necessary parts.

But, I'm am by no means an expert. I could easily be doing something detrimental, and not be aware of it.
9KILLER is offline   Reply With Quote
Old 11-02-2002, 07:54 PM   #16
EatingPie
Triple-A Player
 
Join Date: Jan 2002
Posts: 63
Danger Will Robinson....!!!

The SystemStarter is used to crank up services that are installed in /System/Library/StartupItems. Many of those things will eventually be swapped... and may
need to be at startup!

Startup swapping will depend on how much is actually fired up by SystemStarter (it's controlled by various Prefs panes and system config files). If, for example, you have a 50GB database started with only 128 megs of RAM... well I'd be throwing money down on a swap occuring early on! I betchya you don't, but there is some cut-off where a swap will occur, even during startup, and it's not very easy to say if/when/where it will happen!

So I want to reiterate that moving the Swap startup below that section in /etc/rc is a risky proposition indeed.

Or maybe a better way to put it is this...

Did Apple/Darwin Developers put the swap code before SystemStartup for a reason?

Now a bit of clarification on the /etc/rc addition I suggested...

Note that in my posted code I am not calling mount, but "autodiskmount", which is sortof a *supermount*. It ultimately performs the same task as mount, but *after* a variety of sanity checks. So that's why autodiskmount works where mount fails.

Whether this will actually work on an external disk... Unfortunately, I can't say because I am dealing with partitions on a local drive for my Swap.

Maybe you can give it a shot. It's certainly no more risky than what you've already done. And I'd certainly like to know if I'm barkin up the wrong tree!

-Pie
EatingPie is offline   Reply With Quote
Old 11-02-2002, 11:09 PM   #17
WillyT
Major Leaguer
 
Join Date: Jan 2002
Location: Midwest Not quite Normal
Posts: 416
I like to see my swapfile

I use an explicit mount for the volume like this:
Code:
# Explicitly mount swap volume
mount -t hfs /dev/disk0s10 /Volumes/SWAP

swapdir=/Volumes/SWAP/vm
if [ "${netboot}" = "1" ]; then
    sh /etc/rc.netboot setup_vm ${swapdir}
fi
I always boot su and fsck_hfs ALL volumes.
After I'm logged in I check the date on the swapfile.

To get a fairly reliable mountpoint you should BEFORE editing /etc/re, reboot about 5 or 6 times and do a df each time and record how your swap partition gets mounted. About one in ten times mine comes up /dev/disk1s10. So if you used the rare occurance to set up the swap it won't work most of the time.
Checking all the volumes at reboot is not much of a problem as the system has been up 10+ days at the moment. Only reboot for installers. Too bad 'shutdown now' is broken.
Willy
WillyT is offline   Reply With Quote
Old 11-06-2002, 06:38 PM   #18
Homer72
Prospect
 
Join Date: Nov 2002
Posts: 1
Thumbs up The combo that works for me.

I found that using the rc file alone with the explicit mount command right before the swapdir = line made it so the df -k showed the /Volumes/swap directory as being swap and not swap 1 and when doing the check mentioned earlier in the posts to see if swap was being used on the right partition it shows up there. I tried the /sbin/auto and found I was getting the swap 1 problem in the Volumes folder. This is in 10.2.

Ignore this post, I check and after a few restarts the swap partition was showing up as swap 1 again :P
__________________
-Brian

Last edited by Homer72; 11-06-2002 at 09:54 PM.
Homer72 is offline   Reply With Quote
Old 11-08-2002, 12:23 AM   #19
petey
All Star
 
Join Date: Feb 2002
Location: peteyville
Posts: 794
this combo should work...

homer72,

exactly. i had the same experience.

from that point, moving the relevant section of the RC file to the end made it work 100% for me.
petey is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 02:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.