C drive low disk space in Windows Server 2012 R2
The same with other versions, Low disk space is the most common issue in Windows Server 2012. Comparing with data drives, system C: drive is very likely running out of space. When there is not enough free space left in C drive, you’d better fix this issue as fast as possible. In this article, I’ll introduce how to create low disk space alert in Windows Server 2012 r2 and how to fix C drive low disk space issue fast and easily.
Overview:
Why C: drive runs low disk space in Server 2012 r2
In daily usage, many types of files can eat up free space in C drive, such as:
- Windows updates, system restore point, hibernation, paging file. These files are in large size, so they use up free space very quickly.
- Logs, temp, cache, browser .etc These files are in small size but more and more produced continuously.
- 3rd-party application files. All applications install to C drive by default, even if you install to other drive, some files go to C drive forcedly.
- All files deleted without pressing Shift go to Recycle Bin, which is in C drive.
Even if the C drive is created large to 100GB when building the server, it runs out of space sooner or later.
Risk of low disk space
When C drive is running low on disk space, you cannot install Windows updates or applications. Some Windows services such as backup and recovery stop working. It also cause operating system running much slower. Server stuck, reboot unexpectedly or even crash. So you’d better fix this issue as soon as possible, it is too late when C drive is getting full.
How to create low disk space alert in Windows Server 2012
You can setup a notification to alert when the disk drive runs low on disk space, example script as below:
$freespacethreshold = 17
# Setting path to servers.txt file for input later on…
$inputfilepath = $env:USERPROFILE + “\Desktop”
$inputfilename = “servers.txt”
$workingfile = $inputfilepath + “\” + $inputfilename
#does the file exist?
$fileexist = test-path $workingfile
if ($? -eq $false)
{
Write-Host “$inputfilename does not exist on $infputfilepath” -ForegroundColor Red -BackgroundColor Black
Write-Host “Please Create the file with one server per line that you want checked” -ForegroundColor Red -BackgroundColor Black
exit 1
}
#read the file into a variable for later processing
$servers = Get-Content $workingfile
# Step 1 this is to check the disk space and alert if their is 10% or less free
foreach ($s in $servers)
{
$logicaldisks = Get-WmiObject -ComputerName $s Win32_Logicaldisk
Foreach ($l in $logicaldisks)
{
$totalsize = $l.size
$freespace = $l.freespace
if ($freespace -gt 0)
{
$percentagefree = ($freespace / $totalsize ) * 100
Write-Host $l.deviceid ” has ” $percentagefree “% free”
if ($percentagefree -lt $freespacethreshold)
{
Write-Host “Health Alert!” -ForegroundColor Red -BackgroundColor Black
Write-Host “Drive ” $l.deviceid ” has less the $freespacethreshold % free”
}
}
}
}
You may schedule the low disk space alert script or create an email notification.
How to fix C drive low disk space in Windows Server 2012 R2
To solve this problem, you may find many methods after searching by Google. If you have plenty of time, you may try them all. In fact, many of the methods do little help, but you can solve this problem fast and easily with 2 methods below.
1. Clean up C drive to reclaim disk space
There are many junk and unnecessary files in C: drive. You can remove these files to get more free space. To accomplish task, it is suggested to run Disk Cleanup, which is provided by Microsoft. This tool is safe and fast to delete junk and unnecessary files from your server.
Unlike other versions, Disk Cleanup is not enabled by default in Windows Server 2012 and R2. Therefore, you need to follow the steps to enable Disk Cleanup in Server 2012 in advance.
How to fix low disk space in Windows Server 2012 r2 by cleaning up C drive:
- Press Windows + R together on the keyboard, type cleanmgr and press Enter.
- C: drive is selected by default, simple click OK to continue.
- Click the check-box in front of the files that you want to remove. All files can be deleted safely. However, it is still suggested to read corresponding description on the bottom.
- Confirm the deletion.
- Repeat from step 1 to clean up system files.
Disk Cleanup is usefull especially if you never did this before. But if you cannot get over 20GB free space, you’d better move free space from other partition.
2. Move more free space to C drive
With safe partition software, you can change size of allocated partition without losing data. Shrink a data volume to release free space and transfer to C drive. In this way, you’ll get a larger C drive and everything keeps the same with before.
Better than other tools, NIUBI Partition Editor has Virtual Mode, Cancel-at-well, 1-Second Rollback and Hot Clone technology to protect system and data. Another benefit is that it is much faster when shrinking and moving partitions.
How to fix C drive low disk space in Windows Server 2012 R2 completely:
Step 1: Download NIUBI Partition Editor, right click D: drive and select “Resize/Move Volume“.
Step 2: In the pop-up window, drag the left border rightwards to shrink D drive and make unallocated space on the left.
You may also input a value for the unallocated space directly.
Click OK and back to the main window, unallocated space is made behind C drive in virtual mode.
Step 3: Right click C: drive and run “Resize/Move Volume” again, drag the right border rightwards to add this unallocated space.
Step 4: Click OK and back to the main window. To change real disk partitions, you need to click Apply to confirm.
How to add more free space to C drive:
Besides shrinking and extending partition to move free space, NIUBI Partition Editor helps you do many other disk partition management operations such as merge, clone, convert, hide, defrag, wipe partition, optimize file system, scan bad sectors and much more.