A Raspberry Pi makes a capable, low-power media and ebook server. The Pi 5 handles a Plex library, a Calibre content server, and external storage without breaking a sweat; the Pi Zero 2 W can manage lighter loads if you’re optimizing for cost or power draw. This guide walks through the build I run at home (the HTPieC: a home theater PC on a Raspberry Pi, hence the Pie), covering OS setup, Plex, Calibre, mounting external drives, and automated backups.
The scripts and config behind this build live in the htpiec repo — an install script, a managed Calibre service, fstab samples, and the backup wrapper. They’re samples to adapt, not a turnkey image; the walkthrough below is the by-hand version.
Hardware overview#
- Computer: Raspberry Pi 5 with 8GB RAM
- Storage: 128GB micro-SD card (OS and software)
- Primary storage: Fast external SSD (e.g., 1TB) for media storage
- Backup storage: Reliable external HDD (e.g., 2TB) for data redundancy
For a leaner setup, the Pi Zero 2 W works for smaller libraries and less intensive tasks. Same software, less headroom.
Setting up the Raspberry Pi#
Install and configure Pi OS#
- Boot up: Insert the preloaded micro-SD card and power on your Pi.
- Update the system: Open the terminal and run:
sudo apt update && sudo apt upgrade -y - Enable SSH: If remote access sounds like your jam:Navigate to
sudo raspi-configInterface Options > SSHand enable it.
Configure your network#
Assign a static IP to your Pi through your router’s settings. DHCP leases can shuffle, and you don’t want your media server’s address moving every time the router reboots.
Installing media server software#
Install Plex for media management#
Plex handles transcoding, library organization, and remote streaming. To install:
- Add the Plex repository and install.
apt-keyis deprecated on current Pi OS, so use a signed keyring instead:curl -fsSL https://downloads.plex.tv/plex-keys/PlexSign.key | sudo gpg --dearmor -o /usr/share/keyrings/plex-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/plex-archive-keyring.gpg] https://downloads.plex.tv/repo/deb public main" | sudo tee /etc/apt/sources.list.d/plexmediaserver.list sudo apt update sudo apt install plexmediaserver - Confirm Plex is running:
sudo systemctl status plexmediaserver
Set up Calibre for ebook hosting#
Calibre serves a self-hosted ebook library over HTTP. (For managing the library itself — metadata, conversion, plugins — see The ultimate guide to Calibre.) To install and start the content server:
- Install Calibre:
sudo apt install calibre - Start the Calibre content server:
calibre-server /path/to/your/ebook/folder - Access your ebooks via
http://<raspberry_pi_ip>:8080. To swap the IP for a hostname likehttp://my-library.local, run Pi-hole or any local DNS resolver on your network.
Making your server public#
To expose the HTPieC outside your home network:
- Port forwarding: forward the relevant ports on your router (e.g., 32400 for Plex).
- Dynamic DNS (DDNS): services like No-IP map a stable hostname to your changing public IP.
- TLS: terminate HTTPS with Let’s Encrypt. Don’t skip this; exposing media metadata, library contents, or session credentials over plain HTTP is asking for trouble.
- Calibre auth: the content server is world-open by default. Once it’s reachable beyond your LAN, start it with
--enable-authand add accounts withcalibre-server --manage-users, or you’re publishing your whole library to anyone who finds the port.
Connecting external storage#
Mount drives#
External drives hold the bulk of your media. The Pi’s microSD is for the OS and software; you’ll want disk-grade storage for everything else.
- Identify the drives:
lsblk - Create mount points:
sudo mkdir /mnt/media sudo mkdir /mnt/backup - Mount the drives:
sudo mount /dev/sda1 /mnt/media sudo mount /dev/sdb1 /mnt/backup - Automate the process with
/etc/fstabentries. Mount by UUID, not/dev/sdX— device nodes can reorder across reboots, so your media and backup drives swap places; UUIDs are stable. Grab them withsudo blkid /dev/sda1. Addnofailso the Pi still boots if a drive is unplugged:UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/media ext4 defaults,nofail 0 2 UUID=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy /mnt/backup ext4 defaults,nofail 0 2
Keep your backup drive happy and healthy with tools like smartmontools.
Automating backups#
rsync handles incremental backups well and is in the Pi OS base install:
- Sync your files:
rsync -av --delete /mnt/media/ /mnt/backup/ - Schedule it:Add this to run daily at 2 AM:
crontab -e0 2 * * * rsync -av --delete /mnt/media/ /mnt/backup/
One caveat: --delete mirrors the source exactly, so anything removed from /mnt/media is gone from the backup on the next run. That’s correct for a true mirror, but if a drive glitch corrupts the source, the damage propagates. If you’d rather keep deleted files, add --backup-dir, or put the library on a snapshotting filesystem.
Accessing your media#
- Plex: Stream your movies at
http://<raspberry_pi_ip>:32400/web. - Calibre: Enjoy your ebooks at
http://<raspberry_pi_ip>:8080.
Bonus features#
Once the core HTPieC is running, two natural extensions:
- RetroPie turns the Pi into a network-accessible retro gaming host.
- Kodi layers a polished living-room UI on top of the same media files Plex serves.
Additional tips#
- Power supply: use a reliable adapter rated for the Pi 5’s 5V/5A draw. Underpowered supplies show up as random crashes, not error messages.
- Ethernet: prefer wired when the Pi is stationary. Wi-Fi is fine for the Zero 2 W but adds latency you don’t want on a 4K stream.
- Expand storage: chain more drives, or move to a small NAS once the library outgrows what a couple of USB disks can hold.
With the HTPieC running, you have a Plex server, a Calibre ebook server, and an automated backup pipeline on a low-power machine that costs less than a single year of streaming subscriptions.
Additional resources#
- htpiec repo — the install script, Calibre service, fstab samples, and backup wrapper behind this build
- Raspberry Pi OS — official OS images and the Imager tool
- Plex Media Server — downloads and setup docs
- Calibre content server — the official content-server manual
- The ultimate guide to Calibre — managing the library this server hosts
