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

Prevent CD and DVD disks from becoming stuck System
There has been written a lot about one issue: CDs an DVDs have a tendency to get stuck in the drive at times. Most hints suggest a reboot for remedy. This was unacceptable to me.

After some research, I discovered that the disks only get stuck when the 'Put the disk(s) to sleep when possible' option is activated in the Energy Saver settings. There is only one setting for all drives, so if you actually want your external disks to sleep, you are "stuck." But what if you could you prevent your Superdrive from sleeping, and still have all other disks take their nap?

The solution: Employ /usr/bin/drutil via launchd. You will only need TextEdit and Terminal do the job, but you can use Lingon if you'd rather not use the command line.

Here's how to do it. Just paste the following code in a text editor, and save it as plain text to your user's Library -> LaunchAgents directory (create it if necessary). Name it com.lucdesign.drivesleepfixer.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.lucdesign.drivesleepfixer.plist</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/bin/drutil</string>
    <string>list</string>
    <string>></string>
    <string>nil:</string>
  </array>
  <key>RunAtLoad</key>
  <false/>
  <key>StartInterval</key>
  <integer>540</integer>
</dict>
</plist>

This code works like this: Every nine minutes (540 seconds), a UserAgent will look for available optical drives. This will wake up the drive and restart the sleep timer, which is set to ten minutes by default.

To activate the agent, in the Terminal type this command:
launchctl load ~/Library/LaunchAgents/com.lucdesign.drivesleepfixer.plist
Alternatively, using Lingon, create a new UserAgent and paste the code in its Expert window. You can save and load your agent from here with the click of a button.

Farewell, stuck disks!

[robg adds: I haven't tested this one...]
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[14,409 views]  

Prevent CD and DVD disks from becoming stuck | 14 comments | Create New Account
Click here to return to the 'Prevent CD and DVD disks from becoming stuck' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
which models?
Authored by: taran on Dec 14, '05 08:36:03AM

Which models is this happening on? I've never experienced this problem.



[ Reply to This | # ]
which models?
Authored by: perturb on Dec 14, '05 07:52:23PM

Well, this happens on my (don't laugh) 1999 "Yikes" PowerMac G4 with the optical drive upgraded to a Pioneer DVR-10x ...



[ Reply to This | # ]
which models?
Authored by: AquaX on Dec 15, '05 12:00:54PM

I have a Mirrored Drive Doors G4 upgraded with a Pioneer DVR-108 (from the stock 2x DVR-103), and I suffer from this problem.

Unfortunately, being away for the holidays means I won't be able to test this until I get home after New Year.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: jdb8167 on Dec 14, '05 09:29:20AM

It happens on my mini with an upgraded PIONEER DVD-RW DVR-K05. The latest System Profiler shows this drive as "Apple Shipped/Supported" but if Apple put in special ROMs for their shipped version (which they tend to do), mine obviously doesn't have it.

The problem isn't horrible. The drive sleeps and it can take a couple of minutes for the software to time out during which time the CPU is at 100%. Once the timeout happens I can eject this blank DVD-R/CD-R and everything works. But this hint could save me a lot of trouble. So thanks. I will be trying it out soon.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: jdb8167 on Dec 14, '05 09:40:32AM

There are at least two things wrong with this hint.

First there is a typo:
"launchctrl load ~/Library/LaunchAgents/com.lucdesign.drivesleepfixer.plist"

That is wrong and will produce a command not found error. The command line tool is launchctl NOT launchctrl (note the extra 'r'.)

Second, I'm getting an error on the load complaining that the "StartInterval is zero, ignoring" which isn't giving me a lot of confidence either.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: jdb8167 on Dec 14, '05 10:20:59AM

More problems.

The StartInterval is an integer not a real so that key/value pair should be:

  <key>StartInterval</key>
  <integer>60</integer>

Note that this is every minute not every nine minutes as stated in the hint.

The next problem is that the ProgramArguments appear to be wrong. It looks like there is an attempt to redirect stdout to a device called nil:. This is just weird and not Unix. As far as I can tell this just doesn't work.

The way you are supposed to redirect stdout in a launchd.plist is by using another argument:

StandardOutPath <string>

So here is my plist file that appears to be working though I won't really know until I have a chance to use the burner for real:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.lucdesign.drivesleepfixer.plist</string>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/bin/drutil</string>
		<string>list</string>
	</array>
	<key>RunAtLoad</key>
	<false/>
	<key>StandardOutPath</key>
	<string>/dev/null</string>
	<key>StartInterval</key>
	<integer>60</integer>
</dict>
</plist>


[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: robg on Dec 14, '05 02:15:47PM

Thanks for the fixes -- I corrected the typo and fixed the real/integer bit in the script (as well as set 540 seconds).

-rob.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: jdb8167 on Dec 14, '05 04:19:00PM

The other important thing to fix is the ProgramArguments. Remove the last two entries in the array then add a new child off the root element:

<key>StandardOutPath</key>
<string>/dev/null</string>

The version of the script in the hint doesn't work. What happens is launchd complains and eventually disables the script.

The altered script works. I've tested it most of the day and it keeps the drive active.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: masterluc on Dec 15, '05 03:59:35AM

thanks jdb8167, your enhancements and corrections are very welcome!
ppl, pls use his version instead of mine, maybe with the 540 secs interval if you like.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: sighup9 on Jan 21, '06 07:00:41AM

Thanks for posting the corrected version... it works as advertised on my G4 733 DI that's been driving me nuts on occasion with stuck CDs and DVDs if I happen to leave them loaded for extended periods of time.

This happened both with the stock SuperDrive and the new DVD+/-RW 16x+|NEC ND-3520A SV drive that I installed a while back (I highly recommend this drive FYI).



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: chellman on Dec 14, '05 12:33:00PM

I changed the <real>60</real> to <integer>60</integer> and was able to load it without errors. The man page says the value should be an integer, so maybe it's ignoring the real, and thinking it's zero.

The thing I don't understand is why the hint says this will run every 540 seconds, when that number doesn't appear anyway in the sample.

Also, launchd isn't happy with the way drutil is exiting, apparently with code 1. So after a few failures, it's removed from the list of items launchd will launch. It did this when I set the StartInterval to 5 just to make sure it was working, but still.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: chellman on Dec 14, '05 12:34:16PM

Sigh. That's what I get for not reloading the page before posting.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: masterluc on Dec 14, '05 03:42:18PM

@ taran: i have a G5 dual 2 Ghz with original superdrive.



[ Reply to This | # ]
Prevent CD and DVD disks from becoming stuck
Authored by: BjarneDM on Jan 09, '06 06:32:46AM

OK - this has hint has really saved from a major PITA :-)

I've got one of the original iMac (Flat Panel) "Tessera, P80" at 800MHz from 2002. Last year, the DVD drive went titsup and had to be replaced. I got the following:

[22:28:16@Volumes]$ drutil info
 Vendor   Product           Rev 
 PIONEER  DVD-RW  DVR-106D  1.08

   Interconnect: ATAPI
   SupportLevel: Apple Shipping
          Cache: 2000k
       CD-Write: -R, -RW, BUFE, CDText, Test, IndexPts, ISRC
      DVD-Write: -R, -RW, +R, +RW, BUFE, Test
     Strategies: CD-TAO, CD-SAO, CD-Raw, DVD-DAO

and so far when it went to sleep with a CD or DVD in the drive, I was unable to eject the tray short of rebooting the whole computer and holding down the eject button at startup.

This hint works perfectly in resolving this issue.

I have, however, the following comments:

Normally, when the tray has been ejected, it's automagically pulled retracted again after the infamous 10 minutes. When this hint is implemented, this is no longer the case: once ejected it stays ejected, and has to be manually closed again.

As to launchd and where it's loading stuff from, man launchctl provides the following information:

FILES
     ~/Library/LaunchAgents         Per-user agents provided by the user.
     /Library/LaunchAgents          Per-user agents provided by the administrator.
     /Library/LaunchDaemons         System wide daemons provided by the administrator.
     /System/Library/LaunchAgents   Mac OS X Per-user agents.
     /System/Library/LaunchDaemons  Mac OS X System wide daemons.

We'll keep our dirty hands way off the last two. But the first three are interesting. Provided where you place the file, launchd treats it a somewhat differently:

~/Library/LaunchAgents
If you store the plist here, the plist is only active when the user whose home directory it's in is logged in. It seems to be completely inactive otherwise, so if another user logs in (s)he can still have the problem.

/Library/LaunchAgents
The plist is loaded for every user that logs in. If more than one user is logged in, an instance is running for each and every user. And furthermore, it's not unloaded when the user logs out, so depending on how many accounts you have, you can have a lot of instances running. And it's also one hell of a job getting rid of it again. It's not enough to stop and unload it using the sysadmin/root launchctl; that seems to have no effect at all on running account specific launchd daemons. And, for users that are already logged in, the plist isn't started. To get rid of the phantom user launchd processes I had to kill the user launchd process itself.
Take a look at the following:

[00:34:16@LaunchDaemons]$ ps -aux | grep drutil
tina    13490  13.0  0.4    30968   4092  ??  Ss   12:30AM   0:33.76 /usr/bin/drutil list
maria   13503  12.6  0.4    30968   4096  ??  Ss   12:34AM   0:04.22 /usr/bin/drutil list
bjarne  13505   0.0  0.0    27904    356  p3  U+   12:35AM   0:00.00 grep drutil
[00:35:05@LaunchDaemons]$ ps -aux -U tina
USER   PID %CPU %MEM      VSZ    RSS  TT  STAT STARTED      TIME COMMAND
tina 13490  13.2  0.4    30968   4092  ??  Ss   12:30AM   0:40.84 /usr/bin/drutil list
tina  3413   0.0  0.2    27956   2272  ??  S    Wed12PM   0:04.09 aped
tina  9278   0.0  0.0    27316    504  ??  S    Sat05PM   0:01.30 /sbin/launchd
[00:35:57@LaunchDaemons]$ sudo kill 9278 3413 13490
kill: 13490: No such process
[00:36:36@LaunchDaemons]$ ps -aux | grep drutil
maria   13503  25.0  0.4    30968   4092  ??  Ss   12:34AM   0:19.08 /usr/bin/drutil list
bjarne  13509   0.0  0.0    18060    304  p3  R+   12:36AM   0:00.01 grep drutil
[00:36:48@LaunchDaemons]$ sudo kill 13503
[00:37:21@LaunchDaemons]$ ps -aux | grep drutil
maria   13514  24.6  0.4    30968   4096  ??  Ss   12:37AM   0:01.40 /usr/bin/drutil list
bjarne  13516   0.0  0.0    18060    324  p3  R+   12:37AM   0:00.01 grep drutil
[00:37:38@LaunchDaemons]$ sudo kill 11340
[00:38:08@LaunchDaemons]$ ps -aux | grep drutil
bjarne  13519   0.0  0.0    18060    324  p3  R+   12:38AM   0:00.01 grep drutil

Of these users, only bjarne and maria had active sessions, while tina had been logged out. The plist had been created and loaded into launchd with only bjarne logged in. As you can see, bjarne doesn't get the process while both tina and maria get it. And furthermore, even though tina has subsequently logged out, she's still got the process running. You can also see that even after having unloaded the plist, the maria launchd still re-starts the process.

/Library/LaunchDaemons
This is in my opinion the best place to place a plist like this one. It's only run by the system and is independent on whether and how many users have logged in.

As to the load/unload issue with active/inactive account there might be a plist parameter that fixes this, but I don't know enough about launchd to be able to provide a solution.



[ Reply to This | # ]