A smart, interactive Bash script designed to clone bootable USB drives efficiently.
Unlike standard cloning tools that copy every single byte of a drive (including empty space), this tool calculates exactly where your data ends and copies only the used partitions. This allows you to clone a large source drive (e.g., 128GB with only 7GB of data) onto a smaller target drive (e.g., 16GB), provided the data fits.
- Smart Size Calculation: Automatically detects the end of the last partition to avoid copying empty space.
- Interactive Workflow: Prompts you to insert the target drive only when needed, reducing the risk of overwriting the wrong disk.
- Safety Checks:
- Verifies root privileges.
- Prevents cloning if Source and Target are the same device.
- Calculates if the Target drive has enough physical capacity before starting.
- Universal Compatibility: Works with both Legacy BIOS (MBR/DOS) and UEFI (GPT) partition schemes.
- Auto-Repair: Automatically fixes GPT backup headers on the target drive using
sgdiskif necessary.
You need a Linux system with the following standard tools installed:
bashparted(for partition analysis)lsblk(for size detection)dd(for the actual copying)gdisk(providessgdiskfor GPT repairs)
Installation on Debian/Ubuntu/Kali:
sudo apt update
sudo apt install parted gdisk