Categories
Mac Tech

Sleep Bug with Dell Mini 9

Found a new issue with the Dell Mini 9 Hackintosh that took a little bit of time to fix. If I have a USB drive mounted when the system goes into sleep mode – basically when I close the lid of the machine. When the machine comes back on, I get an error message saying that the USB drive has been removed incorrectly and that there maybe some data corruption.

dellmini9.pngFound a new issue with the Dell Mini 9 Hackintosh that took a little bit of time to fix. If I have a USB drive mounted when the system goes into sleep mode – basically when I close the lid of the machine. When the machine comes back on, I get an error message saying that the USB drive has been removed incorrectly and that there maybe some data corruption.

To solve this, I needed a way to disconnect all the USB drives before the machine went to sleep. After some looking around the internet, I’ve seen some interesting Applescript scripts that could unmount all USB drives. Now that the hard part was done, i needed to find a way to automate this process. The solution: Quicksilver.

After trying a number of scripts that just didn’t do the job, I had to resort to actually looking at Applescript code to see if I could troubleshoot why the unmounting of the drives wasn’t always working. I know very little about Applescript so it took a bit longer than I wanted, but what the hay, it actually forced me to read the Help file. The funny thing is that the Help file had the routine that did what I wanted. It was actually half the size of the ones I found on the internet.

In any event, to solve the issue, I modified an existing Quicksilver plugin, the Extra Scripts plugin. The plugin is located in the ~/Library/Application Support/Quicksilver/Plugins. Within that package, there is a Sleep script located in the Contents/Resources/ExtraScripts/System folder. Open the file in Script Editor and the file will contained the following line:

tell application “System Events” to sleep

Here is the modified code with the lines from the Help file:

tell the application “Finder”

eject (every disk whose ejectable is true)

end tell

tell application “System Events” to sleep

You’ll notice that the bit of new code only ejects disks that can be ejected – this does not include network shares, but does include any CD-ROMs/DVDs. Fortunately on the netbook, I don’t have a DVD drive. Now, instead of just closing the lid of the machine to go into sleep mode, I fire up Quicksilver and execute the Sleep script. Works every time.

Also, as a side note, if I were to leave the USB drive in the USB slot when the netbook comes back awake, the system will remount the drive automatically. Bonus!

Hope this helps someone else!

-JT

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.