Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Defragmenting files


  • Please log in to reply
11 replies to this topic

#1 mangosteen

mangosteen

  • Members
  • 48 posts
  • OFFLINE
  •  
  • Local time:06:13 PM

Posted 21 November 2004 - 10:03 AM

Hello,
My Norton Utilities Speed Disk says I have 20 % fragmented files on my C:.
Running the defragmenting takes forever on my 40g hdisk.
And I still have D: and E: partitions to worry about.

Questions :
1) Will any data lost occur if there is a sudden blackout during defragmenting ?
2) Is there any program that defrags only those most fragmented files instead
of the whole disk ?
(But then again I won't know where the most fragmented files are located, will
I ?)

Thank you very much.
Let's stay happy and healthy.

BC AdBot (Login to Remove)

 


#2 JEservices

JEservices

    helping hand


  • Members
  • 1,700 posts
  • OFFLINE
  •  
  • Location:Texas
  • Local time:04:13 AM

Posted 21 November 2004 - 11:45 AM

Excellant questions on defragging!

For me to explain why you defrag, you need to know a little bit about how hard drives store information. When you save information on the HD(Hard Drive), Windows needs to use the fastest way possible of being able to retrieve the information. Most of the time, it will not be the most effienct and may even have wasted space. Picture if you will, bolt cases-the one that has alot of small boxes. When you get a handful of bolts that you will use again later, to make it easier to find the exact one, you have to seperate them. You put one type of bolt in one box, and another type in a different box, and label the outside of each box with the size. When you get another type of bolt that does not match either of these, you have to put it in another box; and so on, until you have all the different kinds in its own box. When you have more of the same bolt size, you simply add it to the box that you already have set aside of it. When you want a specific kind, you can read the labels, open the box, and get the bolt that you need without having to look at it. Even though you used some extra time to have them seperated, you save alot of time for not having to look at all the bolts many times. When you have used up all of one kind of bolt, you will have an empty bin. You have a choice: either take the label off and re-use it for another size, or leave it empty. HDs use very similar format on saving information. They have bolts(called bytes), boxes(called sectors), box labels(similar to file system: WIN 3x/95 calls it FAT16, WIN 98*Grinler uses FAT32, and WIN NT/2000/XP has NTFS)and even groups of bin boxes(called clusters). Even if you personally do not move, copy or delete files, Windows does it all the time. So much, that you probably do not even notice, unless you start seeing that you are running out of space.

You may be thinking, I have been erasing files, restarted the computer, and when I defrag, I have all of these holes-why is that? Each file will take up space on your HD. Depending on the size in bytes of the file, it could take up many clusters. The holes that you see when defragging (either by Speed Disk, or Windows defrag program) show you the empty clusters. When you defrag, the program looks at the HD to see what has been recently opened up, and moves it to the empty spaces. I am not exactly sure how Speed Disk works, but I know that Windows Defrag likes to move the recent files closer to the system files. Because these applications work differently, it is highly recommended NOT to switch between them: if you use Speed Disk, continue to use it; if you use Windows Defrag, continue using that one.

My Norton Utilities Speed Disk says I have 20 % fragmented files on my C:.
Running the defragmenting takes forever on my 40g hdisk.
And I still have D: and E: partitions to worry about.

Questions :
1) Will any data lost occur if there is a sudden blackout during defragmenting ?
2) Is there any program that defrags only those most fragmented files instead
of the whole disk ?
(But then again I won't know where the most fragmented files are located, will
I ?)



It is recommended that you use Speed Disk in Safe Mode. You can click Bleeping Computer Safe Mode tutorial for directions on how to get into Safe Mode. When you restart your computer, you may find that it is a little bit slower then usual, but that it primarilly because the first restart after defragging in Safe Mode, it is rewriting the locations of start up programs. A second restart will remedy this situation.

You said that it takes a long time to defrag your HD. The reason is probably because you have not done it in a while. I would recommend that you start it before you go to sleep. Under some circumstances, it it normal for it to take 10-12 hours to finish. In the rare case that your screen saver comes up in Safe Mode, disabling it will help it finish properly.

One of the reasons why it takes so long to defrag is because it re-writes the location of the information. To prevent errors from occurring, it may move it several times before it finds the final 'resting place'. Each time it is moved, it needs to put a label on it for location, and erase the previous location. This is why the more spare room you have before you defrag, the faster it is. It will allow it a bigger area to store information for a short time. At bare minimum, I would empty the recycle bin before you begin the defrag program.

There may be a program that will only defrag a portion of the HD at a time, but I would not recommend it. For the program to get a better picture of the space that you have, it needs to see all of it. It sounds like you have your primary HD partitioned (C: D: E:). All defrag programs can defrag these seperately because when you partion a HD, it acts like seperate ones. To save it from doing all of them at one time, you should be able to tell it to do only one of them.

I hope that this helps. If you have any questions, feel free to ask.
We are all curious like a cat. We wonder, we ask, we learn.
Please post back when a suggestion works, so that others may learn.

#3 tg1911

tg1911

    Lord Spam Magnet


  • Members
  • 19,274 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:SW Louisiana
  • Local time:04:13 AM

Posted 21 November 2004 - 01:15 PM

JEservices,

Great HD/Bolt Box analogy.
Can't explain it much easier than that.
MOBO: GIGABYTE GA-MA790X-UD4P, CPU: Phenom II X4 955 Deneb BE, HS/F: CoolerMaster V8, RAM: 2 x 1G Kingston HyperX DDR2 800, VGA: ECS GeForce Black GTX 560, PSU: Antec TruePower Modular 750W, Soundcard: Asus Xonar D1, Case: CoolerMaster COSMOS 1000, Storage: Internal - 2 x Seagate 250GB SATA, 2 x WD 1TB SATA; External - Seagate 500GB USB, WD 640GB eSATA, 3 x WD 1TB eSATA

Become a BleepingComputer fan: Facebook

#4 Scarlett

Scarlett

    Bleeping Diva


  • Members
  • 7,479 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:As always I'm beside myself ;)
  • Local time:05:13 AM

Posted 21 November 2004 - 01:46 PM

Wonderfully put JE!
Posted Image

#5 JEservices

JEservices

    helping hand


  • Members
  • 1,700 posts
  • OFFLINE
  •  
  • Location:Texas
  • Local time:04:13 AM

Posted 21 November 2004 - 01:59 PM

Thanks for the support. It is the same analogy that I am using for my up coming tutorial on hardware. I have been working on it for quite some time, and hope to have it posted soon.
We are all curious like a cat. We wonder, we ask, we learn.
Please post back when a suggestion works, so that others may learn.

#6 mangosteen

mangosteen
  • Topic Starter

  • Members
  • 48 posts
  • OFFLINE
  •  
  • Local time:06:13 PM

Posted 22 November 2004 - 12:17 AM

Thank you very much JE.

A very creative way you have there. Beautifully explained.

But I think you missed out one of my questions.
Will I lose any data if blackout / power failure occurs during defragmenting ?

Thanks again.
Let's stay happy and healthy.

#7 phawgg

phawgg

    Learning Daily


  • Members
  • 4,543 posts
  • OFFLINE
  •  
  • Location:Washington State, USA
  • Local time:02:13 AM

Posted 22 November 2004 - 12:30 AM

Will I lose any data if blackout / power failure occurs during defragmenting ?

my understanding of it is that the defrag will simply not be as complete, and starting over after a blackout will result in it taking less time. I base that on trial & error done in winXP. I've defragged like you after say 13%. took several hours. Checked the "report", saw a few left-overs, and did it again. Done with clean slate in 10 minutes. I've also shut it down, out of necessity. No ill effects, and I have one more thing to say. I defrag whether it says it needs it or not. Also, I have small partitions... a 40GB drive with a 13GB/13GB/13GB that makes defrag now done in under 15 minutes. Other factors are involved, I also have a 120GB drive with a 14GB partition for OS, and 100GB for data. The 100GB doesn't get used for anything but data files, and the need to defrag is less 'cause I don't move them a lot & the add/remove programs and updating + the actions of the anti-virus & anti-malware are what stirr up those nuts & bolt bins more than simple storage does.

Edited by phawgg, 22 November 2004 - 12:31 AM.

patiently patrolling, plenty of persisant pests n' problems ...

#8 mangosteen

mangosteen
  • Topic Starter

  • Members
  • 48 posts
  • OFFLINE
  •  
  • Local time:06:13 PM

Posted 22 November 2004 - 12:37 AM

Hi JE,
More questions for you.

1) Each file is put into a corresponding box/cluster depending on its size.
Isn't there only one size for all the clusters within a particular Windows ? Or
are there many clusters' sizes ?
2) Assuming the cluster has many sizes, what will happen if a file is simply
bigger than the biggest cluster size ? (Like a movie) Will it be split into
several accommodating smaller parts ?
3) Do all files coming from a same program kept in adjacent clusters ?

Thank you very much.
Let's stay happy and healthy.

#9 mangosteen

mangosteen
  • Topic Starter

  • Members
  • 48 posts
  • OFFLINE
  •  
  • Local time:06:13 PM

Posted 22 November 2004 - 12:41 AM

Thanks phawgg.
Let's stay happy and healthy.

#10 JEservices

JEservices

    helping hand


  • Members
  • 1,700 posts
  • OFFLINE
  •  
  • Location:Texas
  • Local time:04:13 AM

Posted 22 November 2004 - 10:49 AM

I will tackle them separately to make sure that I don't miss one this time. Sorry about that.


Will I lose any data if blackout / power failure occurs during defragmenting ?



When you are defragging, the program makes a copy of the file, before it actually moves it. Then, to assure that the copy is identical, it will compare the copy to the original. When it sees that they are identical, it will erase the original. When it sees another spot for it to be move to, it does the same thing (copy, compare, then erase) again. Although it is possible that information can be damaged if the power goes out during defragging, it is very unlikely. The possibility of file damage is actually less when defragging (compared to normal operations), because of the back-up copies that it makes.


1) Each file is put into a corresponding box/cluster depending on its size.
Isn't there only one size for all the clusters within a particular Windows ? Or
are there many clusters' sizes ?



When Windows formats a HD, it will make the sectors a set size, usually 256 or 512 bytes each, and a set number of sectors together as clusters. When a file take up more room then one sector (over 95% of the files will), then it will continue using as many sectors as needed until the entire file is finished. To keep the entire file together as much as possible, the Operating System (OS) or Windows, will tell the file where the next sector is that can be used. To keep the filing system as consistent as possible, 2 files can not occupy the same sector. If a file does not need all of the space allocated for the sector, then it is wasted space.

To see this on your computer, take any file (its easier if you do not use a shortcut icon) on your desktop, right-click and select properties. On the General tab, about half way down, you will see size and size on disk. Size is the physical amount of space that it is actually using; size on disk is the amount of space that it is using on the HD, in sectors. Take the amount from size on disk, and you will see that it is divisible by 256 (Windows 3.x, 95/98 and I think ME) or 512 (Windows NT, XP, and I think 2K).


2) Assuming the cluster has many sizes, what will happen if a file is simply bigger than the biggest cluster size ? (Like a movie) Will it be split into
several accommodating smaller parts ?



All of the clusters are the same size. When a file needs more then one sector to finish saving, Windows keeps track of the "directions" to the location of the remainder of the file. This file system is like the labels that I mentioned in the other message. In the case that it needs more then one cluster to finish saving, it will use the same system to remember the directions. When you defrag your hard drive, it will move the files, that are used the most, closer to the System files. This is the speed difference that you will see when it finishes defragging.



3) Do all files coming from a same program kept in adjacent clusters ?



Incidentally, you may not know how a HD actually works. It has many platters, with a read/write head on each one, on both sides of each platter. Take 3 pieces of paper and stack them together. Put a finger from one hand, in between each piece, including one on top and one on bottom, in the corner, for as far as your fingers will go. The papers are the platters, your fingers are the arms, and the fingertips are the read/write heads. Now, hold the opposing corner with your other hand and turn the paper. You will see that you have to move all of the pages at the same time. The same is true for the HD platters. Because all of the platters rotate on the same point, they can not turn independently. The same is true for the arms-they all turn on the same axis, where they are all physically connected together. Even though you can move each finger (and each joint) by itself, keep each one straight and just move your wrist.

When I mentioned about linking clusters closer together (in the case that a file requires more then one cluster), it does not necessarily mean that they will be on the same platter. Because of having the rotation of the platters, the movement of the arms back and forth, the closest cluster could actually be on another platter. Just in the paper/hand example, if you can read/write several different platters at the same time, the fastest way to save information after a cluster is full, may be to continue to another platter, without having to move either the arms or the platters. Granted the HD rotation of the platters and the arms are so fast that they can not be seen easily with the eye. Curious to know how fast? A standard speed is 5400 RPM (Rotations Per Minute) refers to the platters. There are some that go even faster-as much as 10,000 RPM.
We are all curious like a cat. We wonder, we ask, we learn.
Please post back when a suggestion works, so that others may learn.

#11 JackTheHaack

JackTheHaack

  • Members
  • 307 posts
  • OFFLINE
  •  
  • Location:Queensland, Australia.
  • Local time:08:13 PM

Posted 22 November 2004 - 02:47 PM

Kudos to you Jason. :flowers:

What a great post.

High grade knowledge, good stuff.

JTH :thumbsup:
JTH

#12 mangosteen

mangosteen
  • Topic Starter

  • Members
  • 48 posts
  • OFFLINE
  •  
  • Local time:06:13 PM

Posted 23 November 2004 - 07:42 AM

Hello Jason,

Firstly, don't say sorry. You did me a great deal of help. I should be sorry for troubling you and the others with so many questions.

Secondly, thank you very-very much. It is a very valuable knowledge. A lot of people just use the computer without bothering what's behind it. It is definitely good to know, in theory at least.

Thank you all.
I am deeply grateful.
Let's stay happy and healthy.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users