Stop Windows 7 from flooding the LAN with SMB queries
Hard drive "spin-up" is a very specific operation with the following characteristics and limitations:
- For most desktop / consumer HDDs, it takes between 3 and 5 seconds to complete the spin-up process. During the spin-up process, the HDD cannot read or write any data.
- During the spin-up, if you listen very close to the device, you will hear an increasing pitch sound. At the end of it you will hear a burst of those soft clicks of the HDD's ball bearings moving as the disk "seeks" to various locations (to satisfy the I/O requests that were queued when it started to spin up).
- Consumer HDDs are designed for thousands of spin-up / spin-down cycles, with some lower quality units failing around 1000-2000 spin-up cycles, but with many being engineered for around 600,000. After this number of spin-up cycles, the mechanisms involved in the process start to break down, and will eventually fail.
On the software side, a well-configured system would generally have one of three sorts of policies around spin-ups/spin-downs:
For extreme energy conservation (e.g., in a laptop on battery power), the shortest possible spin-down time you might expect would be around 15 or 30 minutes of inactivity (no disk activity during the period). On modern Windows, we have so many programs running all the time and doing nearly constant I/O that the chances of there being no disk activity for 15 minutes, even on a "clean" system, even with the user completely idle, is virtually zero. In practice, this configuration is uncommon these days.
For moderate energy conservation, a typical desktop spin-down time might be around 2 to 4 hours. This means, if no reads or writes occur to that hard drive over a period of 2 or 4 hours (or whatever it's configured to be), the disk will spin down, and the next I/O request to hit it will have to spin the disk back up.
For servers, since they are desired to always be available at any instant (without any lag in their response), spin-down due to inactivity is usually disabled. This would apply to a NAS as well as a web server or any other type of server.
I would be surprised if the WD NAS you own is designed out of the box to have an extremely short spin-down time. However, there was a bug in Ubuntu Linux many years ago (in 2007) where they accidentally set the spin-down idle time to 0 seconds. This meant that as soon as the disk stopped handling an I/O request, the "0 second" timer for the spin-down would immediately expire, the disk would spin down, and the heads would park. Then I/O requests would queue up in memory while the disk had to spin up again to handle them.
This constant churn of spin-up / spin-down was killing peoples' hard drives in very short order on Ubuntu in 2007. Folks who didn't notice and correct the problem quickly experienced working HDDs failing in days to weeks (these HDDs were either not designed with frequent spin-up cycles in mind, or they were less than 1 year from failing under normal usage).
If your NAS is constantly spinning up and down, the disks inside it are suffering a sort of mechanical wear that is uncommonly weathered (at this frequency) by HDDs, so it's really kind of a torture test for them. You should attempt to remedy the situation on the NAS itself.
Try the following:
- Look through every firmware setting on the NAS's configuration pages and make sure you change any power management settings to be as "lax" as possible (minimal power savings / disabled).
- Update the firmware of the NAS to the latest available from the manufacturer.
- If you're comfortable opening the NAS chassis, do so, and find the model and serial numbers of the HDDs inside. Then punch those numbers in online and see if you can find firmware updates for the HDDs themselves (you can directly apply the firmware updates from Windows by putting the HDDs into a computer if you can't update their firmware from the NAS interface).
- If SMART diagnosis is available for the disks, you should check them using a SMART diagnostics program, or look for such in the NAS firmware, as an indication of possible failure.
- If none of this solves the problem, it's likely that the HDD(s) inside the NAS are defective, or the NAS itself is defective. If the HDDs are experiencing certain types of internal errors, they may be resetting themselves (power off / power on) and as a result are spinning down, then spinning back up.
Now, as to your suspicion that Windows is the problem? It's not. A NAS's disks should not constantly be spinning down after only a few seconds of idle time. They simply shouldn't. Period. No one designs their NAS like that on purpose (well, I wouldn't totally put it past WD to do that, but it's unlikely).
Windows 7 is completely blameless if that's happening because your Windows computer can't control the power management functions of your NAS's SATA controller through the SMB protocol. Only the operating system of the NAS can do that.
What Windows 7 actually does when you open Windows Explorer, is it performs certain SMB operations that query the filesystem metadata to calculate the total and available disk space on the NAS's shared space.
For a hard drive that's spun up and "fully running" at the time of access, calculating the total and available disk space should take less than a second. The request isn't particularly expensive, and it's not "flooding" by any measure.
If you truly believe that Windows is performing some kind of a command flood to the NAS, you should prove it to yourself by installing Wireshark on one of your Windows 7 computers and run a packet sniff on the SMB protocols with an IP destination of your NAS. I would consider it a flood if more than about 100 requests are sent just by opening Windows Explorer, and especially if the requests continue to happen at a very high rate for more than 5-10 seconds after opening Explorer. Otherwise it's more or less normal.
Keep in mind that certain virus scanning and backup products aren't smart enough to realize that a mapped network drive (e.g. F: or something) is a shared drive and, as a result, attempt to do virus scanning or backups on the entire drive (not just the files you access from it deliberately). These sorts of bugs are mostly historical, but can crop up from time to time with certain software. There are also some programs that will faithfully execute a user's instructions if they, for example, configure the program to perform an hourly full virus scan on a shared drive. Once this process begins, it would indeed "flood" the NAS with SMB requests.
So you might want to rule out that sort of thing occurring, but the root cause of the problem in my opinion is that the drive is spinning down in the first place. A good NAS won't let the drive spin down and the heads park until at least 2 hours of total inactivity. If you can open/close Windows Explorer very fast and reproduce the spin-up each time, something is wrong on the NAS side.
Continuously browsing the web I was lead to the following 'solution', which is might be kind of uncomfortable for some people, but still retains network access:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\NonEnum]
"{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}"=dword:00000001
Setting the above dword to 1 removes all references of the network environment out of the windows explorer, which also prevents the spinup of my NAS whenever someone opens a windows explorer instance. Downside is, if you ever want to browse the available machines, you have to manually enter the path to the network environment into a windows explorer path textbox. Machine links and everything else still works.
btw, the drives inside this particular NAS are WD REDs