You are looking to turn your Raspberry Pi into a media centre, but you also need it for other tasks? Perhaps you’re using your Pi for programming or playing Minecraft. It might have a role as a general project machine, meaning you need regular access to Raspbian.
One solution to this might be to keep several microSD cards at hand, each with different operating systems installed. You might have one with Raspbian ready to run, another with a retro gaming distro, and a third with OSMC, openELEC, or LibreELEC. These are the three Kodi-based Raspberry Pi distributions, and the most common solutions. It’s easy to write one of these to microSD card to set up your Raspberry Pi-based Kodi box.
But if you only have a single microSD card, wouldn’t it be far simpler to just install Kodi on Raspbian? Here’s how!
Make Sure You’re Using Raspbian Stretch
Before proceeding, you’ll need to make sure your Raspberry Pi is running the latest version of Raspbian, Stretch. You can check if you’re using Raspbian Stretch by opening a terminal window and entering:
The resulting text (see the screenshot) will show you which Linux operating system and version you’re using.
If you’re on an older version, you can download Raspbian Stretch from the Raspberry Pi website and flash it to your microSD card. This is the recommended option, although it is possible to upgrade manually from within Raspbian Jessie. However, you may run into problems doing it this way, and it’s always good to start with a fresh install.
If flashing doesn’t suit you, try installing Raspbian using the NOOBS installer tool.
If you have data on your Raspberry Pi that you’ll need in Raspbian later on, make sure you back it up first.
Also, make sure you’re using a Raspberry Pi 2 or later. The Raspberry Pi 3 and the Pi Zero, are both suitable; sadly, the original Raspberry Pi Model B is too slow to reliably run Kodi.
Configuring Your Raspberry Pi for Kodi
Before you install Kodi, you’ll need to ensure your Pi is set up correctly. Three things need to be changed:
- Expanding file system (this should happen automatically when booting Stretch for the first time)
- Altering memory split
- Enabling video codecs
Additionally, you’ll need to ensure Broadcom desktop drivers are set.
All three of these things can be done using raspi-config. You can access this on the desktop via Preferences > Raspberry Pi Configuration, or in the command line:
Expanding the Filesystem
If you haven’t already expanded the filesystem, and it didn’t happen automatically when you booted (which gives your Pi more space to run software), you should do so now.
This will improve overall performance of your Kodi box, as there will be more space on the microSD card for installing add-ons and caching data. (By default, Raspbian installs into a partition that is smaller than the microSD card.)
To take full advantage of your microSD card’s capacity, open raspi-config and select the first option, Expand Filesystem. Select OK to confirm your choice, and follow the instructions to restart your Raspberry Pi.
Altering Memory Split
Next, you’ll need to change the memory split. Kodi on the Raspberry Pi 2 or Raspberry Pi 3 requires 256MB dedicated to the GPU to run correctly.
Again, run raspi-config, then go to Advanced Options > Memory Split and set the split to 256MB.
Enabling Video Codecs
Finally, you need to enable certain video codecs that don’t run as standard. These include VP6, VP8, MJPEG, and Theora, among others. To do this, you need to enable the camera. While no camera needs to be connected, enabling this feature will ensure the codecs can be used.
Do this via Interfacing Options > Camera > Yes. Confirm with OK. Note that you can also effect this change via the config.txt file. Found in the /boot/ directory on your Raspberry Pi’s microSD card, this is the only directory that can be read in Windows.
To do it this way, open config.txt on your desktop computer and add:
Save the file, exit, and safely eject your microSD card before replacing in the Raspberry Pi and rebooting.
Setting the Right Desktop Driver
The last pre-install change you need to make is to the desktop driver. Kodi will not function if you’re not using the Broadcom drivers for your Raspberry Pi’s display. As such, you’ll need to ensure the default driver is set.
In raspi-config, select Advanced Options > GL Driver and set Original non-GL desktop driver. Select OK to confirm, and reboot again if prompted.
Installing Kodi on Raspbian Stretch
To get Kodi running on Raspbian, you’ll need to begin with the basics. First, update packages, then check for updates:
sudo apt update sudo apt upgrade
Once these updates are complete, you’re ready to install Kodi:
sudo apt install kodi
However, there’s a bit more to it than that. Installing Kodi is only part of the challenge, as you’ll also need to configure it slightly. This is likely to work best on Raspbian, although this is by no means the only OS you can use.
Once Kodi has downloaded and installed, you’ll probably want to make some tweaks. This ensures you get the best performance out of the media center.
Tweaking the Kodi Install
Kodi should already work, but perhaps not to your liking. Further tweaks can be made, such as choosing some additional components, or configuring Kodi to auto-start when your Pi boots.
To find out what binary add-on packages are available, run:
apt-cache search kodi
Scroll through the list to see what is available. For instance, if you want to add joystick support and the DVBLink PVR, use
sudo apt install kodi-peripheral-joystick kodi-pvr-dvblink
You should now be able to control your Raspberry Pi Kodi box with a joystick, and record live TV streams to an attached storage device.
Meanwhile, to instruct Kodi to launch when you switch on your Raspberry Pi, you’ll need to edit the autostart file via SSH or the command line on your Pi:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
Here, add a line to the end:
Then, save the file and exit with Ctrl + X. When you next reboot your Raspberry Pi, it should boot straight into Kodi. Exiting Kodi, meanwhile, will let you back into the Raspbian desktop!
It Doesn’t Have to Be Raspbian
We have focused on using Raspbian as the base for your Kodi install, but it doesn’t have to be. You might be using one of the many other Raspberry Pi-compatible operating systems. There’s no reason why Kodi shouldn’t run on Ubuntu, for example or Arch Linux.