File System Fragmentation
As files are created, deleted, and modified over time, their size and physical location on the hard disk will change. If a file size needs to increase and the hard disk doesn't have room directly adjacent to the existing file, the file system automatically places the new portion of the file where it can find the room and then marks the necessary structures so that the file system can find the entire file when an application needs it. The file is now in two (or more) fragments.
Fragmentation is normal behavior and is completely transparent to both applications and users. The problem is that over time, more and more files become fragmented and even highly fragmented, increasing the amount of time that it takes for the hard disk controller to locate all of the fragments. Not only does this slow down file access, but it also places additional stress on the hard disk itself.
By default, Windows Vista and Windows 7 will defragment the hard drive at 1:00 A.M. every Wednesday. If the computer is off at this time, defragmentation will start shortly after the computer boots next. Ideally, defragmentation will run when the computer is not in use, minimizing the performance impact. However, the user impact is minimal because the defragmenter uses both low CPU priority and low-priority input/output (I/O).
Unlike earlier versions of Windows, Windows 7 recognizes solid-state drives (SSDs) and disables automatic defragmentation. Defragmentation does not improve the performance of SSDs and can decrease the lifetime of the SSD by unnecessarily reading and writing data.
Defragmentation Algorithm Improvements
Many systems administrators have been captivated by the graphical defragmentation displays in previous versions of Windows. You'll notice the graphics are gone in Windows Vista and Windows 7. Unfortunately, displaying the layout of files and highlighting files that had even one fragmentation made many performancefocused administrators obsessed with eliminating every single fragmented file.
Fragmentation does reduce disk performance, but having a few fragments in a large file doesn't make a difference-even years of reading and writing a large file with a single fragment would never add up to a significant amount of time. For this reason, Microsoft tweaked the defragmentation algorithm so that it does not defragment a file if a segment is longer than 64 MB. In those circumstances, the relatively significant effort required to rearrange files just to combine two 64-MB fragments isn't worth the effort, so Windows doesn't bother.
If you run a different defragmentation tool (including the defragmenter in Windows XP), those fragments will show up, and they'll probably look significant because the fragmented file is so large. (Typically, the entire file appears red if it has even a single fragment.) Trust the algorithm, though-a few fragments don't matter.
To defragment a file system or configure the automatic disk defragmentation schedule manually, follow these steps:
- Click Start and then click Computer.
- Right-click the drive and then click Properties.
- Click the Tools tab and then click Defragment Now. The Disk Defragmenter appears.
- In the Disk Defragmenter dialog box, click Defragment Disk to begin defragmentation.
You can continue to use the computer while defragmentation takes place, but it might be a little slower. You can also adjust the defragmentation schedule for a single computer from this interface.
For more complete control of defragmentation, you can use the command-line defragmentation tool, Defrag.exe, from an elevated command prompt. Defrag.exe has the following syntax, which has changed since Windows Vista.
Defrag <volume> | /C | /E <volumes> [/A | /X | /T] [/H] [/M] [/U] [/V]
The options for Defrag.exe are:
- <volume> The drive letter or mount point of the volume to defragment.
- /C Defragment all local volumes on the computer.
- /E Defragment all local volumes on the computer except those specified.
- /A Display a fragmentation analysis report for the specified volume without defragmenting
it. Analysis reports resemble the following.
Post Defragmentation Report: Volume Information: Volume size = 68.56 GB Free space = 58.78 GB Total fragmented space = 0% Largest free space extent = 31.64 GB You do not need to defragment this volume
- /X Perform free-space consolidation. Free-space consolidation is useful if you need to shrink a volume, and it can reduce fragmentation of future files.
- /T Track an operation already in progress on the specified volume.
- /H Run the operation at normal priority instead of the default low priority. Specify this option if a computer is not otherwise in use.
- /M Defragment multiple volumes simultaneously, in parallel. This is primarily useful for computers that can access multiple disks simultaneously, such as those using SCSIor SATA-based disks rather than disks with an IDE interface.
- /U Print the progress of the operation on the screen.
- /V Verbose mode. Provides additional detail and statistics.
In this tutorial:
- Managing Disks and File Systems
- Overview of Partitioning Disks
- How to Choose Between MBR or GPT
- Converting from MBR to GPT Disks
- GPT Partitions
- Choosing Basic or Dynamic Disks
- Working with Volumes
- How to Create a Simple Volume
- How to Create a Spanned Volume
- How to Create a Striped Volume
- How to Resize a Volume
- How to Delete a Volume
- How to Create and Use a Virtual Hard Disk
- File System Fragmentation
- Backup And Restore
- How File Backups Work
- File and Folder Backup Structure
- How System Image Backups Work
- How to Start a System Image Backup from the Command Line
- How to Restore a System Image Backup
- System Image Backup Structure
- Best Practices for Computer Backups
- How to Manage Backup Using Group Policy Settings
- Previous Versions and Shadow Copies
- How to Manage Shadow Copies
- How to Restore a File with Previous Versions
- How to Configure Previous Versions with Group Policy Settings
- Windows ReadyBoost
- BitLocker Drive Encryption
- How BitLocker Encrypts Data
- How BitLocker Protects Data
- TPM with External Key (Require Startup USB Key At Every Startup)
- TPM with PIN (Require PIN At Every Startup)
- TPM with PIN and External Key
- BitLocker To Go
- BitLocker Phases
- Requirements for Protecting the System Volume with BitLocker
- How to Enable the Use of BitLocker on the System Volume on Computers Without TPM
- How to Enable BitLocker Encryption on System Volumes
- How to Enable BitLocker Encryption on Data Volumes
- How to Manage BitLocker Keys on a Local Computer
- How to Manage BitLocker from the Command Line
- How to Recover Data Protected by BitLocker
- How to Disable or Remove BitLocker Drive Encryption
- How to Decommission a BitLocker Drive Permanently
- How to Prepare AD DS for BitLocker
- How to Configure a Data Recovery Agent
- How to Manage BitLocker with Group Policy
- The Costs of BitLocker
- Windows 7 Encrypting File System
- How to Export Personal Certificates
- How to Import Personal Certificates
- How to Grant Users Access to an Encrypted File
- Symbolic Links
- How to Create Symbolic Links
- How to Create Relative or Absolute Symbolic Links
- How to Create Symbolic Links to Shared Folders
- How to Use Hard Links
- Disk Quotas
- How to Configure Disk Quotas on a Single Computer
- How to Configure Disk Quotas from a Command Prompt
- How to Configure Disk Quotas by Using Group Policy Settings
- Disk Tools
- MoveFile and PendMoves