An automated, production-ready rsync mirror solution for kernel.org repositories
Features • Installation • Configuration • Usage • Monitoring
This script provides a robust, automated solution for creating and maintaining a local mirror of kernel.org repositories. It includes automatic dependency installation, comprehensive error handling, progress tracking, and automated daily synchronization.
Perfect for organizations requiring offline access to kernel sources, reducing bandwidth usage, or establishing internal mirrors for development teams.
- 🔄 Automated Synchronization - Daily sync scheduled via cron at 2 AM
- 📦 Smart Dependency Management - Automatically detects and installs required packages
- 🛡️ Robust Error Handling - Comprehensive error tracking with detailed logging
- 📊 Real-time Progress - Live transfer status with percentage completion
- 🔧 Multi-Distribution Support - Works across major Linux distributions
- 📝 Detailed Logging - All operations logged for audit and troubleshooting
- 🔒 Safe Operations - Implements
--safe-linksand proper directory handling
The script automatically detects and uses the appropriate package manager:
| Distribution | Package Manager |
|---|---|
| Debian/Ubuntu | apt-get |
| RHEL/CentOS | yum |
| Fedora | dnf |
| Arch Linux | pacman |
| openSUSE | zypper |
| Alpine Linux | apk |
- Bash shell
- Root or sudo access
- Internet connection
- Sufficient disk space (kernel.org repository is large!)
-
Clone or download the script:
git clone <your-repo-url> cd <repo-directory>
-
Make the script executable:
chmod +x mirror.sh
-
Run the script:
sudo ./mirror.sh
The script will automatically:
- Install rsync if not present
- Install cron/cronie if not available
- Create necessary directories
- Perform initial sync
- Schedule daily synchronization
Edit these variables at the top of mirror.sh to customize your setup:
# Mirror storage location
MIRROR_DIR="/mnt/mirror/"
# Source rsync URL
RSYNC_URL="rsync://rsync.kernel.org/pub"
# Log file location
LOG_FILE="/var/log/kernel-mirror-sync.log"Ensure your MIRROR_DIR location has adequate space:
- Full kernel.org mirror: ~100GB+ (and growing)
- Check available space:
df -h /mnt/mirror/
Run a one-time sync manually:
sudo ./mirror.shThe script automatically configures a cron job to run daily at 2 AM. To modify the schedule:
crontab -eChange the timing (default: 0 2 * * *):
0 3 * * *- 3 AM daily0 */6 * * *- Every 6 hours0 0 * * 0- Weekly on Sunday at midnight
Monitor sync progress and troubleshoot issues:
# View recent logs
tail -f /var/log/kernel-mirror-sync.log
# View full log
less /var/log/kernel-mirror-sync.log
# Search for errors
grep -i error /var/log/kernel-mirror-sync.logDuring sync, you'll see:
Starting kernel.org mirror sync at Mon Oct 27 14:30:00 UTC 2025
12,345,678 45% 2.34MB/s 0:05:23 (xfr#123, to-chk=456/789)
linux-6.6.1.tar.xz
- Percentage - Overall completion
- Transfer rate - Current speed (MB/s)
- Time remaining - Estimated completion time
- Current file - File being transferred
# View mirror size
du -sh /mnt/mirror/
# Count files
find /mnt/mirror/ -type f | wc -l
# Last sync time
ls -lt /mnt/mirror/ | headrsync fails to install:
# Manually install rsync
sudo apt-get install rsync # Debian/Ubuntu
sudo yum install rsync # RHEL/CentOSPermission denied:
# Ensure script runs with sudo
sudo ./mirror.shDisk space full:
# Check available space
df -h /mnt/mirror/
# Clean old files if needed
sudo rm -rf /mnt/mirror/old-directory/Cron job not running:
# Check cron service
sudo systemctl status cron # Debian/Ubuntu
sudo systemctl status crond # RHEL/CentOS
# View cron logs
grep CRON /var/log/syslog/mnt/mirror/ # Mirror root directory
└── pub/ # Public kernel.org content
├── linux/ # Linux kernel sources
├── software/ # Various software packages
└── ...
/var/log/
└── kernel-mirror-sync.log # Sync operation logs
Contributions are welcome! Please feel free to submit a Pull Request. For major changes:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ensure compliance with kernel.org's [mirror policies]
- Monitor bandwidth and storage usage
- This mirror is for personal/organizational use
- 🐛 Issues: [GitHub Issues]
- 📧 Contact: [projects [AT] kernel [DOT] is]
- 📚 Documentation: [kernel.org]
Made with ❤️ for the Linux community
⭐ Star this repo if you find it helpful!