3.7. Cleaning Up a Volume


You want to clean up unused or unneeded files on a volume to reclaim space.


Using a graphical user interface

  1. Open Windows Explorer.

  2. Right-click the drive you want to clean up and select Properties.

  3. Click the General tab if it isn't opened by default.

  4. Click the Disk Cleanup button. Depending on the size of the volume you are scanning, this can take a while to complete.

  5. Under Files to delete, check the boxes beside the type of files you want to remove.

  6. When you are done with your selections, click OK.

  7. Click Yes to confirm that you want to delete the files.

Using a command-line interface

You can launch the Disk Cleanup tool from the command line by running the following command:

> cleanmgr

To target a specific drive, use the /d option:

> cleanmgr /d E:

You can automate the Disk Cleanup tool to run against all the drives on a system in a couple of steps. First, you need to configure the types of files you want to clean up. Run the cleanmgr utility with the /sageset: option following by an integer. The integer represents a Disk Cleanup profile. In the following example, I'll use 1:

> cleanmgr /sageset:1

This opens the Disk Cleanup Settings property page. Under Files to delete, check the boxes beside the types of files you want to clean up. Click OK when you are done. Now, use the /sagerun: option followed by the same number we just used (1 in this case):

> cleanmgr /sagerun:1

This command enumerates all drives on the system and performs a disk clean up according ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.