Today I accidently found that there are a collection of eBooks laying in my hard drive, that I barely read. In addition, some friends shared with me kid books in various format (pdf, epub, mobi etc) and it’s simply too many to import them to iPad or Android tablet. I think it might be a good idea to build a home ebook library so that I can access the contents from different devices, e.g. mobile or tablet or Kindle. The Raspberry Pi is good for this purpose. Although I have the powerful RPi 4 but my 3 A+ has been sleeping in the gaming case for a long time, maybe it’s time to wake her up.
For the management system, of course we can use cloud storage (eg Google Drive) and install an ereader app on terminal devices. However, this will take up spaces on our device and downloading takes time as well. I used Calibre in the past and it can satisfy my needs.
1. install Ubuntu server on RPi
I used the 32 bit Ubuntu 20.04 Server image for Rpi 3. Here is the tutorial. After downloading, I flashed the image to a 32GB MicroSD card using BalenaEtcher and then edit the network-config (in the root of system-boot partition) to add WIFI name and password for connection. Just uncomment the following lines and add name/password:
|
|
Then eject SD card, insert it to Pi, and connect with the power supply. Wait for a few minutes until the green led blinks regularly. Then I checked the ip address (name “ubuntu”) on my router.
Then we can ssh into the RPi (“ubuntu” as default username and password) from our own computer and update the system:
|
|
On Rasperry Pi 4 you might encounter an error like this:
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1941 (unattended-upgr)
It is is a daemon that runs in the background and check for system updates automatically when you start your system. Just wait for a few minutes until it is finished.
Check by: ps aux | grep -i apt and run sudo apt upgrade
again
enable FTP
|
|
Later we can use ftp client (eg. Cyberduck) to access the default user directory (e.g. /home/ubuntu) or use scp
to transfer files, e.g. to backup calibre database locally.
|
|
2. Install and configure Calibre
This can be done using APT on the Pi. The installation takes >10min on Pi 3A+ and much shorter on Pi 4.
|
|
Note that after installing xvfb, the system will boot with gnome manager (GUI). To disable GUI at boot use sudo systemctl set-default multi-user. (To use GUI sudo systemctl set-default graphical)
Setup the Calibre library directory and another folder to holder resource books
The library path can be under user’s directory (e.g., /home/ubuntu)
|
|
Setup another folder for uploading books to the library, eg. books downloaded or from external drive
|
|
We can download a book here:
|
|
Alternatively, we can mount an external USB drive to this directory
|
|
adding books to calibre library
|
|
managing the library
For the headless server, we need to define –with-library all the time, otherwise there will be an error about “unable to open database file”.
|
|
run calibre content server
calibre-server ~/calibreLib
Now we can go to https://192.168.x.xx:8080/ on any device in the same network to browse and read books.
But I found it really slow to start and stop the server on Pi 3A+. Probably the RAM does matter a lot (3A+ for 512MB / 3B+ 1GB vs 4GB) and maybe I should switch to my Pi 4 instead.
to start the server automatically on system boot
Here is the manual to start the server automatically on system boot
First we create a file /etc/systemd/system/calibre-server.service
with the following content:
|
|
Replace ExecStart location accordingly by checking the location of calibre-server
|
|
and then push it to system
|
|
Finally, Calibre is very bad at converting PDF documents and sometimes the output is horrible. For a large amount of PDF to read maybe it’s better to store the files on cloud drive and read through a PDF reader app (I used Xodo and I like it).
20200627 Updata for PDF library
For PDF files, e.g. scanned books I now store them on my raspberry pi and share via samba. On the terminal device, e.g. mobile/tablet/computer there is usually PDF readers that can directly read the files.
I firstly attached an external USB drive (usb stick) with PDF files, MP3 and videos to my Pi (see section above). I mounted it to /media/usb1
install and configure samba
|
|
add something like this (I shared my USB stick)
|
|
I set public access as no so we need to set up username and password to access the folder
sudo smbpasswd -a ubuntu
will prompt to set the password for ‘ubuntu’
May also need to change the owner of the shared folder:
|
|
Now restart samba to apply changes
sudo systemctl restart smbd
Now we can access the shared folder on our computer, mobile or tablet.
I am using an Android phone and I found an app called Network Browser that supports smb share. In addition it also has build-in video player. I opened PDF files using Xodo because the sliding is really nice.
On iOS I tried the FE File Explorer and it also works great. It’s easy to read the PDF book while listening to the corresponding mp3.