Jump to content











Photo
- - - - -

[SOLVED] Can't Defrag a Win7 VHD file under XP?


  • Please log in to reply
15 replies to this topic

#1 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 12 March 2009 - 11:40 AM

Hi,

My 150GB C:\ Drive has a 40GB VHD file containing Win7beta. There's about 50GB Free Space. There is 1GB RAM.

Using XP Pro's Defragmenter, the Drive looks badly fragmented. But it quits with a message saying some files cannot be defragmented. The report shows Total Volume Fragmentation: 21%, and File Fragmentation: 42%. It also states that there is only one file fragmented - the VHD - with 64 fragments.

Is this inability to defragment the VHD a result of the shear size of the single file, or do VHDs have other properties that make them un-defragmentable (under XP)?

Should I try a different defragmenter? Perhaps under PE? Any risks of damaging the contents of the file?

Thanks

#2 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7100 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 12 March 2009 - 12:08 PM

Should I try a different defragmenter? Perhaps under PE?

YES: :cheers:
But the problem might NOT be in the XP's defragmenter, but on the actual "XP". :cheers:
I mean it is possible that the changes made to NTFS require Vista to manage properly a Windows 7 NTFS filesystem. :cheers:
http://en.wikipedia....nsactional_NTFS
but also some permission settings were changed, if I recall correctrly.

Just in case:
http://ultradefrag.sourceforge.net/

Since with it you can select WHAT to defragment, you may be able to "skip" past the problematic file(s).

Any risks of damaging the contents of the file?

YES. :cheers:

jaclaz

#3 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 15 March 2009 - 05:07 PM

Since with
it you can select WHAT to defragment, you may be able to "skip" past the
problematic file(s).


No luck running UltraDefrag in WinPE 2.1. The Special notes for Windows Vista users are a bit hard to implement, and that may be the problem. It's an 'access denied' error for writing a UltraDefrag log that causes the Program to quit before it gets under way. Tried it under XP too, and the status was not particularly clear.

Had better luck with jkDefrag in WinPE 2.1. When booted to WinPE, there was only one fragmented file - the 40GB-fixed native-boot Win7 VHD. So ran jkDefrag to defragment C:, and it showed the single fragmented file. Then it copped out with 99% CPU usage at the Defragment stage... waiting hours for nothing!

Maybe there is a way to give it more room to move.

Otherwise, the Lesson might be to defragment thoroughly before creating a big VHD on an XP system.

I'll boot to Win7beta to see if its Defragmenter is more successful.

Regards

#4 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 15 March 2009 - 06:10 PM

I'll boot to Win7beta to see if its Defragmenter is more successful.


As I was booting Win7beta, it suddenly occured to me that the defragmented VHD is actually (virtually) the Win7 'Partition' that I'm booting to. Is it possible to defrag a single file from within that file?

The Win7 Partition (inside the VHD) was only 2% defragmented after a clean install.

Win7beta's Defragmenter analyzed the XP Partition as 0% defragmented, so perhaps it ignored the VHD. I selected to Defrag anyway, and it went thorough 4 or 5 passes at 'consolidation' and there was considerable disk activity and CPU usage.

Booted back to XP and the good news - the VHD is now in 5 fragments rather than the original 64 fragments.

The bad news - I don't know whether it was Win7's Defragmenter or jkDefrag under WinPE 2.1 that caused the improvement because I forgot to take a look after rebooting from WinPE 2.1.into XP then on to Win7beta.

The whole saga ought to have been more meticulously examined ... ^_^ ...

Regards :good:

#5 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7100 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 15 March 2009 - 06:37 PM

Can I use this thread as an example of the antonym to this? ^_^:
http://en.wikipedia....ientific_method

:good:

^_^

^_^

jaclaz

#6 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 15 March 2009 - 07:51 PM

Yes. Impatience is not a virtue.

In the old days, one of my favourite pastimes was watching Norton Speed Disk moving the little coloured squares around on my first computer - a Mac. Not any more.

The pace of Windows' Defragmenters is so much quicker than the others mentioned, and the results are clearer. However, I didn't bother to look for a graphic or detailed report on Win7 - neither were apparent in the Defragmenter GUI.

Regards

#7 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7100 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 15 March 2009 - 08:08 PM

In the old days, one of my favourite pastimes was watching Norton Speed Disk moving the little coloured squares around on my first computer - a Mac. Not any more.


Not much to do down-under as a kid? :good:

^_^

In my day...:
http://www.911cd.net...o...21362&st=10

^_^

jaclaz

#8 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 16 March 2009 - 06:52 AM

Not much to do down-under as a kid? ^_^


... continuing with the scientific analysis, it seems ittle has changed in the passing years.

I started with the valid hypothesis that nothing's going to work and it's all a waste of time. Having disproved that, we now have a theorem that something did work.

Strangely, my latest test disprove the theorem! Here are the results shown in the analysis graphic of XP immediately after each attempt at a defrag.

Defagged in XP:
[attachment=7885:XPDefrag1.gif]

Defragged with jkDefrag in WinPE 2.1:
[attachment=7886:XPjkDefrag2.gif]

Defragged in Win7 beta (actually 'consolidated' because it's still reporting 0% defragmentation):
[attachment=7887:XPWin73.gif]

There is very little difference. Some minor fragmentation as a result of rebooting and logging on/off.

However, after defragmenting with jkDefrag in WinPE 2.1, the VHD fragments actually increased from five to six, so there is some sign of action. The problem is this:
[attachment=7888:WinPEjkDef1.gif]
... defragmentation at 100% and CPU usage at !00%. All known methods to terminate jkDefrag failed, and the computer simply refused to shutdown. The only course was to reset - all up about half an hour's running time in WinPE 2.1.

For my earlier scientific experiment (... ^_^ ...), starting with the 64-fragment VHD, the entire process lasted quite a lot longer while I tried to figure out ways to kill jkDefrag and a host of other Apps that were stubbornly hanging on - a couple of hours maybe, including a longer period before jkDefrag showed 100% defragmentation.

The explanation comes from Jeroen Kessels on his forum:
http://www.kessels.c...msg8162#msg8162

JkDefrag is simply moving a very large file. It uses white to highlight the file with which it is busy. Which filename is shown in the status bar? That is the file. You can exclude the file with the JkDefrag "-e" option, if you want. Take a look at the advanced properties of the file, is it compressed? If so then that explains why it is slow. The percentage is only an estimate and can be wrong (and go up to 100%) especially in cases such as yours, when JkDefrag has moved some small files and then moves a huge file.


As for Win7 beta' Defragmenter ... :good:

Regards ^_^

#9 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7100 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 16 March 2009 - 12:02 PM

Cannot say if it helps: ^_^
http://www.msfn.org/...showtopic=12947
http://www.msfn.org/...o...129473&st=8

I guess that the equation is so mixed up that adding one more variable cannot hurt too much. :good:


There are trial versions that you can experiment with:
http://www.perfectdisk.com/

^_^

jaclaz

#10 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 16 March 2009 - 11:37 PM

Cannot say if it helps: ^_^


Possibly! However, I'm fairly satisfied with jkDefrag, and that's where this experiment must end for me. My old buddies and I have moved on from watching defragmenters all day. We now spend most of our time watching screensavers! ... :good: ...

To recap:

1. XP with a 40GB native-boot Win7 beta VHD file in 64 fragments
2. XP's Defragmenter cannot defragment the VHD file
3. Booted WinPE 2.1 and ran jkDefrag, selecting to defragment the XP Volume. Reset (switched the power off) after about two hours with jkDefrag reporting 100% defragmentation
4. Booted the Win7 beta VHD and ran Win7 beta's Defragmenter, which reported 0% defragmentation on the XP Volume (which contained the VHD which was booted), and completed 4 or 5 'consolidation' passes.
5. Ended up with the the VHD file in five fragments
6. Repeated the experiment, terminating the WinPE 2.1 session after just half an hour with jkDefrag reporting 100% defragmentation
7. Ended up with the VHD file in six fragments after running jkDefrag

The explanation from Jeroen Kessels is that the 'Defragment 100%' reading is incorrect when defragmenting a very large file.

The second experiment showed that Win7 beta's Defragmenter did nothing with the VHD. Unlike XP's Defragmenter, Win7's Defragmenter did not even acknowledge the VHD as being defragmented, either because it is programmed to ignore VHD files or because it was actually the VHD that had been booted.

The conclusion is that jkDefrag did defragment the VHD from the initial 64 fragments to five. Then, in the second session, began defragmentation, but the session was terminated much too early with a false reading of 100% defragmentation, and the VHD ended up with one extra fragment.

In the jkDefrag Forums, it is mentioned that under safe mode, jkDefrag can take a very long time because there is no 'disk cache' in safe mode. Fortunately, WinPE 2.1 allows a scratch-space (which I assume is the same as 'daisk cache'). The default size is 32MB. However, it can be increased up to a maximum of 512MB.

The final experiment (when I have time) will be to see if jkDefrag, under WinPE 2.1 with 512MB scratchspace, will complete the defragmentation of the 40GB VHD file. Hopefully it will terminate itself after completion (when it really reaches 100% defragmentation) , and then switch on its own screensaver. That'll be interesting to watch - apparently it's a back-screen screensaver, which we haven't seen before! ... ^_^ ...

Regards ^_^

#11 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 17 March 2009 - 02:42 PM

The final experiment (when I have time) will be to see if jkDefrag, under WinPE 2.1 with 512MB scratchspace, will complete the defragmentation of the 40GB VHD file. Hopefully it will terminate itself after completion (when it really reaches 100% defragmentation) , and then switch on its own screensaver.


Sadly, after watching Task Managers CPU graph for six and a half hours we decided to go and get something to eat and switched the computer off. The graph stayed at 100% the whole time. We thought that was pretty cool! ... :good: ...

And the VHD is still in six fragments ... ^_^ ...

Time to delete it.

#12 cdob

cdob

    Gold Member

  • Expert
  • 1440 posts

Posted 17 March 2009 - 04:35 PM

Defrag a Win7 VHD file under XP:

contig H:\WindowsAnnika.vhd

Contig v1.52 - Makes files contiguous
Copyright © 1998-2005 Mark Russinovich
Sysinternals - www.sysinternals.com


Summary:
Number of files processed : 1
Number of files defragmented: 1
Average fragmentation before: 5 frags/file
Average fragmentation after : 1 frags/file

There is a dynamic file size, currently 6 GB used.
XP can defrag a Win7 VHD file. Disk was partitioned and format within Win7.

BTW: that's currently a USB hard disk.

#13 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 17 March 2009 - 05:28 PM

There is a dynamic file size, currently 6 GB used.
XP can defrag a Win7 VHD file....


Thanks. I was wondering why jaclaz hadn't recommended it.

Anyway, I had created a Windows PE 3.0 (for Win7beta) to use its diskpart to remove VHD. ... thought it might be the proper way, rather than simply deleting it.

Fortunately, I put the Sysinternals Suite on board, and contig is currently running over the file.

Any idea how long it might take? I can see disk activity - more than I could see with jkDefrag! However, I'm only in the command-prompt shell, and contig has taken it over. So, no Task Manager or anything to watch - just three dots and a blinking cursor ... ^_^ ... Should I make a cup of tea or send one the boys out to get some popcorn?

Regards :good:

#14 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 17 March 2009 - 06:14 PM

... Should I make a cup of tea or send one the boys out to get some popcorn?


Never mind! A cup of tea was all that was required. It's finished!

Contig v1.54 - Makes files contiguous
Copyright © 1998-2007 Mark Russinovich
Sysinternals - www.sysinternals.com


Summary:
Number of files processed : 1
Number of files defragmented: 1
Average fragmentation before: 6 frags/file
Average fragmentation after : 2 frags/file


X:\Windows\System32>notepad

X:\Windows\System32>contig -v c:\win7beta.vhd

Contig v1.54 - Makes files contiguous
Copyright © 1998-2007 Mark Russinovich
Sysinternals - www.sysinternals.com

------------------------
Processing c:\win7beta.vhd:
Scanning file...
Scanning disk...
File is 10485761 physical clusters in length.
File is in 2 fragments.

c:\win7beta.vhd is as contiguous as possible.
------------------------
Summary:
Number of files processed : 1
Number of files defragmented: 0
All files were either already defragmented or unable to be defragmented.

X:\Windows\System32>


[attachment=7894:contigVHD.gif]

Two fragments left. But when Mark Russinovich says that's as good as it gets, then I reckon that's as good as it gets too!

Brilliant! Thanks cdob and Sysinternals. ... :good: ...

#15 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7100 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 17 March 2009 - 08:04 PM

I did not understand what the problem was, evidently.

I thought you were trying to defrag a mounted image, not an "offline" file.

Or I am not understanding it now? ^_^

However, jaclaz failed to recommend contig for this reason, and because he would have recommended to test wincontig :good::
http://wincontig.mdt...it/en/index.htm

^_^

jaclaz

#16 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 18 March 2009 - 01:03 AM

I thought you were trying to defrag a mounted image, not an "offline" file.

Or I am not understanding it now? :good:


I think you're with me now ... ^_^ ... It was just a single file on my XP Volume that was causing some grief. Not every day that a defragger has to try to manage a 40GB file.

I've already given out first prize to contig for coming first. But WinContig must receive the highest honours for the following reasons.
1. It offers to run CheckDisk.
2. It offers to remove Temporary Files.
3. It has a an appealing GUI.
4. It gives a reason why the 40GB .vhd file cannot be defragged any further.

Here it is running in WinPE 3.0 with bbLean Shell:
[attachment=7898:wcontig.png]

Thanks a million. Can I finish now? ...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users