Post

Kodi setup on a Raspberry Pi 4

popcorn

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, the gpu_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.

stig-popcorn

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.

This post is licensed under CC BY 4.0 by the author.