• RSS
  • Twitter
  • FaceBook

Security Forums

Log in

FAQ | Usergroups | Profile | Register | RSS | Posting Guidelines | Recent Posts

[Tutorial] Using XP's Disk Defragmenter Utility

Users browsing this topic:0 Security Fans, 0 Stealth Security Fans
Registered Security Fans: None
Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Windows

View previous topic :: View next topic  
Author Message
Tom Bair
SF Boss
SF Boss


Joined: 10 Aug 2002
Posts: 16776955
Location: Portland, Oregon USA

Offline

PostPosted: Sun Oct 22, 2006 12:15 am    Post subject: [Tutorial] Using XP's Disk Defragmenter Utility Reply with quote

Defragmenting your hard drive ... by Tom Bair

One of the most Preventive Maintenance Routines you can perform is to keep your computer's hard drive in prime working order. This tutorial will look at the Windows XP System Tool, Disk Defragmenter.

What this tool does is to reorganize the data located in the occupied space of a disk volume within XP by making each file to be written to a contiguous part of the volume. Bit confusing to you?

Try imagining a binder with 100 clear plastic sheet holders in it. You are able to hold a total of 200 sheets of printed paper in that binder, placing them back to back; two sheets of paper per holder. The perfect solution is to have your page 1 in the very first sheet with page 2 inserted on the back side. Yet let's say you've finished page 47 first, and have to slip it in quickly. You don't have time to count the sheets to see where page 47 would fit in.

As you go, you insert pages. Maybe page 14 would be the next page finished, and it would go right behind page 47. Then you finished page 183, so it is slotted into the second sheet holder in the binder. You get the idea.

Once your binder is filled with 200 pages, imagine how time-consuming it would be to read your manual, starting first with page 1. Next you would have to find page 2, 3, and 4. The amount of time spent locating the pages in order to read the manual in sequential order would be several times as long as the actual reading.

So along comes Miss Defragmenter. She first pulls out the first sheet in your binder. Then she will locate and pull out page 1 and insert the prior sheet (page 47) into its place. She places page 1 into the first sheet holder in the binder then next pulls out the page behind it (page 14). This process continues until the binder is organized in sequential order. She then hands you the binder and you gleefully read through it from start to finish in a flash.

Now you understand what fragmentation is for a hard drive, and how it is fixed. You also should understand why you would want to fix it. Speed things up, right?

How Defragmenter Works

The tool will first analyze your volume to discover how badly fragmented the files on it actually are. It does this by checking the File Allocation Table (FAT) on FAT/FAT32 volumes, and checking the Master File Table (MFT) on NTFS volumes. Since both table types keep a record of the data blocks used by each file, it is rather easy for the defragmenter tool to determine which files are using discontinuous volume space.

Once the volume has been analyzed, Defragmenter will start in cleaning up the fragmented files. You may still notice some areas of free disk space after the Tool has finished the job. This is due to the fact that Defragmenter only defragments the files on the drive. It does not reorganize nor compact the files on the volume.
Actually Using It

There are two popular methods of accessing Disk Defragmenter. I shall give instructions to both methods below:

Using the Start Menu

1. Click on the Start button.
2. Highlight All Programs.
3. Highlight Accessories in the sub-menu.
4. Highlight System Tools in the next sub-menu.
5. Click on Disk Defragmenter.
6. In the Disk Defragmenter Window, click on the Hard Drive you wish to defragment.
7. Click the Defragment button.

Using My Computer

1. Double-click on My Computer.
2. Right-click on the Hard Drive you wish to defragment and click on Properties in the pop-up command window.
3. Click on the Tools tab.
4. Click on the Defragment now... button.

Once the Tool has completed the job, you can exit the Window. The time involved to defragment a volume varies depending on how badly fragmented the volume actually is. Generally, the first time you run the tool; it can take up to several hours to complete. Yet if you run it twice a week, the job is done within minutes.

You will not want to be running other programs while this process is under way. It might slow it down. It would actually force it to start over again from the beginning if the other program you are running accesses the Hard Drive during the defragmentation process.

Fragmentation of the Pagefile

This section is a bit tougher, and you may want to skip this if you feel you are uncomfortable with the process. Also note that you will need to have two volumes running on your PC to perform this feat. That means you will either need to have at least two logical drives set up on your system's single physical hard drive, or have two physical hard drives installed.

The Pagefile has also been called Paging File, virtual memory, and swap file. They are all one and the same. Disk Defragmenter will not and cannot remove the fragmentation in a Pagefile. However, there is a slick way around this by simply re-creating the Pagefile.

What we will be doing is creating a new Pagefile on the second volume and activating it. Then we will remove the Pagefile from the Primary volume and run Disk Defragmenter. The space once occupied by the Pagefile will be available to Disk Defragmenter to insert whole files into.

Once the defragmentation process is complete, we will place a fresh and contiguous Pagefile back on the Primary volume, and remove the temporary Pagefile on the second volume. So let's get started.

1. Right-click on My Computer located on your Desktop.
2. Click on Properties.
3. Click on the Advanced tab.
4. In the Performance frame at the top of the window, click on the Settings button. Be careful that you select the correct button, since there are three of them in the window.
5. In the Performance Options window, click on the Advanced tab.
6. In the Virtual Memory frame at the bottom of the window, click on the Change button.
7. You will see your drives (volumes) listed in a dialog box at the top of the Virtual Memory window. Keeping in mind that Drive C holds your Primary Pagefile, click on a drive other than C on which you would like to make a temporary paging file.
8. In the Paging file size for selected drive frame, click on the radio button next to Custom size.
9. Taking note of the size in megabyte listed beside Recommended in the Total paging file size for all drives frame at the bottom of the window, enter this figure into the dialog boxes next to Initial size and the Maximum size.
10. Click the Set button. This will result in the Paging file being created.
11. Click on the volume with the primary paging file, (commonly Drive C).
12. Change the Initial size and Maximum size to 0.
13. Click on the Set button.
14. Exit all windows.
15. Reboot your computer. This will remove the paging file from the Primary volume and place it on your other volume.
16. Run Disk Defragmenter and select your Primary volume (normally Drive C). Defrag will reuse the space which was once occupied by the paging file.
17. Once Defrag has completed its process, exit the Tool.
18. Open the Virtual Memory dialog box once more by following steps 1 - 6 above.
19. Click on the drive you just defragmented.
20. Follow steps 8 - 10 above to once again assign a paging file to your Primary volume.
21. Start the process of removing the Paging file from your other drive by clicking on it in the dialog box in the Virtual Memory window. Then set the Initial size and Maximum size to 0.
22. Click on the Set button.
23. Exit all windows.
24. Reboot your computer.
25. Repeat steps 1 - 6 above.
26. Click on the drive you just set the Page File to 0 on.
27. Now click on the radio button next to No paging file.
28. Click on the Set button.
29. Click the OK button.
30. Again, reboot your computer. You now have a defragmented Pagefile.

I have always recommended that people check their drives for errors before defragmenting one. You can do so by clicking on the Check Now... button located in the Error-checking frame on the same Tools tab where the Defragment Now... button is located. If there are errors on the volume when you run Defrag, you can increase the seriousness of those errors, possibly to the point where your computer will not boot from the Primary volume.
Back to top
View user's profile Send private message Visit poster's website
AdamV
SF Mod
SF Mod


Joined: 06 Oct 2004
Posts: 24
Location: Leeds, UK

Offline

PostPosted: Sun Oct 22, 2006 11:57 am    Post subject: Reply with quote

Do not forget to log in with an account that has local admin rights before doing all of the above, or you will be told that you do not have the appropriate rights.
As Tom says, running other programs at the same time as defrag may slow both down, but it is much more tolerant than (say) win 98 and rarely is forced to restart because of other disk access. Similarly in XP you can stop a defrag and it can carry on next time without restarting the whole process.
Back to top
View user's profile Send private message Visit poster's website
raalpha9
Just Arrived
Just Arrived


Joined: 12 Jun 2004
Posts: 0
Location: Tasmania Australia

Offline

PostPosted: Sun Jan 14, 2007 1:58 am    Post subject: [Tutorial] Using XP's Disk Defragmenter Utility Reply with quote

Tom
I would like to experiment with the Page file defrag. you describe.
I have a "Pen Drive" as the alternative volume, would this be satisfactory or would the fact that it relies on the disc based drivers cause it to fail ?
I am using the XP operating system and the USB drive is 512 MB .
Back to top
View user's profile Send private message
Tom Bair
SF Boss
SF Boss


Joined: 10 Aug 2002
Posts: 16776955
Location: Portland, Oregon USA

Offline

PostPosted: Mon Jan 15, 2007 11:02 am    Post subject: Re: [Tutorial] Using XP's Disk Defragmenter Utility Reply with quote

raalpha9 wrote:
Tom
I would like to experiment with the Page file defrag. you describe.
I have a "Pen Drive" as the alternative volume, would this be satisfactory or would the fact that it relies on the disc based drivers cause it to fail ?
I am using the XP operating system and the USB drive is 512 MB .


You know, I just don't know. Technically, I don't recall any OP restrictions on USB drives as far as the paging file goes, but I'm sure you would see a major BSOD if you ever booted up without the USB drive in place -- the first time XP went to write to it.

I'd be interested in hearing of your experiences/research on this. I'd also suggest you do it on a spare PC or in a VPM environment.

Another question is, how slow will using a USB drive slow down your system?

Also, I do know that Windows versions do not support an either/or option for pagefiling. Many have wanted that for years, but MS will not implement such code at this time due to the extra boolean code to check which drive is being used for R/W ... plus it must be a continous file not divided between physical drives ... due to (again) the slowing down of the OS.

Let us know what you discover!

Tom
Back to top
View user's profile Send private message Visit poster's website
prateek-sri
Just Arrived
Just Arrived


Joined: 09 Jul 2010
Posts: 2


Offline

PostPosted: Fri Jul 09, 2010 11:24 pm    Post subject: reply Reply with quote

hello sir ..
i have a question which files get more fragmented ... smaller files or bigger ....

as i have a logical drive which have doc, rar, pdf , music(mp3 ) files and is never fragmented more than 15 % ..

and in a partition i have all my disk images mostly above 700mb, but that drive never reports fragments when i analyse it using defragment tool..

where as the drive which have all my virtual hard disk(.vhd file) created by virtual pc machine is nearly 98% fragmented ... and evry time i run fragmentation it again turn to same level of fragment after few days why this is so ....



1 more thing i have read in a forum to set the page file to delete every time system shutdown. as this will increase the system speed .. is it true ... ?
Back to top
View user's profile Send private message
capi
SF Senior Mod
SF Senior Mod


Joined: 21 Sep 2003
Posts: 16777097
Location: Portugal

Offline

PostPosted: Sat Jul 10, 2010 12:03 am    Post subject: Re: reply Reply with quote

prateek-sri wrote:
i have a question which files get more fragmented ... smaller files or bigger ....

The bigger the file, the greater the chance of it becoming fragmented. Files are divided into pieces ("clusters" or "blocks") when they are stored on the filesystem; the greater the file, the more pieces we need to store. The more pieces we need to store, the harder it is to find a single consecutive hole where they will all fit.


prateek-sri wrote:
where as the drive which have all my virtual hard disk(.vhd file) created by virtual pc machine is nearly 98% fragmented ... and evry time i run fragmentation it again turn to same level of fragment after few days why this is so ....

98% fragmented? Ouch!! Is this drive almost full? The defragmenter needs to have some free space in order to do its job properly. If the drive is almost full, the defragmenter won't be able to help much. My advice would be to move half of the files to another drive temporarily, defragment the drive, then move everything back. Then defragment again. Of course if the drive really is almost full, it will probably become fragmented again rather quickly as you create and erase temporary files and so on... But I doubt it'll get to 98% fragmentation very soon (unless you usually erase and create a lot of virtual hard disks).


prateek-sri wrote:
1 more thing i have read in a forum to set the page file to delete every time system shutdown. as this will increase the system speed .. is it true ... ?

I see no reason to do this, apart from privacy reasons where you might want to wipe the pagefile to make sure no one recovers information about what you were doing. Deleting the pagefile on system shutdown certainly won't speed anything up. It might in fact slow things down, since every time you create the pagefile again, there's the probability of it becoming fragmented.

Your best bet for speed and performance is to set the pagefile to a fixed size, large enough to accommodate your needs (growing and shrinking the pagefile just makes it much more likely that it will fragment). Just follow Tom's guide above so that when you create the pagefile, it is contiguous. As for the size, aim for 1.5 times your RAM size, but anything over 4 GB is probably more than you'll ever need.

Incidentally, you can and should defragment the Windows pagefile. Winternals's Mark Russinovich created a great little tool called PageDefrag, which does exactly that. It is now an official Microsoft utility, ever since Microsoft bought Winternals.

As I said above, as long as you set the pagefile to a fixed size, and defragment it the first time, it will never become fragmented again.
Back to top
View user's profile Send private message
prateek-sri
Just Arrived
Just Arrived


Joined: 09 Jul 2010
Posts: 2


Offline

PostPosted: Sat Jul 10, 2010 12:51 am    Post subject: Reply with quote

yes the drive with virtual hard disk is almost full ,12 % is free i.e 1.3gb ..
and i dont delete hard drive very frequently ...

image for the result of drive -

http://tinypic.com/r/2l3xhx/3

if bigger files get fragmented then why the disk images (.iso , uif, nrg etc in my case ) don't get fragmented .

link for the drive that contains images only .

http://tinypic.com/r/2l3xhx/3

i use periform defragger software . its free so i used it ...

thnx for reply

prateek
Back to top
View user's profile Send private message
prateek-sri
Just Arrived
Just Arrived


Joined: 09 Jul 2010
Posts: 2


Offline

PostPosted: Sat Jul 10, 2010 12:55 am    Post subject: Reply with quote

sorry the second image link isnt correct

plz refer
http://tinypic.com/r/984ylv/3
Back to top
View user's profile Send private message
capi
SF Senior Mod
SF Senior Mod


Joined: 21 Sep 2003
Posts: 16777097
Location: Portugal

Offline

PostPosted: Sat Jul 10, 2010 1:37 am    Post subject: Reply with quote

prateek-sri wrote:
if bigger files get fragmented then why the disk images (.iso , uif, nrg etc in my case ) don't get fragmented .

Files can only get fragmented when they are written -- either because you edited it and saved it on top, or appended something to the file, or because you moved it from one drive to the other, and so on. ISOs don't normally change so they won't get any more fragmented than they already are.

That said, and looking at the images... That 98% is basically the program being alarmist. You have 5 files, one of which is divided into 32 separate fragments. The other files are divided in 3, 4, 6 and 6 fragments. I wouldn't worry about it too much. The sample size is small, so any minor fragmentation becomes a large percentage. The one file I'd worry about the most would be "xp1 Hard Disk"... at 32 fragments, it could certainly be better.

The problem here is simple: you have several large files and not enough free space. Whenever one of the files needs to grow, it will have to grow to the next available free "hole". As I said, files only get fragmented when they are written.

You might be able to avoid this fragmentation by telling Virtual PC to preallocate the necessary space for the virtual hard drives, instead of growing them on the fly. I don't really use Microsoft Virtual PC, though, so I don't know if it even supports doing that. If it does, you could enable it, then defragment the drive once and there shouldn't be any further fragmentation.
Back to top
View user's profile Send private message
prateek-sri
Just Arrived
Just Arrived


Joined: 09 Jul 2010
Posts: 2


Offline

PostPosted: Mon Jul 12, 2010 1:54 am    Post subject: Reply with quote

ok i got it sir ..

actually i have created each hard disk on virtual pc with 5 gb space and i have left the option to increase the capacity in future open ..

everytime i save something in the harddisk(virtual ) its size increases and as the place left is not much to have continues locations it results in fragmentation ..

thank you for your time ..

prateek
Back to top
View user's profile Send private message
orange47
Just Arrived
Just Arrived


Joined: 04 Nov 2010
Posts: 0


Offline

PostPosted: Fri Nov 05, 2010 12:46 pm    Post subject: Reply with quote

it might be a good idea to choose bigger block size when formatting disk.
esp if files are big (movies). the way I see it, it should be less fragmented with smaller total number of blocks.

there are many defrag utilities, here is a good one, free: http://www.mydefrag.com/

I use bartpe.iso to boot so it can defrag all files.


or just get SSD and forget about all this Wink
Back to top
View user's profile Send private message
orange47
Just Arrived
Just Arrived


Joined: 04 Nov 2010
Posts: 0


Offline

PostPosted: Mon Nov 15, 2010 10:51 am    Post subject: Reply with quote

well, you gotta be patient. having a lot of RAM helps speed up defragmenting. (also, it would be a good idea to check RAM beforehand, for obvious reasons).
so close all other programs before it.
if you do it regularly, it shouldn't take so long.

might be a good idea to first delete all temp(orary) files, clear browser cache, etc.. and run 'chkdsk /f'

and uninstall all stuff you don't really need.

the fewer the files, the quicker it gets, obv.
Back to top
View user's profile Send private message
orange47
Just Arrived
Just Arrived


Joined: 04 Nov 2010
Posts: 0


Offline

PostPosted: Tue Nov 16, 2010 9:21 am    Post subject: Reply with quote

oh, that is normal for virtual drive to grow after defrag. you need to use program called sdelete, like this:
sdelete -z c:

(its from sysinternals, available on microsoft site. there are many other similar utils)

to wipe clean unused space (zero it). you'd need to do it anyway after some time as normal usage also makes virtual drive grow. (because deleted files are not wiped)

it might be a good idea to use sdelete even on real (nonvirtual) drive. because if one day (god forbid) something bad happens to filesystem, you might need to salvage data. in that case it helps if there is only one copy of data block. defragmenting will leave many of them marked 'deleted'. just be extra careful not to wipe used files or whole drive, it cannot be undone!

edit: newer versions of sdelete require using parameter '-z' instead of '-c', so I corrected it.


Last edited by orange47 on Fri Dec 23, 2011 3:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
krep
Just Arrived
Just Arrived


Joined: 18 Nov 2010
Posts: 0


Offline

PostPosted: Thu Nov 18, 2010 5:50 pm    Post subject: Reply with quote

I think these days defragging has become real easy. There's not much to do other than installing an automatic defragmenter, configuring it once and letting it do its work in the background automatically when required. The good utilities defrag the page file, mft, defrag in low space etc, so there's no need to jump through hoops to find workarounds for the windows defragger's shortcomings. Smile
Back to top
View user's profile Send private message
Display posts from previous:   

Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Windows All times are GMT + 2 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Looking for more Windows Networking info?

Sign up to the WindowsNetworking.com Monthly Newsletter, written by Enterprise Security MVP Deb Shinder, containing news, the hottest tips, Networking links of the month and much more. Subscribe today and don't miss a thing!
View a sample newsletter.

Become a WindowsNetworking.com member!

Discuss your Windows Networking issues with thousands of other Windows Newtorking experts. Click here to join!

Community Area

Log in | Register

Readers' Choice

Which is your preferred data recovery solution?

Follow TechGenix on Twitter