Kodi setup on a Raspberry Pi 4
One more handy use for a little computer - a local home media server! Local movie night is relaxing. Itās also great for putting the favorite kid video of the day on repeat ā¦ again and again and again (until the dishwasher is loaded, laundry moved, etc.). š¦ baby shark, doo doo doo š¦ š
The end product is an āappliance-likeā device that can play local media on a television.
Hardware
Youāll need some parts and pieces to build this.
- Raspberry Pi 4 or 5 (amount of RAM up to you)
- Micro-SD card (capacity up to you)
- Power supply for the board (15W USB-C)
- Case (strongly recommend a passively cooled case like this one )
- A big external hard drive w/ an independent power supply (do not draw power from the board) or a network share, for the media to share
- A keyboard (only for initial setup, does not need to be permanently attached)
- A television with HDMI input and a Micro-HDMI cord
Initial setup
Flash the micro SD card with the latest version of the Raspberry Pi OS - Debian 12 (bookworm), 64-bit lite image . Boot it up and then run raspi-config
, the configuration tool , to set up at least the following.
- Username and password
- Localization settings
- Console auto-login (what you want in order to automagically start Kodi on boot)
- Network setup, if needed
- Enable SSH (optional)
1
sudo raspi-config
Run updates to the OS manually, then reboot, before installing more software.
1
2
3
sudo apt update
sudo apt dist-upgrade
sudo reboot
Thereās a decent chance that thereāll be new firmware, drivers, security fixes, etc. Itās now a plain server, ready to install any graphical apps.
Older guides have you configure more settings in the
/boot/config.txt
file. Most arenāt necessary on the Pi 4 B model (or later) with the default OS. In particular, thegpu_mem
settings are deprecated in favor of letting the memory management unit (MMU) do what it was designed to. Legacy config.txt options is the official documentation on this if youāre looking for some light reading. I did no configuration changes apart from whatās in this guide and it works fabulously.
Kodi installation
Install Kodi and the desktop manager for it to use.
1
sudo apt install kodi lightdm
Now have it automatically launch at boot using systemd . Use sudo
to create a file at /lib/systemd/system/kodi.service
with the following contents:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description = Kodi Media Center
After = remote-fs.target network-online.target
Wants = network-online.target
[Service]
User = pi
Group = pi
Type = simple
ExecStart = /usr/bin/kodi-standalone
Restart = on-abort
RestartSec = 5
[Install]
WantedBy = multi-user.target
Note you will need to edit the user
and group
to match the username you created. Enable the service to start Kodi automatically at boot:
1
sudo systemctl enable kodi.service
Then reboot and configure Kodi as youād like. Hereās the official quick start guide to get going. My post-install configuration includes
- Adding the movie, TV, and music directories from an external hard drive to the library (wiki )
- Setting up Kore , the official remote app for phones/tablets
- Configuring a weather add-on to see the local weather
Maintenance
Under the hood, itās a lightweight general-purpose Linux machine thatās likely connected to the internet. It needs regular security updates, outlined in the official docs with handy videos and tutorials.
The chance of me remembering to do this regularly is about zero, so Iāve automated it using the same method in last weekās post - Self-updating build servers, automatically. The machine is joined to a GitHub repository as a self-hosted runner (directions ) and runs a workflow to update it automatically šŖ (this one , to be exact). Now no one will need to remember to keep it securely up to date and itāll yell (create an issue) if something doesnāt go exactly right.
šļø Enjoy home movie night ā¦ or simply keep small humans distracted for a few minutes while groceries are put away. š§ø
Footnotes
Yes, this really was written for me. Iād upgraded the hardware, then the software from Buster to Bookworm, and then random crashes started happening. Rather than troubleshoot and search forums for hours to figure out all the possible problematic changes after years of this Just Working, I rebuilt it and wrote it down for future me. Hope someone else searching finds it useful too.