Image Management ServiceImage Management Service

Compute
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Anti-DDoS
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Compass
Cloud Certificate Manager
Anti-DDoS Service
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB NoSQL
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
ServiceStage
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
DevCloud
ProjectMan
CodeHub
CloudRelease
CloudPipeline
CloudBuild
CloudDeploy
Cloud Communications
Message & SMS
Cloud Ecosystem
Marketplace
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
enterprise-collaboration
Meeting
IoT
IoT
Intelligent EdgeFabric
DeveloperTools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Help Center> Image Management Service> Best Practices> Cleaning Up the Disk Space of a Windows ECS
Updated at: Feb 22, 2022 GMT+08:00

Cleaning Up the Disk Space of a Windows ECS

Scenarios

This section describes how to clean up the disk space of a Windows ECS.

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 release the disk space of the Windows OS.

In the following operations, 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 the 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 initiali size to xxx shown in the warning. The partition for storing paging files must have sufficient space. If the disk resources are insufficient, the virtual memory is insufficient. You only need to set the 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 virtual memory increases.

Disable Hibernation

In the following operations, 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 the hibernation function file of the Windows OS and occupies large system disk space. It saves memory data and sessions to disks so that the memory image file required for sessions can be quickly restored after the computer is restarted. Perform the following steps to delete the Hiberfil.sys file to release 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 is 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.

Deleting Internet Explorer Temporary Files

In the following operations, 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, recent browsing history, visited websites, URLs in the address bar, and Internet Explorer tables/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.

In the following operations, 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 the system startup and file reading. However, the number of files increases with time. Deleting redundant files can release disk space in 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 released. 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. In the following operations, 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 Adding 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 computer.

In the following operations, 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 on disk C to release 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.

In the following operations, 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 and system problems and can be used to monitor 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 the Windows stores the operation logs and event logs of Windows. Deleting the folder can free up the space of disk C.

In the following operations, 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. Chose 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.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel