Prevent Hard Drive From Sleep Mac App

After recently upgrading my Plex Windows 10 machine, I had an issue where I couldn’t prevent hard drives from going to sleep on that system. After the system restarted, a few hours later I would get an email from Stablebit Scanner indicating that one or more of my drives were no longer connected.

This handy Caffeine app can prevent your Mac from entering sleep mode on demand. An icon in the menu bar will allow you to toggle the setting for those occasional times when you need to computer to run uninterrupted. Click on the cup to toggle Caffeine. Want to prevent your Mac from sleeping even if the lid is closed? You can use this free 'keep-awake' application to prevent Mac from sleeping.

With the exception of the system drive, all other drives connected to the system were USB-connected external hard drives. I couldn’t connect to the drives, and the lights on the drive casing indicated that they were in sleep mode.

I hadn’t experienced anything like this since I setup the system over one year ago. After some investigation I found out that there are actually several settings, in two locations, in Windows 10 that I needed to change in order to prevent the hard drives from going to sleep.

Drive

I detail the steps below.

Mac

Changing the power plan

Mac Os Prevent Sleep

The first setting I had to change was the USB suspend setting in the Windows 10 power options. This does require an administrator to change, but you will be prompted to enter the administrator password if you are logged in as a standard user.

  1. Click Start->Settings->System->Power & Sleep to display the options to change the power and sleep settings.
  2. Click the Additional power settings link under Related power settings. The Power Options window will appear.
  3. From this window, Click the Change plan settings link beside the power plan you wish to change.
  4. From the power plan window, click the Change settings that are currently unavailable link, and enter the administrator password when prompted.
  5. Click the Change advanced power settings link to display all the power options for the plan.
  6. From the power plan window, click the Change settings that are currently unavailable link, and enter the administrator password when prompted.
  7. Expand the USB settings and then the USB selective suspend setting option.
  8. Change the Setting value to Disabled.
  9. Disabling the suspend setting in the Power Options for Windows 10.

USB controller device settings

While I thought changing the USB suspend option would solve my problem, the USB-connected hard drives still were put to sleep by Windows 10. At this point, I decided that there must be another setting that caused this problem. After a bit more research online, I did find something that led me to the setting that solved the issue – disabling the ability for Windows 10 to turn off the device from the USB controller settings.

To make these changes, you can use the following steps:

  1. Click Start and then type computer management. When Computer Management appears in the search results, right-click it and then select Run as administrator.
  2. Enter the administrator password and click the Yes button to open the Computer Management window.
  3. In that window, click Device Manager to display a list of all the devices installed on your system, organized in various categories.
  4. From the list of categories on the right, click the Universal Serial Bus controllers category to display all the devices in that category.
  5. Right-click each item in the list, and the select Properties from the context menu that appears. A properties dialog will appear.
  6. If the properties windows contains a Power management tab, then click that tab. If it doesn’t, then close the window and repeat the previous step for the next device in the list.
  7. In the Power management tab, uncheck the Allow the computer to turn off this device to save power option.
  8. The USB Hub power management properties with turn off device option turned off.

  9. Click the OK button to save the changes.
  10. Repeat steps 5 to 8 for each device under the Universal Serial Bus controllers category.

With these two settings set to prevent hard drives from going to sleep in Window 10, you shouldn’t have an issue with any USB-connected hard drives from being disconnected.


Automatically eject/mount disks on sleep/wake | 15 comments | Create New Account
Click here to return to the 'Automatically eject/mount disks on sleep/wake' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
After having to go around a year booting off an External HD, I've discovered that you don't need to do this with a FireWire HD. In my experience, you can even charge while it's unplugged. As long as you plug it back in before you wake from sleep there's no problem.

For those interested, I was using an iBook G4 1 Ghz. I don't know if that makes a difference though. Also, it doesn't work if you have a USB device plugged in.

Prevent

MacTipper

I haven't had this happen for wake/sleep in ages. Is this a 10.4 issue? Doesn't happen with external drives on my 10.5.2 macbook.

You might also be interested in these related scripts:
http://vocaro.com/trevor/blog/2007/02/11/a-set-of-scripts-to-unmount-drives-before-sleeping/

I have been using SleepWatcher, but I get very sporradic results. I have the following .sleep script in my home dir:
#!/bin/sh
/usr/sbin/diskutil eject /Volumes/Backup
The console shows that the .sleep is being executed, but the drive is not ejected and I get the 'Device Removal' error. If I run it manually, it works fine. I know the script actually runs.
I *think* I remember this working prior to 10.5.2... but I'm not sure. Any ideas?

Prevent Mac Sleep

I'm not seeing this working under OS 10.5.2 either--it's not ejecting my USB flash drive, plugged into a USB hub--I still get the 'Device Removal' error when I wake the Mac from sleep.

App
... you have to manually eject all your devices, otherwise you get that dreaded 'Device Removal' dialog. ... When the machine wakes again, all connected external drives will be reconnected.

Nice work around. But... even though you're using a laptop, should you even be having that problem?

This was happening to me with the new external USB drive which I specifically purchased specifically to use for Time Machine on my new 24 inch iMac. Not only did I have to dismount the drive, I had to turn it OFF. Defeats the whole concept of Time Machine working transparently. I returned the defective drive to be replaced. Problem solved.

I had a similar problem when my iPod mini interfering with waking my PowerMac G4 from sleep. That problem also went away though I can't recall whether it was a bad add-on extension or bad chaining of USB hubs.

---
'Where's my other sock?' - A. Einstein

Hi, now how can I remove all this?

I don't know if it's because I'm running 10.5.2 but this mod works erratically. When I close my laptop's lid, it can take a couple of minutes before it fall asleep and sometimes the (Firewire) HD gets unmounted and sometimes not. Why? So, if I want to remove all those files I must find them:

Where are these files :
The .sleep and .awake script files are on the ~/ folder.
I can use Terminal's rm command to delete these script files

Now, for the Bernhard Baehr's SleepWatcher utility, two installers where used:
The SleepWatcher StartupItem seems to be installed in Library/StartupItem/
But where is the sleepwatcher file ?
Is it in /usr/local/sbin/ ?
Is there other files in other places?

Thanks for your help.

Ooops! I meant '... .wakeup script...'.

From the installer:
SleepWatcher Installer:
This package installs the following files:
/usr/local/sbin/sleepwatcher - the sleepwatcher command
/usr/local/share/man/man8/sleepwatcher.8 - manual page for sleepwatcher
SleepWatcher StartupItem Installer
This package installs the following files:
/Library/StartupItems/SleepWatcher - startup script for the sleepwatcher daemon
/etc/rc.sleep - system wide script executed by the sleepwatcher daemon when the Mac goes to sleep mode
/etc/rc.wakeup - system wide script executed by the sleepwatcher daemon when the Mac wakes up from sleep mode
Delete these files and you should be good to go.

deeply deeply confused by this hint. I've used my powerbook with several externals for years (from 10.3 to 10.5) and I never had to eject the external drives before closing the lid.

Hey, thanks djc0.
Besides, Bernhard Baehr, the SleepWatcher's developer, replied me on this too. Here's his recommendations: ... removing SleepWatcher is very simple:

Prevent Hard Drive From Sleep Mac App Download

Drag /Library/StartupItems/SleepWatcher to the trash. This removes the startup item, and with the next restart, SleepWatcher is deactive. To remove the Unix components, you have to execute the following command in a Terminal window:

sudo rm -f /usr/local/sbin/sleepwatcher /usr/local/share/man/man8/sleepwatcher.8 /etc/rc.wakeup /etc/rc.sleep

But it doesn't matter to let these files installed, they do nothing than occupying less then 20 kB of disk space.

So, it was very simple and worked to solve the long sleep delay of my PowerBook and the errors monitored in Console. Now it's clean... unfortunately because I would have liked the mod to work (I thought I could unplug a FW HD when the PB's in sleep with this tweak).

Slight problems with this tip.....
1) It doesn't work, the device eject warning still occurs.
2) It increases the amount of time your mac takes to sleep by alot!
3) It creates a whirly sound on wake, hoorah!
Otherwise useless, now, can someone please advise on how to reverse the changes? I would be very grateful.
MBP2.4
Thanks

I recently purchased a SmartStrip power outlet for my computer setup to turn off devices when the computer went to sleep.
It worked - except for my Hitachi Simpletech 2GB drive. The external drive has a 'power on auto' feature where you plug it into the wall and then into to the computer and only when both the wall outlet and the computer are on does the drive come on.
When the computer went to sleep the Powerstrip would turn off power to the hard drive and the USB port on the Mac would sense that the drive was removed and it would trigger some sort of event where the computer would immediately wake from sleep and I'd get a Device Removal Warning.
I then plugged the external drive into one of the 'Always Powered' outlets, but it had the same issue.
I downloaded SleepWatcher (http://www.bernhard-baehr.de/) and installed SleepWatcher and the Sleepwatcher start-up items program.
I created a file in my home directory as named .sleep and chmod r+x it. (note this thread kept talking about Desktop/.sleep , it should be in your home directory which is commonly refereed to as '~' or something like /bootdrive/usr/yourusername)
.Sleep contained the following command:
osascript -e 'tell application 'Finder' to eject '2TB'
Where 2TB was the name of my external drive.
When the computer went to sleep Sleepwatcher started and finder started to eject the drive and the computer went to sleep. The drive did not completely unmount before the computer went to sleep and it triggered some event that would wake up the Mac. The external drive would turn on and mount again with the Device Removal Warning effectively stopping sleep.
So I modified .sleep to contain:
osascript -e 'tell application 'Finder' to eject '2TB'
osascript -e 'tell application 'Finder' to delay 10'
Now the drive unmounts, finder waits 10 seconds and then the computer sleeps. It works like a charm.
I created a file called .wakeup that contains:
#!/bin/bash
backupsVolume=`diskutil list | awk '/ 2TB / {print $6}'`
if [ ! -z '$backupsVolume' ]
then
diskutil mount $backupsVolume
fi
This mounts the drive when the computer wakes from sleep.
Thank you to Sleepwatcher, this thread, and Finity.org (http://www.finity.org/node/41) for helping me with this.
P.S. I am running this on a Mac pro with Snow Leopard.

So apparently the SleepWatcher appears to be a not so 'easy' fix for the unmounting before sleep problem.
One work around is to use the automator to create an icon you can place on the desktop to put the system to
sleep. This automator sequence can be configured to be run automatically with systems that have auto-sleep as well.
Here is the sequence:
- Step 1: Automator uses Finder to identify the drive(s) you wish to unmount prior to sleep
- Step 2: Automator uses the 'Eject Disk' command to eject all the drives you specified
- Step 3: Run the following applescript:
tell application 'System Events'
sleep
end tell
Save this as an appropriate application, workflow, or plug-in and use accordingly.
Works consistently, reliably, and uses the under appreciated Automator app. :)
Hope this helps!

MAC Automatically Mount Net Drives on WAKE or START UP

Prevent Hard Drive From Sleep Mac Application

For Beginners like ME, Using SLEEPWATCHER and creating the '.wakeup' file
I am new to MAC but have final figured this out how to set up SLEEPWATCHER using this site. Thanks to the people here and lots of reading. Got the SLEEPWATCHER loaded. Installing SLEEPWATCHER is not that user friendly to new MAC users, but take your time and go through it, the instructions are pretty good.
As for creating the '.wakeup' file, I created 'wakeup.txt' in one directory and copied it to ~/
using the following lines of code and copying the code into TERMINAL
Create 'sleep.txt' and 'wakeup.txt' anywhere on your computer. The simplest might be in the head directory ~/ but it really doesn't matter.
Here is the code I used for my 'wakeup.txt' file. I use it to remount my external net drive.
__start code below line_______________________________
#!/bin/sh
exec <'$0' || exit; read v; read v; exec /usr/bin/osascript - '$@'; exit
delay 10
set testnet to 1
repeat with idx from 1 to 5
try
set ping_result to (do shell script 'ping -c 1 -t 1 192.168.20.70')
set testnet to 10
on error
if testnet = 1 then
say 'Searching for W Net Drive'
end if
beep 3
set testnet to (testnet + 1)
delay 10
end try
if testnet = 10 then
exit repeat
end if
end repeat
if testnet = 10 then
delay 1
mount volume 'smb://W-NetDrive/Volume_1'
say 'Net Drive Volumes Mounted'
end if
if testnet = 6 then
say 'The W Net Drive could not be PINGED on the network'
say ' I am unable to mount the W Drive Volumes'
end if
___________________________
end code above line
As a minimum, you need to make these two changes to the above code or it will not work for you.
1) You will need to change the IP address (192.169.20.70) on line 7 (as shown below)
set ping_result to (do shell script 'ping -c 1 -t 1 192.168.20.70')
to match the IP address on your Net Drive or the script cannot PING the Net Drive.
2) You will also need to edit the 7th last line (as shown below)
mount volume 'smb://W-NetDrive/Volume_1'
to reflect you own net drive name, or the net drive will not mount.
Further to that, you can easily remove the computer's talking if you want. Simply delete all the lines that start with 'say'. However, this only occurs at 'wake up' so it is nice to know what is going on, but edit it as you see fit.
The way this works, is that the first two lines of code (as follows)
#!/bin/sh
exec <'$0' || exit; read v; read v; exec /usr/bin/osascript - '$@'; exit
should not be revised as they set up the rest of the script to be able to process APPLESCRIPT.
(need more infer... see http://hints.macworld.com/article.php?story=20060425140531375)
Hooray!! I don't need to learn shebang and all that other complicated programming stuff.
After the first two lines, you can simply program away in APPLESCRIPT. Use your APPLESCRIPT editor to ensure the code is correct, the copy/paste your APPLESCRIPT into your 'wakeup.txt' or 'sleep.txt' file, after the first two lines of code (as noted above).
Then you need to rename the '.txt. files as follows
wakeup.txt to .wakeup
sleep.txt to .sleep
Place the new '.' files in the head directory ~/
Then you need to change the '.wakeup' and '.sleep' file permissions to executable.
I did that this way....
__________________________________________
Enter the following text into TERMINAL to rename files and create the hidden '.' files.
I just copied in one line of code at a time.
FOR .SLEEP
cd ~/
cp ~/documents/data-k/W_NetDrive_PING/sleep_and_wake_files/sleep.txt ~/.sleep
chmod a+x .sleep
FOR .WAKEUP
cd ~/
cp ~/documents/data-k/W_NetDrive_PING/sleep_and_wake_files/wakeup.txt ~/.wakeup
chmod a+x .wakeup
Basically its
cp path/to/file.txt ~/.wakeup
This copies the file to the ~/ directory and changes the name in one command.
Then change the permissions using
chmod a+x .wakeup
________________________________________________
This works great !
so....Place your computer into SLEEP, then WAKE it up. Your NetDrive should mount automatically and inform you that it should now be mounted. If it cannot be found in order to mount it, it will also tell you that. Change it to what ever you want it to say.
Oh, at this point in time I actually only use '.wakeup', I have not set up anything in '.sleep'
________________________________________________
As for mounting the drives on START UP I use a similar APPLESCRIPT as follows. Using my APPLESCRIPT Editor I created the following script.
____Script starts below the line___________________
set testnet to 1
repeat with idx from 1 to 5
try
set ping_result to (do shell script 'ping -c 1 -t 1 192.168.20.70')
set testnet to 10
on error
beep 3
set testnet to (testnet + 1)
delay 10
end try
if testnet = 10 then
exit repeat
end if
end repeat
if testnet = 10 then
delay 1
mount volume 'smb://W-NetDrive/Volume_1'
say 'Net Drive Volumes Mounted'
end if
if testnet = 6 then
say 'The W Net Drive could not be PINGED on the network'
say ' I am unable to mount the W Drive Volumes'
end if
____________________________________
script ends above the line
In the APPLESCRIPT Editor I save the file as 'W-PING.scpt', then re-save the file only this time changing the FILE FORMAT to APPLICATION and as 'W-PING.app'
This file 'W-PING.app' is now executable, (if not change it as above, but I think it become executable as soon as it is saved as an '.app' file extension.)
Then go into the APPLE SYSTEM PREFERENCES
Go to category SYSTEM and find 'USERS & GROUPS' and open it.
On the left hand side you will see the 'Current User', and click on it.
On the right hand side at the top look for 'Login Items' and click on it.
You will see some apps that automatically open when logging in.
Below the box you will see a '+|-' box, go click on the '+'
direct the window to the 'W-PING.app' file or what ever you decided to call it and then click 'ADD'
Repeat this for which ever Users need the Net Drive automatically loaded. You will have to be logged in as them in order to be able to change their start up programs at login.
!!!!!!!!!!!!!!!!!!
Hooray, you are done! You computer will now remount the NetDrive Volumes at both START UP and WAKE.
At least it has all worked for me.
I know there are likely other ways of doing this, but this worked for me so I wanted to share it to save other beginners a bunch of hours trying to figure this out. Just as a though, you may also have to copy the W-PING.app file to a location in their User profile where they can find it and set it up as an application to open at START UP.
Good Luck!