Help Center/ Image Management Service/ Best Practices/ Cleaning Up the Disk Space of a Windows ECS
Updated on 2023-06-09 GMT+08:00

Cleaning Up the Disk Space of a Windows ECS

Scenarios

To clean up the disk space of a Windows ECS, you need to perform the following operations.

Disable Virtual Memory

Some disk space of an ECS serves as virtual memory which can be used when the ECS memory is exhausted. However, when the memory usage is high, frequent switching between the memory and virtual memory causes a large number of extra I/Os, which deteriorates the I/O performance. Therefore, you can disable virtual memory to free up disk space on Windows.

An ECS running Windows Server 2008 R2 Standard 64-bit is used as an example to describe how to disable virtual memory.

  1. Right-click the Computer icon and choose Properties. In the displayed window, click Advanced System Settings.
  2. In the System Properties dialog box, click the Advanced tab.
  3. Click Settings in the Performance area.
  4. In the displayed Performance Options dialog box, click the Advanced tab and then Change. The Virtual Memory dialog box is displayed.
  5. Delete virtual memory.

    In the Virtual Memory dialog box, deselect Automatically manage paging file size for all drives, select the paging file of the disk whose virtual memory is to be deleted, select No paging file, and click Set.

    If the warning "If you disable the paging file or set the initial size to less than xxx megabytes and a system error occurs, Windows might not record details that could help identify the problem. Do you want to continue?" is displayed, set the initial size to xxx shown in the warning. The partition for storing paging files must have sufficient space. If the disk resources are insufficient, virtual memory will be insufficient. You only need to set virtual memory in one partition of the ECS.

  6. Choose Start > Control Panel > Appearance and Personalization > Show hidden files and folders. The Folder Options dialog box is displayed. Click the View tab, deselect Hide protected operating system files (Recommended), and select Show hidden files, folders, and drives. When you deselect Hide protected operating system files (Recommended), a warning is displayed, as shown in Figure 1. Click Yes and then click Apply.
    Figure 1 Warning
    Figure 2 Showing hidden files
  7. After file hiding is disabled, delete the hidden file pagefile.sys from disk C. After the OS is restarted, the available space increases.

Disable Hibernation

An ECS running Windows Server 2008 R2 Standard 64-bit is used as an example to describe how to disable hibernation.

Method 1: Delete the Hiberfil.sys file.

The Hiberfil.sys file is generated by Windows hibernation and occupies large system disk space. It saves memory data and sessions to disks so that the memory image file required by sessions can be quickly restored after the computer is restarted. Perform the following steps to delete the Hiberfil.sys file to free up some disk space:

  1. Run cmd.exe as an administrator to open the command line interface (CLI).
  2. Run the following command to disable hibernation (Hiberfil.sys file will be automatically deleted):

    powercfg -h off

Method 2: Disable hibernation.

  1. Choose Start > Control Panel > Appearance and Personalization > Personalization > Change screen saver and click Change plan settings.
  2. In the Power Options window, click Change plan settings on the right of Balanced (recommended).
  3. Set Turn off the display to Never.

Delete Internet Explorer Temporary Files

An ECS running Windows Server 2008 R2 Standard 64bit is used as an example to describe how to delete temporary files generated by Internet Explorer.

Internet Explorer stores all information about Internet access in a specified folder, including Internet Explorer cache files, cookies files, browsing history, visited websites, URLs in the address bar, and Internet Explorer forms/passwords. Perform the following steps to delete temporary files generated by Internet Explorer:

  1. Choose Start > Control Panel > Network and Internet > Internet Options. Click Delete browsing history and cookies to delete cookies and temporary files of Internet Explorer.

  2. After the preceding step is performed, there may be residual files or records left. Open the C:\Windows\temp and C:\Users\Username\AppData\Local\Temp folders and delete all files in them. (The folders store visited websites and other temporary information.)

Disable Data Execution Prevention (DEP)

DEP reserves a part of ECS memory for temporarily storing application data and another part of memory for temporarily storing application instructions. This protects ECSs from viruses and other security threats.

An ECS running Windows Server 2008 R2 Standard 64-bit is used as an example to describe how to disable DEP.

  1. Right-click the Computer icon and choose Properties. In the displayed window, click Advanced System Settings.
  2. In the System Properties dialog box, click the Advanced tab.
  3. Click Settings in the Performance area.
  4. In the Performance Options dialog box, click the Data Execution Prevention tab, select Turn on DEP for essential Windows programs and services only, and click Apply.

Delete Redundant Application Files

The C:\Windows\prefetch folder stores the index files generated by applications. The files are used to improve system performance and speed up system startup and file reading. However, the number of files increases with time. Deleting redundant files can free up disk space on Windows.

Delete all files in the C:\Windows\prefetch folder to delete redundant application files.

Clean Up Disks

You can use Disk Cleanup of ECSs to delete temporary files, empty the recycle bin, and delete redundant system files and other files.

On the ECS, click Start. In the search box, enter Disk Cleanup. Click the displayed Disk Cleanup to scan for the space that can be freed up. After the scan is complete, confirm the files to be deleted and click OK to start disk cleanup.

If Disk Cleanup is unavailable, you need to install Desktop Experience first. An ECS running Windows Server 2008 R2 Standard 64bit is used as an example to describe how to install Desktop Experience.

  1. Choose Start > All Programs > Administrative Tools > Server Manager. In the navigation pane, click Features.
  2. Click Add Features.
  3. In the Select Features dialog box, select Desktop Experience and click Next.
    Figure 3 Installing Desktop Experience
  4. In the Confirm Installation Selections dialog box, confirm the installation of Desktop Experience, and click Install.
  5. When the installation progress reaches 100% in the Results dialog box, the system prompts you to restart the server. Click Close, and then click Yes to restart the server.
  6. After the server is restarted, start the server manager. In the Function Summary area, check whether Desktop Experience is installed.
    Figure 4 Successful installation of Desktop Experience
  7. Choose Start > All Programs > Accessories > System Tools > Disk Cleanup to start the disk cleanup tool.

Defragment and Optimize Drives

Disk defragmentation is a process in which system software or professional disk defragmentation software is used to organize the fragments generated during the long-term use of disks into the smallest number of contiguous fragments, improving the performance and running speed of the server.

An ECS running Windows Server 2012 R2 Datacenter 64bit is used as an example to describe how to defragment and optimize drives.

  1. Choose Control Panel > All Control Panel Items > Administrative Tools, and double-click Defragment and Optimize Drives.

  2. Select the disk partition to be optimized, and then click Analyze to analyze whether the disk partition needs to be optimized. If the analysis result indicates that optimization is necessary, click Optimize.

Delete .dmp Files

When a blue screen of death (BSOD) occurs on a Windows ECS, the system automatically generates a BSOD error file with the suffix .dmp. A .dmp file is a system error file in Windows, such as, memory.dmp and minixxxx.dmp.

You can manually delete .dmp files from disk C to free up system disk space.

After the .dmp file is deleted, the BSOD cause on the ECS cannot be queried.

Clean Up Component Store

Windows Component Store stores all the files required for installing Windows. Updated installation files are also stored in Component Store, which causes the size of Component Store to increase as the update increases.

An ECS running Windows Server 2012 R2 Datacenter 64-bit is used as an example to describe how to clean up Component Store.

  1. In Windows PowerShell, run the following command to delete the backup files generated during the Service Pack installation:

    dism /online /cleanup-image /spsuperseded

  2. Run the following command to check the size of Component Store:

    Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore

  3. Run the following command to clean up Component Store:

    Dism.exe /online /Cleanup-Image /StartComponentCleanup

Delete System Logs

System logs record hardware and software information, system problems, and system events. You can use the logs to locate error causes or track attacker actions. System logs include application logs, security logs, startup logs, and event forwarding logs. The System32 > LogFiles folder on disk C of Windows stores the operation logs and event logs of Windows. Deleting the folder can free up the space of disk C.

An ECS running Windows Server 2008 R2 Standard 64-bit is used as an example to describe how to delete system logs.

  1. Open the C:\Windows\System32\LogFiles folder, and delete all the files and folders in it.

  1. Choose Start, right-click Computer, and choose Manage in the shortcut menu.
  2. In the displayed window, choose Diagnostics > Event Viewer > Windows Logs and delete logs of Application, Security, Setup, System, and Forwarded Events.