Jump to content
CCleaner Community Forums
lmacri

Why Does Windows Disk Defragmenter (dfrgntfs.exe) Run During Idle?

Recommended Posts

I am running Piriform Defraggler v. 1.21.209 on a 32-bit Windows Vista Home Premium SP2 PC. I recently discovered that the Windows Disk Defragmenter (dfrgntfs.exe) sometimes runs when my system is idle and causes my hard drive to thrash for long periods of time.

 

I did not expect that Windows Disk Defragmenter (WDD) would be the culprit since scheduled WDD defrags are disabled on my machine [i.e., the "Run on a schedule" check box of the WDD GUI is disabled and the Windows Task Scheduler shows that the ScheduledDefrag task (Start | Administrative Tools | Task Scheduler | Task Scheduler Library | Microsoft | Windows | Defrag) is disabled and has not run for the past two years]. I am also certain that there is no partially completed manual WDD defrag running on my system that could be re-starting during idle.

 

Does Windows Vista automatically perform some sort of system files optimization routine after boot-up that would cause WDD's dfrgntfs.exe to run during idle? I'm not certain, but this idle-time WDD defrag seems to runs for longer periods after I perform a full disk defrag with Defraggler and I'm wondering if this "silent" WDD defrag is relocating of some of the system files on my hard disk after Defraggler finishes its full disk defrag.

Share this post


Link to post
Share on other sites

I believe that there are two aspects here.

 

Imacri is apparently seeing the prefetch defrag. In the prefetch folder is a text file called Layout.ini, which is a simple composite list of all the files that the other entries in the prefetch folder (the .pf files) are referencing. At three-day intervals, when the pc has been idle for at least 10 minutes, Windows invokes its defragger to defrag the files listed in Layout.ini, presumably with the intention of grouping all those files into one contiguous lump on the disk. This is all done by default, although it could be disabled if one should so wish.

 

Aethec's link pointed me to something I wasn't aware of, that Windows XP onwards does a boot-time defrag as well as and separate from the prefetch defrag. I've looked, and it's enabled on my box and has been doing its stuff for years without me noticing. Although I haven't found a definitive statement, I believe that the boot-time defrag only defrags those files referenced in the NTOSBOOT-B00DFAAD.PF prefetch file and not all those application files found in Layout.ini. That would be sensible.

 

My instinct says that the boot files would be not changed very often, or in my case hardly at all, as I don't modify my machine's boot behaviour at all, or very rarely. NTOSBOOT-B00DFAAD.PF is included in Layout.ini, so it gets defragged every three days anyway. So one could turn off the boot-time defrag and perhaps speed up boot time a fraction. On the other hand, does defragger look at the files at boot-time, discover that they are already defragged, and ignore the command, in which case stopping it would have negligible time gain. All these questions.

Share this post


Link to post
Share on other sites

Well idle defrag can be turned off in XP which I always do if using a third party defrag tool using Microsoft Tweak UI.

 

It can be disabled in:

General -> Optimize hard disk when idle

 

Disabling that allows third party defrag tools less work, and less moving around of files, i.e.; stopping idle defrag from undoing their optimization features.

 

Of course Vista an onward need a different approach to disabling it.

Share this post


Link to post
Share on other sites

Thanks to everyone for the excellent feedback. I followed up on the replies to my original post and found an article in the MSDN library (see Disabling Disk Defragmentation) that indicates that there are at least two registry changes required to disable "silent" idle-time Windows defrags (at least in XP):

 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction (Enable = N, type is REG_SZ)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout (EnableAutoLayout = 0, type is REG_DWORD)

 

According to this article, the disk defragmentation service rearranges data on the disk to create contiguous sections of data, while the the auto-layout service moves the most-used data closer to the center of the disk to expedite boot time. A second article on the Microsoft TechNet (see Disk Defragmenter Tools and Settings) has more detailed information about the BootOptimizeFunction key and states that "Windows automatically optimizes the file location for boot optimization. This optimization occurs automatically if the system is idle for 10 minutes. Boot optimization improves startup time by locating startup files in contiguous clusters on the volume, reducing the movement of the disk head when reading the volume."

 

After checking the link in Aethec's post I looked at my Windows registry and, like Augeas, the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction key is enabled on my Vista machine by default.

 

There is no value named EnableAutoLayout for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout in my Vista registry, but I gather that this value could be created manually. This ties in nicely with Andavari's post, because I've been told that if the "Optimize hard disk when idle" feature is disabled in Tweak UI (available here for Windows XP and Server 2003), then Tweak UI will actually create a new EnableAutoLayout value in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout key and set the value to 0 (zero). Too bad that Microsoft SysInternals never released a Tweak UI for Vista or Windows 7.

________

 

It sounds to me like this "silent" Windows idle-time defrag is designed to reduce boot times, so I'm not going to do any registry hacks until I get a definitive answer from Piriform. Given that this background Windows defrag by dfrgntfs.exe occasionally thrashes my hard drive for more than 30 minutes, I'm concerned that Defraggler and Windows use different algorithms to optimize the location of boot-up files and constantly shuffle these files around my hard drive drive.

Share this post


Link to post
Share on other sites

I'm concerned that Defraggler and Windows use different algorithms to optimize the location of boot-up files and constantly shuffle these files around my hard drive drive.

 

Howdy ! I've the same concern, did you got any answer ?

Share this post


Link to post
Share on other sites

what answer are you chasing to this 3 year old thread?

"that Defraggler & Windows use different algorithms" or "Why Does Windows Disk Defragmenter (dfrgntfs.exe) Run During Idle?"

Share this post


Link to post
Share on other sites

Howdy ! I've the same concern, did you got any answer ?

 

If there would've been an answer I'd imagine it would've been posted in this topic.

 

Some 3rd party defrag tools (not all) offer to disable the built-in Windows Disk Defragmenter, so manually editing the registry or using a tools like Tweak UI (in XP at least) wouldn't be necessary for such 3rd party defrag tools.

Share this post


Link to post
Share on other sites

Hi rodot:

Welcome to the Piriform forum.

I still don't have a definite answer as to whether Windows Disk Defragmenter (dfrgntfs.exe on my 32-Vista OS) and Piriform's Defraggler (defraggler.exe) both use the exact same file placement algorithm.  There is a Piriform support article here titled Why Defraggler is Safe to Use stating that Defraggler uses Window's internal API (Application Programming Interface), but I'm not certain if that means that operations for defragging and file placement like those described here in the Windows Dev Centre are coded identically in Defraggler.

I still have the scheduler for automatic Windows Disk Defragmenter (WDD) defrags disabled on my system, and I still see WDD's dfrgntfs.exe running for 10 - 30 min during the occasional system idle, which I assume is the Windows background WDD optimization of system boot files I described in post # 5 that can only be disabled with a registry edit.  I use Defraggler for disk fragmentation analysis and Quick Defrags, but I have the Defraggler setting at Options | Advanced | Windows Integration | Replace Windows Disk Defragmenter disabled so that I can run a full disk defrag with WDD a few times a year to ensure my Windows system files have their optimum disk placement for faster boot-ups.  I don't know if that's necessary, but until I get a definitive answer from Piriform about how their file placement algorithm works I'll keep using WDD for my full disk defrags.
-------------
Windows Vista Home Premium 32-bit SP2 * NIS v. 20.4.0.40 * CCleaner 4.08.4428 * Defraggler 2.16.809
HP Pavilion dv6835ca, Intel Core2Duo CPU T5550 @ 1.83 GHz, 3.0 GB RAM, NVIDIA GeForce 8400 GS

Share this post


Link to post
Share on other sites

Imacri - I would like to thank you for all the work you have put into this. I recently bought a Lenovo T400 Thinkpad that had Vista Business installed. I used Vista for several days visiting Lenovo's support website in order to find the BIOS and firmware updates available for this machine. Then I installed openSUSE 13.1 and noticed that the almost constant disk activity that was going on when Vista was installed had vanished. I was always curious as to why Vista was doing this, and now I know. Thank you again for your effort.

Share this post


Link to post
Share on other sites

I'm thinking that if you 1) ran Windows Defrag then 2) run Defraggler then 3) ran Windows Defrag again that if they really were using the same file placement algorithms then there should be no, or very little, file re-organising going on.

 

I think (years ago admittedly) that this was not the case and 2) did a whole, long-winded defrag and then 3) proceeded to defrag all over again.

Share this post


Link to post
Share on other sites

I'd think the algorithms are different for the mere fact Defraggler will redo some of what Windows Disk Defragmenter has done, and vice-versa.

 

Edit:

Just because Defraggler is using the Windows Defrag API (which most 3rd party defrag tools use) doesn't mean using the same algorithms.

Edited by Andavari

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...