Freeing Up Space on the System Partition Using a Batch Script in Windows

If you’ve ever attempted to upgrade Windows and encountered an error stating there’s not enough space on the system partition (also called the EFI System Partition, or ESP), you’re not alone. This small but crucial partition—usually around 100MB—can quickly fill up, especially on systems with legacy setups or after several major OS upgrades.

One common culprit is the accumulation of font files in the EFI partition, specifically in the EFI\Microsoft\Boot\Fonts folder. While these fonts are used by the boot loader for displaying text during boot-time error screens, they are not critical for the average user under normal circumstances. If space is needed urgently to allow a Windows upgrade to proceed, you can safely remove these files temporarily.

This blog post outlines how to use a batch script to mount the system partition, navigate to the Fonts folder, and delete those files, creating just enough space to complete the upgrade.


⚠️ Important Warning
Modifying or deleting files from the EFI System Partition is potentially risky. Proceed only if you understand the implications, and make sure you have a full system backup. If you’re unsure, consult a professional or proceed manually and with caution.


Step-by-Step: Using a Batch Script

Here’s what the script does:

  1. Assigns a temporary drive letter to the system partition
  2. Navigates to the Fonts directory in the EFI folder
  3. Deletes all files in that directory
  4. Removes the temporary drive letter
  5. Reboots the system after the cleanup is complete

The Batch Script

@echo off
echo Mounting the EFI system partition...

:: Assign the EFI partition a drive letter (in this case, S:)
mountvol S: /S

echo Changing to the Fonts directory...
cd /d S:\EFI\Microsoft\Boot\Fonts

echo Deleting font files to free up space...
del *.*

echo Unmounting the EFI system partition...
mountvol S: /D

echo Cleanup complete. The system will now reboot in 60 seconds.
shutdown /r /t 60

How to Use the Script

  1. Open Notepad and paste the above script.
  2. Save the file as clear-efi-fonts.bat.
  3. Right-click the file and choose Run as administrator.
  4. Let the script run. Once it finishes, the system will automatically reboot after 60 seconds. Once the system comes back online, retry the upgrade.

If you still don’t have enough space, you may also want to clear out old EFI boot loaders or other unused boot resources, but only if you know what you’re doing. The Fonts folder fix usually frees up enough room for the upgrade to complete.


Why This Works

The system partition is used primarily during boot. Once the operating system is loaded, Windows doesn’t typically need the files inside the Fonts folder. The boot loader can still function without these fonts in many cases, and after the upgrade, they may be restored or reinstalled by Windows.

This method is especially useful on systems where resizing the EFI partition isn’t practical or where the OEM configuration has already allocated the minimum size (often 100MB).


After the Upgrade

Once your upgrade is complete, you may want to restore the font files. These are generally copied from system sources or can be extracted from installation media using tools like 7-Zip or from a healthy Windows installation.


Final Thoughts

This batch script provides a quick and simple solution to a frustrating problem, especially for IT professionals managing many machines or users stuck in upgrade limbo. While this isn’t the most elegant solution, it’s effective and often necessary when space on the system partition is tight.

Have you run into this issue? Do you use another method to free up space on the EFI partition? Let me know in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.