Installing XBMC – perfect startup on Linux

home of a content challenger

Installing XBMC – perfect startup on Linux

I have been playing with XBMC for a couple of years now and it has been an awesome experience.  I use it to play all my content (music, movies and series) to most of the rooms in my house. Since it has been part of my life for such a long time, I spent an awful amount of time tuning the boot process, so XBMC will start both quickly and beautifully. In this post I will describe what choices I have made, what I customized to make XBMC boot within 10 seconds (including BIOS start) and completely controlling the output on the screen.

Hardware and OS

Let’s start with the hardware. The best hardware would have a BIOS that can be completely silent. For my main box, I chose an Intel main board that can boot without displaying anything to the screen. This guarantees that the first couple of seconds in our boot process we will just see a black screen. If your BIOS does not support complete silent startup, you might be able to create a custom one with a custom (XBMC) logo.

For quick boot you will need a solid state disk (SSD) as well. Personally I have all my content on a NAS, so my HTPC is installed on a huge 64Gb SSD. The whole installation currently fits on a little less than 6Gb, so smaller (and cheaper) SSDs can be used as well.

Since I don’t need any fancy 3d on a HTPC, I went for an I3 processor and use the standard Intel HD 2000 graphics, which gives me GPU accelerated playback at 1080i. Together with 4Gb of RAM the whole system is complete.

On my system I had to turn off UEFI boot in the BIOS. With UEFI turned on, the GRUB bootloader would always display an error message (booting in blind mode). Using a non-UEFI setup installed another version of GRUB (grub-pc) which would remain quiet during boot.

Next I chose my OS. With XBMC you have three options: Linux, Windows or OS X. For full control Linux is my OS of choice. However using Linux leaves you with the next choice: what distribution of Linux are you going to use? Personally I really like Debian. However the support for XBMC is not an area where Debian shines. For that reason I chose Ubuntu for this installation, support for XBMC is great: the XBMC maintainers have a dedicated ppa, where you can get the latest greatest version. A note of caution though: the current version of Ubuntu 14.04 did not work for me: the movies were blurry and choppy. Downgrading (reinstalling) Ubuntu 13.10 fixed the problem. I have not been able to identify the root-cause of this problem.

Since we want to create a lean mean machine, make sure you install the server version of Ubuntu and only install an openssh server. There is no need for a full desktop environment on a machine that will only be used for XBMC. Installing a desktop (KDE, GNOME or LXDE) will also install a lot of extra services (CUPS for printing, SANE for scanning) that will slow down your boot process. Since this machine is an appliance there is also no need for fancy partitioning, just take the default option and let Ubuntu use the whole disk.

Installation of XBMC

After the installation is done, you can do the rest of the installation remotely through SSH. Just install the HTPC next to your stereo equipment and sit on the sofa to do the modifications. The first thing you want to do is to upgrade your current installation and get the latest security patches:

sudo apt-get update
sudo apt-get upgrade

We are going to install the following packages (please note that a lot of dependencies will be installed as well, you are looking at downloading around 200Mb here):

  • xbmc the xbmc media center
  • xinit: a utility to start the X Windows System and an application of choice
  • lcdproc: to talk to the lcd display on the front of the HTPC box
  • ir-keytable: to handle the remote
  • lirc: for controlling additional remote options (lircrc)
  • plymouth: for a boot screen
  • alsa-utils: sound.
  • sysfsutils: access to linux devices through sysfs
  • powertop: provide an overview of power consumption
  • anacron: to execute cron jobs asynchronously
  • ubuntu-restriced-extras: codecs and other restricted stuff
  • shairplay: enable apple airplay functionality
  • pm-utils: scripts for hibernate and suspend to ram

sudo aptitude install xbmc xinit lcdproc ir-keytable lirc plymouth-label alsa-utils sysfsutils powertop anacron ubuntu-restricted-extras shairplay pm-utils

The user you will use to start xbmc needs to be in the following additional groups: audio, video and fuse (I am not sure about the last one, but it can be practical):

sudo adduser [your_user_name] audio
sudo adduser [your_user_name] video
sudo adduser [your_user_name] fuse

To get a newer version of xbmc I installed the team-xbmc ppa.

sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get upgrade

If you would like to have a xbmc logo during the boot process, you can install the following package:

sudo wget http://excyle.nl/plymouth-theme-xbmc-logo.deb
sudo dpkg -i plymouth-theme-xbmc-logo.deb

Last but not least I installed the VA and VAAPI driver to get video acceleration on my intel HD 2000 card. If you are using another card this step should be replaced with the driver for your card.

sudo apt-get install i965-va-driver libva-intel-vaapi-driver

Configuration of the system

A couple of small scripts and changes to configurations are needed to start xbmc and remove all unwanted output from the screen.

Start XBMC as a service

To automatically start xbmc when the system boots you have to create the  file: /etc/init/xbmc.conf and give it the following content (you need to be root to create that file, so use: sudo nano /etc/init/xbmc.conf):

# xbmc-upstart
# starts XBMC on startup by using xinit.
# by default runs as xbmc, to change edit below.
env USER=[your_user_name]

description     "XBMC-barebones-upstart-script"
author          "Matt Filetto"

#start on (filesystem and stopped udevtrigger)
start on (filesystem)
stop on runlevel [016]

# tell upstart to respawn the process if abnormal exit
respawn

script
  exec su -c "xinit /usr/bin/xbmc --standalone -- -nocursor :0" $USER
end script

Remove tty1

You might notice that on any Ubuntu system you see the command prompt for a split second in the background before a graphical environment starts. Since the goal is a perfect boot we want to remove that. Easiest way is to make sure it doesn’t start at all. This removes your first terminal, so if you are working on the console of the machine, you have to use another one!

Ubuntu has a pretty elegant way of setting a service to start manually all you have to do is create an override file that says manual. For tty1 we have to create the  file: /etc/init/tty1.override with the following content:

manual

Yes, that is right, just write the word “manual” in the file and save it. If you ever need your tty1, you can simply start it with a “sudo service tty1 start”.

Allow your user to start the X Windows Server

By default your user is not allowed to start the X Windows Server, which is needed to show xbmc on your screen. To change this open the file /etc/X11/Xwrapper.config and change the last line to:

allowed_users=anybody

A silent grub

During boot, grub will normally allow you to select a kernel you would like to boot. For a perfect boot we do not want to see that information, so grub needs to be put into silence mode. Open the file /etc/default/grub and make sure it contains the following lines at the top (just overwrite existing options):

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0
GRUB_RECORDFAIL_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

These options ensure that grub will remain quiet even if the system restarts due to a crash (GRUB_RECORDFAIL_TIMEOUT). To activate these changes run the following command:

sudo update-grub

Summary

The above installation and configuration should give you a silent system that boots directly into xbmc. Now you still need to set up your remote control and maybe configure the little display on your HTPC. Since this is very dependent on your hardware I will leave that exercise up to you. In case you have any questions or remarks, please leave them in the comments below.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: