When your computer starts running slower, it could be due to low disk space. This guide shows you how to configure a Windows script to monitor your disk space and send email alerts when the available space is low, preventing system slowdowns.
Setting up a Windows script to check your disk space regularly can help you avoid issues like system slowdowns and crashes due to low storage. Here's a simple script that checks your disk space and sends an email alert when it's about to run out.
This solution involves creating a script that checks your hard disk space, and sends you an email notification when the disk usage exceeds a certain threshold (e.g., 90%). Follow the steps below:
Create a script file with the following content. You can save it as check_disk_space.sh in your home directory:
#!/bin/bash CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g') THRESHOLD=90 if [ "$CURRENT" -gt "$THRESHOLD" ] ; then mail -s 'Disk Space Alert' youremail@example.com << EOF Your root partition remaining free space is critically low. Used: $CURRENT% EOF fi
To ensure that the script runs daily, you need to add it to your system's cron job scheduler. Open the /etc/crontab file and add the following line at the end:
@daily ~/check_disk_space.sh
Remember to replace youremail@example.com with your actual email address. The script is configured to send an alert if disk usage exceeds 90%. You can adjust this threshold if needed.
Also read: How to enable and disable Windows low disk space warnings
If you receive a low disk space alert, it means your system drive (usually C:) is more than 90% full. Here are some actions you can take to free up space and prevent performance issues:
The first step is to clean up unnecessary files that are taking up space. You can start by:
Note: Windows built-in tools can work if there is unallocated space adjacent to the partition you want to extend. If there is another partition or the recovery/oem partition stand in the way, try a third party free tool instead.
If your C drive is nearly full and there is unallocated space available, you can try extending your C drive partition using built-in Windows tools:
If you prefer using the command line, you can use the diskpart command:
Note: Windows built-in tools can only extend c drive when it has NTFS file system and adjacent unallocated space is at its right side adjacent to it.
More requirements?
Windows built-in tools can only extend partitions when adjacent unallocated space is available. If there is no unallocated space or if you encounter issues, consider using third-party partition management software.
We recommend using IM-Magic Partition Resizer Free, a powerful tool that allows you to resize, move, and merge partitions safely without data loss.
Video: How to resize partition without losing data
For Windows 11/10/8/7 => Download Partition Resizer Free Portable [100% Free]
For Windows Server 2022-2003 => Download Partition Resizer Server Portable [Free Demo]