Skip to main content

USB Cloner

USB Cloner is a Python library for rapidly replicating the contents of a USB. It also includes various features to wipe drives before cloning, verify the cloning process, and scramble filenames.

Installation

Use pip to install usbcloner. Python 3.8 or higher is required.

pip3 install usbcloner

Usage

Duplicating USBs

Cloning mode is used to duplicate the contents of one drive to multiple others. Cloning will add files without wiping the drive by default. If there is not enough diskspace, usbcloner will skip the new device and not attempt to clone to it.

# Begin a cloning session using a user-provided USB. Files will be verified using filesizes only--no hashing.
usbcloner

# Wipe all USBs prior to cloning to ensure there is enough disk space and use hashing to verify file duplication for all files.
usbcloner -w -p 100

Verify USB Contents

Verification mode can be used to ensure the contents of numerous devices are identical without performing any cloning.

# Prompt for a USB and verify subsequent USB drives.
usbcloner --verify-only

# Build and save a verification table first, then verify devices using the saved table at a later time.
# Without --verify_only, usbcloner will enter into "cloning" mode after saving the verification table.
usbcloner -o "verify.tbl" --verify_only

# At a later time...
usbcloner -i "verify.tbl" --verify_only

Renaming Files

In addition to duplication and verification, usbcloner allows for the scrambling of filenames on a drive. It does this in a way that maintains the lexicographical (alphabetical sort) order of the files and folders.

# Clone the drives, but scramble the filenames first. All cloned drives will have the same scrambled filenames for the same files.
usbcloner --rename

# Only rename the files that are already on the drive. No cloning or verification.
usbcloner --rename-only

Speed vs Confidence

By default usbcloner only uses filename and file size to verify successful duplication. However, you can use the -p flag to use hashing to verify duplication for a user-provided percentage of files (0-100).

# Do not perform any hash verification for cloned files. This is the default behavior and the same as running "usbcloner".
usbcloner -p 0

# Perform hash verification for 50% of files after cloning.
usbcloner -p 50

# Perform hash verification for all files after cloning.
usbcloner -p 100

Trim

--trim removes any files that are found on the drive that are not in the verification table. This is particularly helpful in deleting hidden files that various operating systems add when drives are mounted or viewed. Examples include .DS_Store on OSX and the "System Volume Information" folder on Windows.

usbcloner --trim

Other Examples

Use a folder on disk to clone instead of a user-provided USB.

usbcloner -s ~/Folder_to_be_cloned/

Roadmap

  • Add pytest tests
  • Add a Rich interface that shows cloning progress in realtime.
  • Determine if a drive needs to be reformated
  • Test the performance of using Rust for the file copy
  • Figure out math on better file name length during renames
  • Make it so you don't need to use the computer as a temporary file storage

Ideas

  • Figure out how to associate a USB port to a physical port.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

GNU General Public License v3.0

Release files for usbcloner 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for usbcloner 0.1.0
File Size Uploaded
usbcloner-0.1.0.tar.gz 56.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for usbcloner 0.1.0
File Interpreter ABI Platform
usbcloner-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 103.5 kB

Release files / usbcloner-0.1.0.tar.gz

Download URL usbcloner-0.1.0.tar.gz
Size 56.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e2e3b9fae625df1ba0875a2d34a10c568dafe44685b5bb8f48c2ea3e4883cbba
BLAKE2b-256 checksum
How to use checksums
ba2bb93f30837112dc193f9922216e632fb219875480b86797c478458433053f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release files / usbcloner-0.1.0-py3-none-any.whl

Download URL usbcloner-0.1.0-py3-none-any.whl
Size 46.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bdea63eed91213848a18dadec31996c665aa1df4140a735d0fe16369f287232
BLAKE2b-256 checksum
How to use checksums
2941312b4eb3d854c1dd2f21986def6c113ed9ccc75cf87e6239ecdf27532096
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page