I jailbroke my Kindle as I wanted to be able to sync my own documents to it, without sending them to the Amazon magic email address, and without having to plug the thing into USB.
It seems like the most common way to do this is with KOReader and Calibre. For various reasons, I dislike Calibre. Among other things I did not want to have to run a desktop GUI app to synchronise my books. How prehistoric.
KOReader has ssh support out of the box, so I thought my job was done - rsync a directory and get on with my life.
rsync -e 'ssh -p 2222' -avc root@kindle.ip.here:/mnt/us/documents/ documents/
sh: rsync: not found
(the KOReader ssh daemon runs on port 2222)
Not so fast.
There is no rsync binary on the Kindle, so this will not work.
I tried in vain to find a binary1, as setting up a cross-compiling environment just to build a single binary seemed like an onerous task. Then a friend pointed me in a direction I should have thought of in the first place - alternate implementations of rsync - preferably in a modern language (sorry C programmers).
He found https://github.com/gokrazy/rsync.
Being go-based, I can trivially cross compile this for the Kindle’s ARM architecture.
git clone https://github.com/gokrazy/rsync
cd rsync
cd cmd/gokr-rsync
GOOS=linux GOARCH=arm GOARM=7 go build .
Now we have a binary gokr-rsync
built for the Arm7 architecture the Kindle
uses, on your local machine (Mac in my case, but your local build architecture
doesn’t matter with Go’s cross-compilation support).
ssh’ing into the Kindle, we can put the root filesystem into read/write mode temporarily:
mntroot rw
And now copy our binary across, giving it the usual name:
scp -P 2222 gokr-rsync root@kindle.ip.here:/usr/bin/rsync
And now on the Kindle you can restore the root filesystem into read-only mode:
mntroot ro
Now we can use rsync:
rsync -e 'ssh -p 2222' -avc root@kindle.ip.here:/mnt/us/documents/ kindle/