A hardware-based USB imaging and cloning solution using a Raspberry Pi Zero/Zero 2, Adafruit 128x64 1.3" OLED Bonnet, and Zero4U USB Hub or Mcuzone Gigabit Ethernet Expansion Board. Inspired by lukehutch/usb-copier.
- Clone USB disk to USB disk - Direct device-to-device cloning with multiple modes:
- Smart mode (partclone) - Intelligent partition-aware cloning
- Exact mode (dd) - Bit-for-bit exact copies
- Verify mode - Clone with SHA256 verification
- Backup Disk to Image - Create Clonezilla-compatible backup images
- Restore Clonezilla images to Disk - Restore from Clonezilla backup images
- Restore Passmark ImageUSB .bin images to Disk - Support for ImageUSB format
- Restore ISO image to Disk - Write ISO files directly to USB drives
- OLED Display UI - 128x64 pixel display with 7-button navigation for standalone operation
- Web UI - Real-time display streaming via WebSocket (port 8000) for remote monitoring and control
- Auto-detection - Automatic USB device discovery and monitoring
- Mounting/Unmounting - Safe device mounting with retry logic
- Formatting - Format devices with various filesystems (FAT32, ext4, NTFS, exFAT)
- Secure Erasure - Quick or full device erasure with verification
- USB-to-USB - Copy images directly between USB drives on the same Pi
- Ethernet Direct - Transfer images between Pis via direct Ethernet (mDNS discovery + HTTP)
- WiFi Direct - Peer-to-peer wireless transfer without a router (P2P via
wpa_supplicant)
|
|
|
|
|
|
Quick setup for experienced users:
# Clone the repository
git clone https://github.com/2wenty2wo/Rpi-USB-Cloner
cd Rpi-USB-Cloner
# Set up Python virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the cloner (requires root for disk operations)
sudo -E python3 rpi-usb-cloner.pyPrerequisites: I2C must be enabled and hardware properly connected. See the Installation section below for complete setup instructions.
Download the source code to your Raspberry Pi:
git clone https://github.com/2wenty2wo/Rpi-USB-Cloner
cd Rpi-USB-Cloner-
Flash Raspberry Pi OS (Lite is fine) to your microSD and boot the Pi Zero.
-
Update system packages to the latest versions:
sudo apt update sudo apt upgrade -y
-
Enable I2C (required for the Adafruit OLED Bonnet):
Option A: Use raspi-config interactive tool:
sudo raspi-config
Navigate to: Interface Options β I2C β Enable, then reboot.
Option B: Manually edit
/boot/config.txt:# Enable I2C for OLED display dtparam=i2c_arm=on
After enabling I2C, confirm the display address is either 0x3C or 0x3D. The OLED driver class depends on the panel type, so verify whether your panel is SSD1306 or SH1106.
Optional: Set faster I2C baud rate (1 MHz) for better display performance
-
Open the config file (path depends on your Raspberry Pi OS version):
# Newer Raspberry Pi OS releases sudo nano /boot/firmware/config.txt # Older versions may use /boot/config.txt
-
Add or update the following line:
dtparam=i2c_baudrate=1000000
-
Save and reboot:
sudo reboot
-
-
Install Python and required system libraries:
sudo apt install -y python3 python3-pip python3-dev python3-venv git \ libopenjp2-7 libfreetype6 libjpeg62-turbo libpng16-16t64 zlib1g partclone \ bluez bluez-tools bridge-utils dnsmasq
-
Install Python dependencies (Bookworm enforces PEP 668):
Option A (recommended): Virtual environment
python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txtOption B: System Python (single-use device only)
sudo pip install --break-system-packages -r requirements.txt
Basic usage:
sudo -E python3 rpi-usb-cloner.pyDebug mode:
sudo -E python3 rpi-usb-cloner.py --debugNote: The
-Eflag preserves environment variables. Root permissions are required for disk operations.
Stop/Restart:
- Press Ctrl+C to stop the running process
- Run the command again to restart
-
Create the systemd service file
/etc/systemd/system/rpi-usb-cloner.service:[Unit] Description=Rpi USB Cloner After=network.target [Service] Type=simple User=root # Update paths to match your installation directory WorkingDirectory=/home/pi/Rpi-USB-Cloner # For virtual environment (Option A), use the venv Python: ExecStart=/home/pi/Rpi-USB-Cloner/.venv/bin/python /home/pi/Rpi-USB-Cloner/rpi-usb-cloner.py # For system Python (Option B), use: /usr/bin/python3 /home/pi/Rpi-USB-Cloner/rpi-usb-cloner.py Restart=on-failure [Install] WantedBy=multi-user.target
Important: Update
User=and all paths to match your installation. -
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable rpi-usb-cloner.service sudo systemctl start rpi-usb-cloner.service -
Manage the service:
sudo systemctl stop rpi-usb-cloner.service # Stop sudo systemctl start rpi-usb-cloner.service # Start sudo systemctl restart rpi-usb-cloner.service # Restart sudo systemctl status rpi-usb-cloner.service # Status sudo journalctl -u rpi-usb-cloner.service -f # View logs
Via OLED UI:
- Navigate to: Settings β Update
Via command line:
Fix Git "dubious ownership" error (if needed)
If you see "dubious ownership" errors when running updates as root:
sudo git config --global --add safe.directory /home/pi/Rpi-USB-ClonerOption A: Virtual environment
cd /path/to/Rpi-USB-Cloner
git pull
source .venv/bin/activate
pip install -r requirements.txtOption B: System Python
cd /path/to/Rpi-USB-Cloner
git pull
sudo pip install --break-system-packages -r requirements.txtPlace custom GIFs in rpi_usb_cloner/ui/assets/gifs/ and the screensaver will automatically pick them up.
This project uses Lucide icons; see https://lucide.dev/license for license details.






