Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm attempting to create a RAM disk that loads the previous contents when the system starts up, and every six hours writes the contents to a disk image. Currently, when you run the script from the terminal ("sudo bash LogToRAM.sh") everything works fine. But when run from launchd during startup, it doesn't work.

Here's the lines from the log; the first line just gives some idea as to where in the boot process we are:


SecurityAgent[202] Showing Login Window 
com.mechcozmo.LogToRAM[51] + /Developer/usr/bin/SetFile -a V /Volumes/LogfileRAMdisk 
com.mechcozmo.LogToRAM[51] ERROR: File Not Found. (-43)  on file: /Volumes/LogfileRAMdisk  
com.mechcozmo.LogToRAM[51] + /usr/sbin/asr -source '/Library/Application Support/LogToRAM/RAMdisk_store.dmg' -target /Volumes/LogfileRAMdisk/ -noverify

Here is the script and plist file in question.

Note that 'set -vx' is up at the top of the script; it give a lot of information about what is happening in the script. My current theory is that the /Volumes directory does not exist at this stage of the boot process, but that seems unlikely to be honest.

share|improve this question
    
I'm not able to reach the specified host in the link to the script and plist file. Would you mind confirming that the link is right and the site is up? –  Clinton Blackmore Mar 2 '10 at 21:28

3 Answers 3

You know - that is right. I've tried mounting a volume over afp - and it won't work until you log in. Though I bet you could easily verify this with "does vol exist?" (I forget what that is in shell).

share|improve this answer

To confirm if the volumes exist or not when the script gets run, which does seem the most likely cause of those errors, add lines to the top to output the list of currently active volumes to a file in /tmp or /var/log.

When are these volumes usually created/mounted?
Also, when is your script run? From /etc/rc.local? From a command in /etc/rc*.d?

Some guesses without knowing your boot sequence:

  • If the volumes are usually created as you login then they will not exist on startup. You will need to change this or also run your cache-to-RAM script on login also.
  • If the volumes are created in the startup (pre-login) process, then you may simply need to adjust the order that your boot scripts are run.
  • If they are volumes that for whatever reason take a while to mount, and they are being mounted asynchronously, you script may need to be altered to have a scan-and-wait loop at the beginning so it waits until they are present.
share|improve this answer
    
The script is run from launchd, PID 1 on Macs 10.4 and up. See <a href="developer.apple.com/MacOsX/launchd.html">Apple's site</a> for more details. I'll try out some of the other suggestions and report back what happens. –  Mechcozmo Jul 30 '09 at 0:29

What happened when you try with a Login Hook (use the first method and don't forget the sudo) ? Does it work ?

The Login Hook is loaded later, so more features should be accessible.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.