How to fully consolidate free space on a defragmented HD

My scenario:

  • My HDD is fully defragmented and must be kept defragmented.
  • Free space must be fully defragmented (no small gaps) so when copying new files with iso2opl they aren't fragmented.

I think the only solution is to make the existing files "slide" toward the beginning of the disk.

Options I've already discarded:

  • Defrag the new files after they are copied (can't do that when disk free space is below 10%)
  • Reformat the HDD and copy all the files over (it's slow and I don't have another HDD free for the process)
  • jkdefrag -a 5 "Force together" (create fragments)
  • MyDefrag "Consolidate Free Space" script (will create fragments)
  • Defraggler (will only move whole files if they fill the free blocks)

Options I'm considering:

  • dirms "Compact" mode (documentation not totally clear)
  • Auslogics Disk Defrag Free (documentation incomplete about free space consolidation)
  • VOPT Defragger "Tightest Packing" (documentation incomplete)

IMPORTANT EDIT: Forgot to mention my HDD is formatted in FAT32 and it is not a system drive!


Solution 1:

You may not be able to

If there are any unmovable files on the disk it is very likely that you will not be able to have both 100% defragmented files AND 100% defragmented free space at the same time. This is because the amount of space between unmovable files may not have any combination of your files that are the same length. Plus the unmovable files themselves may be fragmented.

From memory FAT32 stores its directory structure in unmovable files, though it has been a lot of years since I've really used FAT32. Yes a directory is stored as a file on the disk that essentially contains a list of the files and folders inside it and where on the disk each of them starts. As you add more files to a directory the size of the file storing the directory information grows. This can become fragmented. NTFS allows you to defragment the directory files too.

If this is also a system drive there will be some unmovable system files too. You can get around this by putting the disk in another system or booting up from another drive/cd/dvd/usb/etc.

The developer of jkdefrag renamed his product to MyDefrag. I know that the MyDefrag tool allows you to wrap a file around unmovable files, such that the free space is 100% consolidated, and all of the movable files on the disk are in sequential order, like defragmented files, but with the unmovable files in between segments of the file. This will show the files as fragmented, but reading them will still be very fast due to them being on the disk in sequence. Reading one of these files that wrap around the unmovable files will occur in sequential disk logical block address order but with a few gaps here and there. The length of time it takes a disk to skip reading some sectors is VERY short.

Edit: Also, just because there is open free space does not mean windows or for that matter Linux will use the space you expect in a sequential nature when adding new files. You may have to defragment anyway.