![]() |
||
---|---|---|
README.md | ||
disk-check-macos.sh | ||
disk-check.sh |
README.md
Disk Space Report Script
A comprehensive disk space analysis tool for Ubuntu/Linux systems that helps identify storage usage patterns and suggests cleanup opportunities.
Features
- APT Cache Analysis: Estimates size of package cache that can be cleared
- Package Management: Identifies old installed packages taking up space
- Journal Log Analysis: Checks system journal logs for cleanup opportunities
- Temporary Files Check: Analyzes temporary directories for cleanup
- Docker Volume Analysis: Identifies unused Docker volumes consuming space
- Docker Log Management: Finds large Docker log files and suggests rotation
- Large Directory Discovery: Lists directories consuming significant space
- Automatic Report Upload: Uploads results to Hastebin for easy sharing
Requirements
- Ubuntu/Linux system
sudo
privileges for comprehensive analysisdocker
(optional, for Docker-related analysis)jq
for JSON parsing (for Hastebin upload)curl
for report uploading
Installation
# Clone the repository
git clone https://github.com/yourusername/disk-space-report.git
cd disk-space-report
# Make the script executable
chmod +x disk-check.sh
Usage
./disk-check.sh
The script will:
- Analyze various system components for space usage
- Generate a comprehensive report
- Save the report to
/tmp/disk_space_report.log
- Upload the report to Hastebin and provide a shareable URL
What It Analyzes
System Components
- APT Cache (
/var/cache/apt
): Downloaded package files - Package Lists (
/var/lib/apt/lists
): Package index files - Journal Logs: System logging data
- Temporary Files (
/tmp
,/var/tmp
): Temporary system files
Docker Components (if Docker is installed)
- Unused Volumes: Dangling Docker volumes
- Large Log Files: Docker container logs over 1GB
Directory Analysis
- Large Directories: Directories consuming more than 5GB and 10GB
- Home Directory Analysis: Large directories in user home folders
Sample Output
The script provides estimates like:
Estimating the size of the apt cache:
1.2G /var/cache/apt
Estimating the size of journal logs:
Archived and active journals take up 2.1G in the file system.
Directories in / consuming more than 5GB:
7.2G /var/lib/docker
12G /usr/share
Cleanup Suggestions
Based on the analysis, you can:
- Clear APT cache:
sudo apt clean
- Remove old packages:
sudo apt autoremove
- Clean journal logs:
sudo journalctl --vacuum-time=30d
- Clear temporary files:
sudo rm -rf /tmp/*
(use with caution) - Remove unused Docker volumes:
docker volume prune
- Truncate Docker logs: Use the provided command in the script output
macOS Version
For macOS users, there's also a disk-check-macos.sh
version that provides similar functionality adapted for macOS systems.
Safety Notes
- This script only analyzes disk usage - it doesn't delete anything
- Always review suggested cleanup commands before running them
- Some cleanup operations cannot be undone
- The script requires
sudo
for comprehensive system analysis
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
License
This project is licensed under the MIT License.