I was looking for stand alone “headless” Raspberry Pi USB Copier software and stumbled upon Luke Hutchison’s “usb-copier” which allows you to copy, view and wipe USB sticks.
After seeing the picture of it utilizing the Adafruit 128×64 OLED Raspberry Pi bonnet and the Zero4U Shield, I instantly ordered both.
With little information on how to get this running on the GitHub page and not knowing a thing about Java, this took a little bit of playing around and also reaching out to the developer for help.
While this was a fun little project to complete, ultimately it doesn’t fulfill my use case. This program uses Rsync to copy files from one USB stick to another, which is great if it’s just random files but I want to be able to copy boot disks like Windows and recovery USB sticks for arcade games. This would require sector to sector copying like dd. I attempted to implement dd in replacement to the Rsync commands but with zero Java knowledge, I didn’t get far.
Regardless, if you are into the idea of a USB stick copier (for general files, not boot disks), this could be perfect for you.
Build Machine
My build machine is MacOS.
- Download usb-copier from GitHub and unzip.
- Download and install Apache NetBeans 12.2.
- Install Maven via Homebrew:
brew install maven
- Download the Java Adafruit-OLED-Bonnet-Toolkit dependency and install
mvn install
- Open the usb-copier project folder in Apache NetBeans and build the program. I saved the file called “usb-copier-0.0.2-jar-with-dependencies.jar” and copy it to /home/pi on the Raspberry Pi Zero via SSH.
Raspberry Pi Zero
- Install Raspberry Pi OS Lite on Raspberry Pi Zero 1.3.
- Install Java 11 for ARMv6 provided by Azul as openjdk-11-jdk won’t run on the Zero.
- Install
sudo apt-get install wiringpi pigpio udevil nano
- Run
sudo nano /boot/cmdline.txt
and addiomem=relaxed
- Enable I2C by running
raspi-config
and turn it on. - Set I2C data rate in config file.
sudo nano /boot/config.txt
& add,i2c_arm_baudrate=1000000
afterdtparam=i2c_arm=on
- Extract
libpi4j-pigpio.so
to /home/pi:unzip -j usb-copier-0.0.2-jar-with-dependencies.jar lib/armhf/libpi4j-pigpio.so
- Start at boot:
sudo nano /etc/rc.local
and addsudo bash -c 'nohup java -Dpi4j.library.path=/home/pi -jar /home/pi/usb-copier-0.0.2-jar-with-dependencies.jar &'
Wanted:
Sector to Sector copying with dd
I tried to modify the original script to utilise dd over rsync. With the help of the developer I managed to get the dd command to work but without a working progress bar (this is such a pain). I ended up starting to develop my own version of usb-copier by using something a little simpler like Python.
I’m a Python newbie, I’m still only at the GUI phase and it’s currently not working (no copy functionality yet).
If someone with more skills than me would like to take this challenge on, please reach out! Having a dedicated one-purpose stand-alone USB copier device that could be part of my daily tool-kit would be awesome.