Skip to content

kernel-is/mirror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

🌐 Kernel.org Mirror Sync

Bash Linux

An automated, production-ready rsync mirror solution for kernel.org repositories

FeaturesInstallationConfigurationUsageMonitoring


📋 Overview

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.

✨ Features

  • 🔄 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-links and proper directory handling

🎯 Supported Package Managers

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

🚀 Installation

Prerequisites

  • Bash shell
  • Root or sudo access
  • Internet connection
  • Sufficient disk space (kernel.org repository is large!)

Quick Start

  1. Clone or download the script:

    git clone <your-repo-url>
    cd <repo-directory>
  2. Make the script executable:

    chmod +x mirror.sh
  3. 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

⚙️ Configuration

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"

Storage Requirements

Ensure your MIRROR_DIR location has adequate space:

  • Full kernel.org mirror: ~100GB+ (and growing)
  • Check available space: df -h /mnt/mirror/

📖 Usage

Manual Sync

Run a one-time sync manually:

sudo ./mirror.sh

Automated Daily Sync

The script automatically configures a cron job to run daily at 2 AM. To modify the schedule:

crontab -e

Change the timing (default: 0 2 * * *):

  • 0 3 * * * - 3 AM daily
  • 0 */6 * * * - Every 6 hours
  • 0 0 * * 0 - Weekly on Sunday at midnight

Viewing Logs

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.log

📊 Monitoring

Real-time Progress

During 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

Check Mirror Status

# View mirror size
du -sh /mnt/mirror/

# Count files
find /mnt/mirror/ -type f | wc -l

# Last sync time
ls -lt /mnt/mirror/ | head

🔧 Troubleshooting

Common Issues

rsync fails to install:

# Manually install rsync
sudo apt-get install rsync  # Debian/Ubuntu
sudo yum install rsync      # RHEL/CentOS

Permission denied:

# Ensure script runs with sudo
sudo ./mirror.sh

Disk 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

📁 Directory Structure

/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

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

  • Ensure compliance with kernel.org's [mirror policies]
  • Monitor bandwidth and storage usage
  • This mirror is for personal/organizational use

📞 Support

  • 🐛 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!

About

Script for setting up a kernel.org mirror.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages