Saturday, June 30, 2012

Apache 2 Reverse Proxy Howto: Protect and redirect your internal web services with Apache 2 acting as a Reverse Proxy

Apache 2 Reverse Proxy Howto: Use Apache Web server acting as a reverse proxy to protect and redirect your internal Web services

The Goal:

For various situations, you may need to use a reverse proxy to protect or redirect your internal web services, this can done really easily with an Apache server!

For example, you have a home server and don't want to open directly outside connections to your server, you can use an third party to host theses Web services. (as for an example using a virtual host inside your own host)

You may also need this kind of configuration if your home server uses any VPN connection that redirect any outgoing traffic to the tunnel. (typical case and normal situation with any VPN public provide)

Let's resume some benefits:

  • Improves your Web services security with a third party server
  • Secure your Web services on third party server even if running non SSL on real server
  • Easily secure with SSL an embedded or non standard Web Service
  • Consolidates your Web services ports on third party server (example: a logical range on your proxy and any port on your real server)
  • Provides an answer to host Web services when you use a VPN provider that redirects all traffic to the tunnel

What you need:

  • A server hosting your web services (Any OS)
  • A third party: A another physical server or just a virtual host on your server
If you want to host a virtual machine on your server (Virtual-box, Vmware...), i recommend to choose a minimalist Linux distribution and server oriented, such as Debian or Ubuntu server.
You won't need any desktop interface, so just a minimalist and low resource consuming OS, Ubuntu server will be perfect.

Step 1: Configure your network and Third party server that will act as a reverse proxy

  • If you choose a virtual host, ensure to configure the Network interface using bridge mode, it will act as  a totally independent network interface as if it would be a real physical one
  • Configure your local router or firewall to open and redirect TCP ports to your Third party server (and not your real server)
Example of configuration:
  • Let's your server has following Web services : 80 (http), 443(https), 10190 (http)
  • And Your third party server (eg. Reverse proxy) will host: 10000(http), 10001(https), 10002 (htttps)
  • On your Router/Home Firewall/ISP Box, redirect all external traffic TCP ports 10000, 10001, 10002 to your Physical or Virtual Host acting as the Reverse Proxy

Step 2: Install Apache 2 and configure

  • Install Apache 2, openssl and requirements:
Install Apache 2 on Debian and derived systems:
sudo apt-get install apache2 openssl
Activate required Apache modules:
sudo a2enmod proxy proxy_http proxy_connect ssl
Deactivate defaults http and https sites (we don't need it and don't want it):
sudo a2dissite default
Configure Apache to listen to required ports:
edit "/etc/apache2/ports.conf" as follows:
NameVirtualHost *:10000
Listen 10000

NameVirtualHost *:10001
Listen 10001

NameVirtualHost *:10002
Listen 10002

Step 3: Configure your auto signed SSL certificate

Create your auto signed certificate to encrypt and secure Web traffic with SSL (use whatever you want when asked by openssl) :

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -out /etc/apache2/server.crt -keyout /etc/apache2/server.key

Step 4: Configure an "htpassword" file for simple authentication (at least recommended)

generate an .htpasswd file to protect your site by authentication (adapt your username) :

  • "-c" option will create a new file
  • "-m" option will use MD5 to secure password, by default htpasswd uses DES which will only consider first 8 characters 
sudo htpasswd -c -m /etc/apache2/.htpasswd username

Step 5: Configure and enable your Reverse proxy instances

Create your first reverse proxy site:
create a new file "/etc/apache2/sites-available/instance1_port10000 (adapt to your needs):
<VirtualHost *:10000>
  ProxyRequests Off
  ProxyVia Off
    <Proxy *>
     Order deny,allow
     Allow from all
  ProxyPass / http://MY PHYSICAL HOST:PORT
  ProxyPassReverse / http://MY PHYSICAL HOST:PORT
  <Location />
    Order allow,deny
    Allow from all
    AuthName "Access Restricted"
    AuthType Basic
    AuthUserFile "/etc/apache2/.htpasswd"
    Require valid-user
  LogLevel info
  CustomLog /var/log/apache2/access_XXXXXXX.log combined
  ErrorLog /var/log/apache2/error_XXXXXXX.log
  SSLEngine on
  SSLCertificateFile /etc/apache2/server.crt
  SSLCertificateKeyFile /etc/apache2/server.key

Enable the site:
sudo a2ensite instance1_port10000

Restart Apache:
sudo service apache2 restart (or "sudo apachectl restart" if you prefer)
Test your site by accessing https://<reverse_proxy_ip>:<instance_port>

You will be able to access with the same URL from both inside and outside locations without having to open direct connection from outside to your real server :-)

This is off course a real simple example you may easily use for your Home server, reverses proxy are very often used in Enterprise with others security mechanisms.

The purpose here is to provide a simple way to improve home Web services security and consolidate.

Thursday, June 28, 2012

VPN - Protect your personal Internet Traffic with a VPN Provider on your Home Linux Server (with auto check and reconnect shell script)

Protect your personal Internet Traffic with a VPN Provider on your Home Linux Server (with auto check and reconnect shell script)

The Goal:

I will not explain in details what's the benefit of a VPN (Virtual Private Network), a quick search on the Internet will easily answer to that question :)

Anonymity, confidentiality, accessing to Internet services closed to your own country, protecting your Internet traffic from being inspected by anyone or even your ISP... There may be thousands of good reasons to need a personal VPN !

Please do not hesitate to comment if you like, hate... or see any error, update required ! :-) 

What you need:

First of all, you need a VPN provider.
You will find a lot of provider offers on Internet, ensure enough servers and countries are provided and also if you expect to use on a Linux Home server, ensure openvpn protocol is provided. (you may also use pptp or l2tp but i not recommend it)

Take a look on quick google research and you will what you look for, i would personally recommend :
  • vyprvpn
  • hidemass (my great favorite, serious, stable and performer!=)

Step 1: Prepare your system

First, you need to install openvpn and openvpn additional requirements.
On Debian and derived (Ubuntu...) systems, this will be simply achieved:

sudo apt-get install openvpn

Step 2: Get your VPN provider configuration files

You will have to follow your provider's specific Howto to get needed configuration files.

In the case of Hidemyass as for an example, you will be able to choose between TCP or UDP configuration, i advise you to choose UDP because of the protocol itself you'll be expecting better inbound and outbound rates.

In the case of hidemyass, i recommend you to check their nice Wiki page:

And specific Linux page:

Step 3: Initiate your first connection

  • In "/etc/openvpn" create a text file "passwd.txt" that will contain credential information in 2 lines:

This file will contain your password in clear, and as far as i know it's possible to hash it...

  • For hidemyass (and probably any provider), you will have to extract all configuration files (including certificate files) to /etc/openvpn
  • Prepare each openvpn configuration file to include access to your password file:
cd /etc/openvpn
for i in `ls *.ovpn`; do echo "" >> $i && echo "auth-user-pass /etc/openvpn/passwd.txt" >> $i; done
NB: You will be able to connect without having to submit credentials
  • Choose a country configuration file, and create symbolic link to openvpn.conf:
ln -s NL.ROTTERDAM4-UDP.ovpn openvpn.conf
  • Initiate the connection:
sudo /etc/init.d/openvpn start
  • Check connection status:
If your connection is functional, you should have a new device called "tun0"

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet adr:  P-t-P:  Masque:
          Packets reçus:19 erreurs:0 :0 overruns:0 frame:0
          TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:100 
          Octets reçus:6751 (6.7 KB) Octets transmis:10242 (10.2 KB)
  • Test your Internet access

Step 3: Implement auto connection check and auto reconnect

These 2 scripts will automatically initiate the VPN connection, check its reliability by an icmp request to, in case of failure will stop it and try to reconnect.
  • Copy "watch_openvpn" to /etc/init.d/watch_openvpn
  • Attribute correct owner and rights:
sudo chown root:root /etc/init.d/watch_openvpn
sudo chmod 755 /etc/init.d/watch_openvpn
  • Copy to /etc/openvpn/
  • Attribute correct owner and rights:
sudo chown root:root /etc/openvpn/
sudo chmod 755 /etc/openvpn/
  • Add it to run levels:
sudo update-rc.d watch_openvpn defaults
  • Add some alias to manage your connection:
Edit ~/.bashrc and add:

alias vpnstart="sudo /etc/init.d/watch_openvpn start_vpn"
alias vpnstop="sudo /etc/init.d/watch_openvpn stop_vpn"
alias vpnstatus="sudo /etc/init.d/watch_openvpn status_vpn"
alias watchstart="sudo /etc/init.d/watch_openvpn start"
alias watchstop="sudo /etc/init.d/watch_openvpn stop"
alias watchstatus="sudo /etc/init.d/watch_openvpn status"
  • Optional: allow your user to manage VPN connection without providing credentials:
sudo visudo

Adapt your username and add:
user ALL=(ALL) NOPASSWD: /etc/init.d/watch_openvpn *

Logfile will be available in /var/log/openvpn.log

Do not hesitate to adapt these scripts to your needs!

Enjoy :-)

FAQ, issues and advices:

  • When my Linux home server is connected to my VPN, i can't access anymore to any hosted service! (eg. ssh remote access, web traffic, etc...)

Be aware that all your outgoing Internet traffic will be routed to the VPN, that means that any outside request to your server to a service port you have opened will be lost in the VPN tunnel.

There is no "easy" solution, in my opinion the better solution is to create a virtual machine in your host (using Virtualbox as for an example) that will use a bridge connection.

Your virtual machine will be considered as a normal host on the network and any outside connection will be correctly routed to your virtual host.

Moreover, this will improve your security by avoiding any direct connection to your server and jailing it into a virtual host.

You will be able to use your virtual host as an SSH gateway and finally connect to your real host.

Also, if you need to host any web service, you can simply use apache as a reverse proxy (on your virtual host) that will request your physical host.

 Example of a apache reverse proxy configuration with SSL:
<VirtualHost *:PORT>
  ProxyRequests Off
  ProxyVia Off
    <Proxy *>
     Order deny,allow
     Allow from all
  ProxyPass / http://MY PHYSICAL HOST:PORT
  ProxyPassReverse / http://MY PHYSICAL HOST:PORT
  <Location />
    Order allow,deny
    Allow from all
    AuthName "Access Restricted"
    AuthType Basic
    AuthUserFile "/etc/apache2/.htpasswd"
    Require valid-user
  LogLevel info
  CustomLog /var/log/apache2/access_xxxxxx.log combined
  ErrorLog /var/log/apache2/error_xxxxxxx.log
  SSLEngine on
  SSLCertificateFile /etc/apache2/server.crt
  SSLCertificateKeyFile /etc/apache2/server.key

  • How to find the better VPN server of my VPN provider with better download and upload rates ?
Hidemyass provides a Software with the capacity to give better servers for you...but unfortunately not for Linux !

You can use a simple shell script that will connect to each *.ovpn config file in your openvpn directory, then download a sample file and log download rates:

NB: Adapt it to your needs if required

# Speed test, launch as root

cd /etc/openvpn

> test_result.txt

for i in `ls *.ovpn`; do

echo "Speed test using VPN Server : $i "

echo "Stoping VPN"

/etc/init.d/watch_openvpn stop_vpn
sleep 2
rm openvpn.conf
ln -s $i openvpn.conf

echo "Starting VPN using $i"
/etc/init.d/watch_openvpn start_vpn
echo "sleeping 10 seconds..."

sleep 30

echo "Starting Test !"
echo "Testing VPN server $i :" >> test_result.txt
wget -o /tmp/wget.tmp -O /dev/null
grep '/dev/null' /tmp/wget.tmp >> test_result.txt
echo "Test Done." >> test_result.txt


echo "Test terminated !"

Then compare results and make your choice :)

Wednesday, June 27, 2012

XBMC Install and Config HOWTO for Linux on AMD Graphic Based Systems (FUSION) - XBMC XVBA

*** Updated July 02, 2013  ***

- AdvancedSettings synced to XBMC XVBA thread
- Catalyst section update
- 03/05/2013: PPA sections (since Frodo is now the official realse), note about CPU load with advanced themes, Typo corrections
- 02/03/2013: Various updates
- 07/01/2013: Catalyst 12.10 included, Splashscreen correction, ACPI extinction addon
- 12/28/2012: grub fail boot timeout procedure
- 12/03/2012: Internal IR config correction
- 10/22/2012: Add Catalyst Legacy section for outdated Radeon HD graphics (previous to HD5000)
- 10/17/2012: Internal IR receiver for Zotac
- 10/13/2012: Catalyst 12.9 Quantal 
- 24/09/12: Integration of Zotac NANO XS AD11
- 20/09/12: Catalyst 12.9 BETA update
- Link to share and sync Media Library using Mysql and Samba
- Catalyst 12.8 update
- Sound configuration in Eden
- ASIC bug hand fixed in all branches
- System tuning to improve performances
- XBMC integrated to your Web Browser
- XBMC integrated access to amdcccle
- XBMC integrated access to a File Manager
- Correcting troubles with shipped Zotac MCE remote control

Edit April 04, 2013: Ubuntu 13.04 is out, don't use it as for now, there is no ATI Catalyst driver suitable for it, all recent versions are bugged and will result in CPU Overload.
Don't use 13.03, Keep 12.10. (or 12.04)

Edit 10/23/2012: Ubuntu 12.10 TLS is now out, i am currently checking all steps but this guide should still be applicable without major correction required

Major source:

Thanks to people working on XBMC for fusion systems!
For any issue with XBMC XVBA, this is the place to go ^^

You will also find my Howto in official Xbmc Wiki :

Please comment if you like, comment if you find any error or correction required :-) 

Summary of steps:

Step 1: Install, optimize and tune your base Linux system 
Step 2: Install some requirements 
Step 3: Install ATI proprietary driver
Step 4: Install XBMC
Step 5: First XBMC start and base configuration
           Step 5.a: Proceed to base settings
           Step 5.b: Install Network Manager Addon (Optional)
Step 6: Optimize XBMC CPU usage and configure GPU sensor
Step 7: Configure Audio
Step 8: Configure Power Management
Step 9: Configure your Video Media Library and Home access screens using Smart Playlist
Step 10: Optional - Integrate a Web browser inside XBMC
Step 11: Optional - Integrate a file manager inside XBMC
Step 12: Configure Network services: UPnP, Airplay, XBMC web control interface
Step 13: Configure Remote Control
Step 14: Optional - Use Live TV

Installation and configuration of XBMC on Ubuntu based OS with AMD HD Graphics (tested with Zotac AD02, AD10, AD11 - Should work with any AMD based hardware)

The Goal:

Installing and configuring all the necessary to get a fully functional, stable and great XBMC media center on AMD Plateform using proprietary ATI driver and Hardware acceleration.


This configuration guide has been tested under Ubuntu based OS running 11.10 TLS and 12.04 TLS (desktop versions of Xubuntu and Lubuntu, Ubuntu Minimal)


This configuration guide has been tested on Zotac AMD Based HTPC: ZOTAC AD02, ZOTAC NANO AD10 and ZOTAC NANO XS AD11.
This is expected to work on any recent enough fusion system.

These HTPCs have quite the same hardware capacity; One major difference is the included and optional USB IR receiver for Zotac AD10/AD11, associated with its nice MCE remote control.
Also, only Zotac AD02/AD10 have an SPDIF output to serve Digital sound, digital sound for Zotac AD10 has to be achieved using HDMI output. (still you can buy an external USB sound card if you want SPDIF)

Both of them are embedded with an AMD E350 CPU with ATI Radeon HD able to deal with 1080p video and 5.1 Digital audio :-)

Zotac AD02 Model : AMD E-350 APU Platform (dual-core) (1.6 GHz) AMD Radeon™ HD 6310

Zotac NANO AD10 Model : AMD E-350 APU Platform (dual-core) (1.6 GHz) AMD Radeon™ HD 6310

Zotac NANO XS AD11 Model : AMD E-450 APU Platform (dual-core) (1.6 GHz) AMD Radeon™ HD 6320

Step 1: Install, optimize and tune your based Linux system

Important Note for Zotac Devices:

Last Zotac UEFI have introduced an option to set the UMA frame buffer size.
This setting will be used to set allocable Physical Memory for the graphic component.

By default, the size set may be to small and prevent you from being able to correctly playback HD files.

Please Go at the end of this post in Memorandum section to see how to change UMA Frame Buffer size, i personally recommend to set it at 1GB to prevent any playback issue.

For other devices:

 you still may have to check or set your UMA Frame Buffer Size, set to the higher value available on your hardware.

Choose and install your system:

First choose your Ubuntu version to install. This guide will only be fully applicable with an Ubuntu based version.

I will not cover the OS installation itself as there is a lot of tutorials on this subject and installation is enough easy right now.

I do not recommend using Ubuntu classic version as it provides by default a very resource consuming interface (Unity) and has a lot of problems and bugs running ATI proprietary driver!

As far as I know and as far as I have tested, the only Ubuntu bases distributions with absolutely no issue with the ATI proprietary driver are:
  • Xubuntu : Ubuntu based version with XFCE desktop
  • Lubuntu : Ubuntu based version with LFCE desktop
  • Ubuntu Minimal: Ubuntu minimal installation, you will NOT have a desktop with it (by default)

Installation advises:

3 partitions :
  • A first partition for the root system ( / )
  • A second partition for home (/home)
  • A small Swap partition (1 or 2 GB will largely be enough, a such system is not expected to really swap in normal conditions)
  • Install Third party software (mp3 and so on)
  • In the installation Software, use “xbmc” as a the login
  • Activate auto login for the user "xbmc"

After your based installation has achieved, ensure you are fully up to date:
Update your system:
sudo apt-get update
sudo apt-get dist-upgrade –y
sudo reboot

If you installed Ubuntu Minimal:
sudo apt-get install ssh python-software-properties udisks upower xorg alsa-utils mesa-utils git-core librtmp0 lirc libmad0 lightdm lightdm-gtk-greeter lm-sensors
sudo adduser xbmc video
sudo adduser xbmc audio

Install SSH and set your Network configuration (optional set a static IP if you prefer):
sudo apt-get install ssh

If you want to set a static IP instead of using DHCP (after installation):

Edit the /etc/config/interfaces file Comment out the line iface eth0 inet dhcp (or whatever your network adapter hardware device is)
Configuration example:

iface eth0 inet 
static address 

Optional: Network Manager 

If you use Ubuntu Minimal and want to be able to set your Wifi connection from XBMC, you can use an XBMC addon called "Network Manager", it requires package from the same name:
sudo apt-get install network-manager

Note for Wireless Interface on Zotac AD10:

The Zotac AD10 comes with different Wireless interfaces, depending on the model you shipped:
  • Atheros chipset: Working out of the box in Ubuntu 12.04
  • RT2860: Manual installation required
If the Blue led in front of your Zotac is not powered on, then your Wireless interface is off and you can be sure you have an RT2860 chipset. (you can check with "lsusb")

To manually install the driver, do as follows (thanks for people how commented it out)

tar -zxvf NB*.tar.gz
sudo make 
sudo make install
cd os/linux
insmod rt3290sta.ko
sudo reboot

Optimize your system:

1. Disable access time for more filesystem performances

For each ext4 filesystem, edit your /etc/fstab and add "noatime" in mount options, example:
# / was on /dev/sda1 during installation                                      UUID=affe0f48-6b88-43a5-b131-20a58cd776b8 /   ext4    errors=remount-ro,noatime  0       1         

2. If you have an SSD:

  • Go in UEFI (new BIOS) and ensure to set your Sata mode to "AHCI"
  • Edit your fstab to add "discard" in mount options for each partition on your SSD, this will enable TRIM, example:
# / was on /dev/sda1 during installation
UUID=affe0f48-6b88-43a5-b131-20a58cd776b8 /   ext4    errors=remount-ro,noatime,discard  0       1              

For more information, see:

3. If you have a large amount of RAM (beginning on 2GB), tune swapiness

For more information, see:

Add theses values to /etc/sysctl.conf:

4. Turn /tmp into tmpfs to use RAM instead of HDD or SSD

Using this you will turn your "/tmp" directory (used by many programs as their temp directory) into a tmpfs, which means this will reside into you virtual memory instead of the HDD or SSD partition

Edit /etc/fstab and add:
# tmpfs
tmpfs   /tmp    tmpfs   defaults,noatime,mode=1777      0       0

You may see on different posts people also turning /var/tmp, /var/run and others into a tmpfs.
This not useful anymore as it has been turned aleready into a tmpfs in recent distributions. (they are all linked into /run which is into a tmpfs)

Use "mount" to see all mounted tmpfs, you should now see /tmp and /run mounted that way.

If you are using XFCE as the Window Manager (eg. Xubuntu or XCFE manually installed), you should deactivate "compositing":

  • Under your Session, go to parameters > Window Manager Tweaks and disable compositing


Tune your system:

Modify your grub configuration to ensure your system will always boot even after dirty reboot:

20121228: Updated to 12.10 Ubuntu by modifying grub default:

After a bad boot (hard reset or any problem encountered bu the system during last reboot), by default grub will wait for a user action to select and use the boot option.

This can be easily corrected with the good option in grub default file (thanks to the anonymous comment).

Edit "/etc/default/grub" and add: (change the timeout value to the value of your choice)

In case of dirty reboot, grub will wait 10 seconds before processing to the default boot.

Update grub:
sudo update-grub

Replace the system splash screen with an XBMC related:

Edit 01/07/2012: Thanks to Nick, Splash screen may be broken after Grub install / updates, please follow the instruction in case you have an issue

Edit 10/24/2012: If this does not work for you (you get some strange screen or nothing moving) please try a lower resolution.

You may prefer to replace your OS default splash screen by the XBMC splash screen:

sudo apt-get update
sudo apt-get install plymouth-label v86d
sudo dpkg -i plymouth-theme-xbmc-logo.deb

Create "/etc/initramfs-tools/conf.d/splash" and add:

Choose you Resolution mode:

- "720x480"
- "720x576"
- "1280×720"
- "1366x768"
- "1920x1080"

Edit "/etc/initramfs-tools/modules", adapt to your resolution, example with 1280x720:
uvesafb mode_option=1280x720-24 mtrr=3 scroll=ywrap

Edit your default grub configuration file "/etc/default/grub", adapt your resolution, example with 1280x720:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset video=uvesafb:mode_option=1280x720-24,mtrr=3,scroll=ywrap"


Update grub and initramfs:
sudo update-grub
sudo update-initramfs -u

Reboot and voila, you've got the XBMC boot screen logo ^^

If it does not work:

Create the script "" with the following content:
#! /bin/bash
# Fix Ubuntu Plymouth Boot Splash 
# if entry exists for $vt_handoff use sed to search and replace
# write to tmp file - move to original 

checkVT=$(grep -c "\$vt_handoff" /boot/grub/grub.cfg)

if [ ! "$checkVT" -eq "0" ] 
echo "> Found vt_handoff removing ..."
sudo sed 's/$vt_handoff//g' /boot/grub/grub.cfg > /tmp/.grub.cfg
sudo mv /boot/grub/grub.cfg /boot/grub/grub.cfg.backup
sudo mv /tmp/.grub.cfg /boot/grub/grub.cfg

echo "> Done"

Make it executable:
sudo chmod +x

And execute:

sudo ./

Reboot and that should work, remember to execute this every grub update.
For more explanation, see Nick's comment in date of December 30, 2012 3:38 PM

Multiboot Configuration : XBMC related Splashscreen

If you have Multi-Boot, you may also want to have a grub splashcreen related to XBMC! (just because it's beautiful or just because you can :-)

Download this file (png type, usable by grub):

Install "grub-customizer" to set the grub splashcreen, it's a great tool that allow you to manage grub:
sudo add-apt-repository ppa:danielrichter2007/grub-customizer && sudo apt-get update && sudo apt-get install -y grub-customizer

Open grub-customizer and set the grub splashcreen, go to preference and set the splashcreen:

If you installed Ubuntu Minimal, configure automount:

Create the file "/etc/polkit-1/localauthority/50-local.d/custom-actions.pkla":
[Actions for xbmc user]

Add xbmc user to group "users":
sudo adduser xbmc users

Create the file /etc/udev/rules.d/11-media-by-label-auto-mount.rules:
# Start at sdb to avoid system harddrive. 
KERNEL!="sd[b-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit


Step 2: Install some requirements

If you installed a full desktop version (Xubuntu, Lubuntu...):
sudo apt-get install ssh python-software-properties udisks upower xorg alsa-utils mesa-utils git-core librtmp0 lirc libmad0 lm-sensors lib32gcc1 libc6-i386 dkms libbluray1

If you installed Ubuntu Minimal:
sudo apt-get install ssh python-software-properties udisks upower xorg alsa-utils mesa-utils git-core librtmp0 lirc libmad0 lightdm lightdm-gtk-greeter lm-sensors dpkg-dev debhelper execstack dh-modaliases libqtgui4 libbluray1

NB : For lirc, when wizard asks you to choose your hardware in our case we will configure it later so you can choose none... If you already know how to configure lirc and your hardware you may want to choose the right one.

Step 3: Install ATI proprietary driver (required for XVBA Hardware acceleration)

Important Note about ATI Catalyst Driver versions, extract from XBMC XVBA main thread:

Every driver after 12.11 (xorg 1.12 only) and 12.9Quantal(xorg 1.13 shipped with Ubuntu 12.10) is broken. It causes 100% CPU usage with enable vsync.
There is currently no driver that can be installed for Ubuntu 13.04 - don't use this version.
Currently you have the choice to use Ubuntu 12.04 and manually install Catalyst 12.11. Alternatively you can install 12.10 and keep the provided driver (fglrx 9.0.0ubuntu3). Ubuntu 13.04 ships with Catalyst 13.1 that is broken, Catalyst 13.4 is also broken. Every other Catalyst release / beta since then is also affected.
In short: Don't use Ubuntu Raring.


To install ATI driver, you will have 2 possibilities, installing the driver using official Ubuntu repository or installing the Catalyst driver manually downloaded from AMD.

My preference is to use to manual way as i want to be certain to use the version i decided, and also i want to keep the control on it, but both solutions are ok.

Edit 10/22/2012 - Non anymore supported Radeon HD (previous to HD5000): ATI does not support anymore graphic component previous to HD5000 (eg. Radeon HD4200, 4800...)
If you have one, please Go to memorandum "Install Catalyst Legacy for non supported ATI cards) at the end of this post

Using Ubuntu Repository packages:

NOT RECOMMENDED for Ubuntu 12.04 TLS

RECOMMENDED for Ubuntu 12.10 TLS (don't use this with graphic cards previous to HD5000)

Installing ATI proprietary driver using Ubuntu package:

Real simple, just use:
sudo apt-get install fglrx

Then execute configuration. (see above)

Under Ubuntu 12.10, you can consider this method with no problem. (still you can also choose the above manual installation)

    Manual installation:

    RECOMMENDED for Ubuntu 12.04 TLS

    USELESS for Ubuntu 12.10 TLS

    Installing ATI proprietary driver manually (Recommended):

    *** Important remark ***

    A small history of recent Catalyst releases:

    - Catalyst 12.6 : Works fine but has issue with missing graphic cards reference, needs to overwrite signature file with 12.4 signature
    - Catalyst 12.8 : has XVBA broken
    - Catalyst 12.9 official Beta : Suspend broken
    - Catalyst 12.9 Quantal : Works good
    - Catalyst 12.10 official release: Said to be the better for 12.04
    - Catalyst 12.11 official release: Works good

    Any version after 12.11 is bugged and will generate a CPU Overload, don't use it as for now.

    For a fresh install (eg. the first time you install ATI driver on your system):

    For Ubuntu 12.04 TLS:

    I recommend ATI Catalyst 12.10:

    Official Release: ATI Catalyst Version 12.10 (Release Version):
    • Download, Build packages and install 12.10 Driver:
    cd ~/; mkdir catalyst12.10; cd catalyst12.10/
    chmod +x amd-driver-installer-*.run
    sudo sh ./amd-driver-installer-*.run --buildpkg
    sudo dpkg -i fgl*.deb

    Quantal Beta version: ATI Catalyst Version 12.9

    Don't use this method with Ubuntu 12.10 (use the repository method version above), this method is for Ubuntu 12.04:

    Beta Release (use at your own risk, but known to be good) - ATI Catalyst Version 12.9 BETA (Ubuntu Quantal Version, updated September 2012): 

    Thanks to Fritsch! ^^
    • Download, Build packages and install 12.9 BETA Driver using Quantal sources packages:
    sudo apt-get install xserver-xorg-dev
    mkdir catalyst_12.9_quantal_ubuntu3 && cd catalyst_12.9_quantal_ubuntu3
    mkdir tmp && cd tmp
    tar xvfz fglrx-installer_9.000.orig.tar.gz
    tar xvfz fglrx-installer_9.000-0ubuntu3.debian.tar.gz
    mv *.tar.gz ../
    dpkg-buildpackage -us -uc
    cd ../
    sudo dpkg -i *.deb

    Then execute configuration. (see above)

    Official Release: ATI Catalyst Version 12.8 (Release Version):
    • Download, Build packages and install 12.8 Driver:
    cd ~/; mkdir catalyst12.8; cd catalyst12.8/
    chmod +x
    sudo sh ./ --buildpkg
    sudo dpkg -i fgl*.deb

    Then execute configuration. (see above)


    *** PAY ATTENTION: STOP X11 before applying ATI config  - Required if you use Desktop Version ***

    Go in terminal using SSH from another computer or by switching to local console (CTRL+ALT+F1)

    Don't stay under the desktop as stopping X11 will put you out :-)

    If X11 is started, Stop X11:
    sudo service lightdm stop
    Create xorg configuration file:
    sudo aticonfig --initial -f
    sudo aticonfig --sync-vsync=on
    sudo aticonfig --set-pcs-u32=MCIL,HWUVD_H264Level51Support,1

    Black borders:

    Optional : Depending on your configuration and TV / Screen, you could have black borders and XBMC does not fit the screen, then try to disable Underscan:
    sudo aticonfig --set-pcs-val=MCIL,DigitalHDTVDefaultUnderscan,0

    Edit 24/09/2012: If you still have borders scan issues, go to:

    Restart X11 or (better) reboot

    For an upgrade from previous Catalyst version:

    If this is not a fresh install and you already have a previous Catalyst version installed (eg. Upgrade from 12.6 for example), you have 2 options:

    1. Upgrading packages (if hopefully you installed the driver by the recommended way to generate packages ^^)

    Note: you can have a small issue with version of driver shown by amdcccle but easy to solve

    To  upgrade installed packages by the new one you just generated, just follow the normal installation and restart X11 if started.

    When you open amdcccle, if you see the previous Catalyst version shown as installed, just remove "/etc/ati/amdpcsdb" and restart X11 (you will lose custom settings such as brightness, etc...)
    If you re-open amdcccle, the new driver version will be correctly shown.

    2. Totally remove and clean ATI and install the new version

    Note: you will loose your custom settings unless to backup and restore "/etc/ati/amdpcsdb" 

    To completely remove
    • Stop X11 and go in terminal with ssh or console: sudo service lightdm stop
    • Uninstall any previous package: sudo apt-get remove --purge xorg-driver-fglrx fglrx*
    Note: In my system, apt-get will aslso remove "xbmc" package (and not xbmc-bin), just think to "sudo apt-get install xbmc" after you're done :-) 
    You won't loose any xbmc setting.
    • And follow installation above
    • When you open amdcccle, if you see the previous Catalyst version shown as installed, just remove "/etc/ati/amdpcsdb" and restart X11 (you will lose custom settings such as brightness, etc...)

    Step 4: Proceed with XBMC installation using pre-compiled packages built for ATI

    This procedure will add a ppa containing pre-compiled XBMC versions with XVBA support and install XBMC.

    Edit March 5, 2013: Frodo is now officially released, don't choose Eden version unless you really have a reason for this

    Install the ppa:

    Choose the ppa correspoding to your needs:
    • xbmc-xvba-eden: Stable Eden version, H264 Level5.1 fix not included but supported (when you configured aticonfig in steps before) and Audio Engine not included
    sudo add-apt-repository ppa:wsnipex/xbmc-xvba-eden

    • xbmc-xvba: XBMC Stable Frodo Version (XBMC 12)
    sudo add-apt-repository ppa:wsnipex/xbmc-xvba-frodo
    • xbmc-xvba-testing: Frodo XVBA Testing Version, not recommended for normal users:
    sudo add-apt-repository ppa:wsnipex/xbmc-xvba

    Press enter to valid adding the ppa you choosed:


      Update and install:
      sudo apt-get update$ sudo apt-get install xbmc xbmc-bin
      Allow xbmc user to change its nice level:

      edit /etc/security/limits.conf add the following line at the end of the file
      xbmc              -        nice              -1

      If you installed Ubuntu Minimal, set the Xsession to automatically start with XBMC:

      Install the Window Manager:
      sudo apt-get install lightdm lightdm-gtk-greeter
      sudo adduser xbmc video
      sudo adduser xbmc audio

      Edit /etc/lightdm/lightdm.conf:

      Check the content of /usr/share/xsessions/XBMC.desktop, should be:
      [Desktop Entry]
      Comment=This session will start XBMC Media Center

      If you installed a desktop version (Xubuntu, Lubuntu), set your session to automatically start with XBMC:
      • Go to your session configuration and add a entry that simply calls "xbmc" command

      Reboot or start lightdm (sudo service lightm start).

      Step 5: First start of XBMC and base configuration

      Step 5.a: Proceed to base settings
      • Open XBMC
      • In Appearance / skin, I recommend “AEON NOX” (In my opinion the better theme!)
      Note about CPU usage under Aeon Nox (and potentially various themes):

      Keep in mind that any advanced theme like Aeon Nox will consume more CPU than the default confluence XBMC theme.
      I don't feel it as a problem, but more as poor price to pay when you want to have various advanced options, functions and want to get a wonderful media center solution.

      My XBMC box (a Zotac AD02, not a real powerful computer in itself but very great at this job) is running 24 hours a day and also hosts various services (Apache instances, Splunk server, Observium, Owncloud and Ajaxplorer, sabnzbd and others) and it's working so good even with an high CPU load.
      You should not be afraid about having an high CPU load with XBMC, it will still be very fluid and doesn't have anything to matter with Video Quality or decoding... (Which will uses the GPU thanks to hardware acceleration)

      • In Appearance, adapt your language if required

      • In System->Settings->System->Video Settings:
      Vertical Sync: Always on

      • In System ->Video->Playback:

      XVBA: On
      Adjust Refreshrate to match video: On
      Sync Playback to Display: On
      Sync Method: Video Clock (Drop/Dupe)

      Step 5.b: Install Network Manager (Optional)

      Manage your WIFI connection with Network Manager:

      With XBMC Addon "Network Manager", you can manage your Wifi setup directly inside XBMC, this may be very useful if you installed Ubuntu Minimal as you don't directly have a desktop available.

      Note: For Ubuntu Minimal, see above and ensure you installed Network Manager

      Go to Addon and install the addon called: "Network Manager"
      To set it up, open the addon in addon page.

      Step 5.c: Access ATI graphical configuration tool (amdcccle) inside XBMC (Optional)

      *** If you are using XFCE as the Window Manager (eg. under Xubuntu) you have to deactivate compositing (settings > Window Manager tweaks > Disable compositing)   ***

      This optional but if you installed Ubuntu Minimal (and even with desktop versions), it is very useful to be able to easily access to amdcccle directly inside XBMC.
      • First authorize your XBMC user to launch amdcccle as root and without having to provide root's password:
      Add sudo right using visudo:
      sudo visudo

      Add this line, save and exit:
      xbmc ALL=(ALL) NOPASSWD: /usr/bin/amdcccle

      Create a simple shell script "" that will be used by advanced launcher:
      sudo amdcccle

      Make it executable:
      chmod +x ~/Scripts/

      • Install the addon "Advanced Launcher" (addon / program addons)

      Note: You can manually create the launcher using Advanced Launcher, just ensure not to let any command argument (provided by default).
      I feel more simple to use the configuration file i provide but this is optional...

      create addon dir if does not exists yet:
      mkdir -p ~/.xbmc/userdata/addon_data/plugin.program.advanced.launcher

      create  the file "launcher.xml" with the following content:

      edit: "~/.xbmc/userdata/addon_data/plugin.program.advanced.launcher/launchers.xml" and adapt "MY VOLUME":
      <?xml version="1.0" encoding="utf-8" standalone="yes"?>
      • Add your launcher to favorites (Go in addon / Advanced Launcher and right click add to favorites upon chromuim)
      • Go to skin configuration: settings>skins
      • Add a custom page and call it as you want, example: ATI CONFIG
      • Set a nice wallpaper
      • And test!


      Step 6: Optimize XBMC CPU usage and configure GPU sensor

      Enable Dirty Region Rendering (drastically reduces CPU load on XBMC idle) and DDS Fanart NOTE: do not do this as root or with sudo. this file must belong to your normal xbmc user
      create: ~/.xbmc/userdata/advancedsettings.xml
         <loglevel hide="false">0</loglevel>
        <cputempcommand>sensors|sed -ne "s/temp1: \+[-+]\([0-9]\+\).*/\1 C/p"</cputempcommand>
        <gputempcommand>/usr/bin/aticonfig --od-gettemperature | grep Temperature | cut -f 2 -d "-" | cut -f 1 -d "." | sed -e "s, ,," | sed 's/$/ C/'</gputempcommand>
            <delay>175</delay> <!-- set to zero or adjust if audio seems out of sync with 24p movies -->

      Step 7: Configure Audio

      First of all, know your system:

      The first thing you have to do is to know your system and configuration.
      So, begin to identify your sound interface references using the command line "aplay".

      Method 1:

      Using the command "aplay -L" (high case) will produce all required information, example:

          HD-Audio Generic, HDMI 0
          HDMI Audio Output
          HD-Audio Generic, HDMI 0
          Direct sample snooping device

      With these commands, you can easily know what will be the interface reference you need to know, using the example above, if i want to use:

      - HDMI for sound ouput, my interface should be "hdmi:CARD=Generic,DEV=0", identified by HD-Audio Generic, HDMI 0

      - SPDIF for sound ouput, my interface should be "hw:CARD=SB,DEV=1", identified  by HDA ATI SB, ALC892 Digital

      Method 2:

      Using the command "aplay- l" you can also identify your soundcard:

      **** Liste des Périphériques Matériels PLAYBACK ****
      carte 0: Generic [HD-Audio Generic], périphérique 3: HDMI 0 [HDMI 0]
        Sous-périphériques: 1/1
        Sous-périphérique #0: subdevice #0
      carte 1: SB [HDA ATI SB], périphérique 0: ALC892 Analog [ALC892 Analog]
        Sous-périphériques: 1/1
        Sous-périphérique #0: subdevice #0
      carte 1: SB [HDA ATI SB], périphérique 1: ALC892 Digital [ALC892 Digital]
        Sous-périphériques: 1/1
        Sous-périphérique #0: subdevice #0

      You interfaces would also be accessible through (most cases):
      • HDMI: plughw:0,3
      • SPDIF: plughw:1,1

      If you are using "xbmc-xvba-eden":

      The Audio Engine isn't included in Eden version, so you will have to set the device using custom device with the interface reference you got above.

      The old way was to create a custom sound configuration file (.asoundrc) containing required information and then set XBMC to use this custom interface.

      This is not required anymore with Eden, you can now set it using the reference you got using the command line "aplay".

      For references only, i let 2 examples of asoundrc for Zotac-AD02 using SPDIF and Zotac-AD10 using HDMI. (you can still choose this option if can't get the sound to work with the new method)

      THE OLD WAY:

      Zotac-AD02 using SPDIF (As xbmc user, create a new file in your home: ~/.asoundrc)
      pcm.dmixer {
          type dmix
          ipc_key 1024
          slave {
              pcm "hw:1,1"
              period_time 0
              period_size 1024
              buffer_size 8192
              rate 48000
           bindings {
              0 0
              1 1
      pcm.!default {
         type plug
         slave.pcm "dmixer"

      Restart XBMC, in Settings>System>Audio Output:
      • Audio Output: Optical/Coax
      • Speaker Configuration: 5.1
      • Audio Output Device: Custom
      • Custom Audio Device: plug:dmixer
      • Passthrought Output Device: Custom
      • Custom Passthrought Device: plug:dmixer

      Zotac-AD10/AD11 using HDMI (As xbmc user, create a new file in your home: ~/.asoundrc)
      pcm.dmixer {
         type dmix
         ipc_key 1024
         ipc_key_add_uid false
         ipc_perm 0660
         slave {
            pcm "hw:0,3"               #HDMI, defaults to 48000 kHz
            channels 2
            period_size 1024
            buffer_size 4096
      pcm.!default {
         type plug
         slave.pcm "dmixer"

      Restart XBMC, in Settings>System>Audio Output:
      • Audio Output: HDMI
      • Speaker Configuration: 5.1
      • Audio Output Device: Custom
      • Custom Audio Device: plug:dmixer
      • Passthrought Output Device: hdmi (alsa)

      THE NEW WAY:

      Get your interface reference (using aplay, see above), and set XBMC correctly.

      Adapt to your configuration: 2.0 or 5.1 sound system, AC3 / DTS capable device...

      UNLESS YOU NEED IT, you should uninstall pulseaudio to avoid some problems

      To uninstall pulseaudio:
      sudo apt-get remove pulseaudio

      Recommended Method using "plughw" devices: (there is other methods but this is the one i recommend and works the best)

      If you don't get to work that way, try using the 2nd method (that identifies your card using aplay -l):

      Example HDMI:

      • Audio Output: HDMI or Optical (try both)
      • Audio Output Device: Custom
      • Custom Audio Device: plughw:0,3
      • Passthrought Output Device: Custom
      • Custom Passthrought Device:  plughw:0,3

      Example SPDIF:

      • Audio Output: Optical
      • Audio Output Device: Custom
      • Custom Audio Device: plughw:1,1
      • Passthrought Output Device: Custom
      • Custom Passthrought Device:  plughw:1,1

      Note: If you don't get menu sounds that way, create the ".asoundrc" file as explained in the old way, you system will use default PCM for system sounds

      If your connection between your TV and your sound system is not numerical (usually SPDIF), you probably have to use 2.0 speaker configuration and analogic instead of optical/HDMI

      If you are using "xbmc-xvba" or "xbmc-xvba-testing":

      The Audio Engine is included in the build, getting the sound to work should be much easier!

      You can proceed the same way than above, or (perhaps better) use the integrated Audio Engine.

      UNLESS YOU NEED IT, you should uninstall pulseaudio to avoid potential issues in Linux

      To uninstall pulseaudio:
      sudo apt-get remove pulseaudio

      You can identify your Alsa device references (hardware and sub-hardware) using the commande "aplay -l".

      Then, i advice you to start XBMC and check the log file, you will see all devices scanned by the Audio Engine.

      Launch XBMC and open your logfile "~/.xbmc/temp/xbmc.log", you will see something like that:
      02:51:50 T:140653859886976  NOTICE: Enumerated ALSA devices:
      02:51:50 T:140653859886976  NOTICE:     Device 1
      02:51:50 T:140653859886976  NOTICE:         m_deviceName      : @
      02:51:50 T:140653859886976  NOTICE:         m_displayName     : Default (HDA ATI SB ALC892 Digital) ()
      02:51:50 T:140653859886976  NOTICE:         m_displayNameExtra:
      02:51:50 T:140653859886976  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
      02:51:50 T:140653859886976  NOTICE:         m_channels        : FL,FR
      02:51:50 T:140653859886976  NOTICE:         m_sampleRates     : 96000
      02:51:50 T:140653859886976  NOTICE:         m_dataFormats     : AE_FMT_S16NE,AE_FMT_S16LE
      02:51:50 T:140653859886976  NOTICE:     Device 2
      02:51:50 T:140653859886976  NOTICE:         m_deviceName      : dmixer
      02:51:50 T:140653859886976  NOTICE:         m_displayName     : HDA ATI SB ()
      02:51:50 T:140653859886976  NOTICE:         m_displayNameExtra: ALC892 Digital
      02:51:50 T:140653859886976  NOTICE:         m_deviceType      : AE_DEVTYPE_PCM
      02:51:50 T:140653859886976  NOTICE:         m_channels        : FL,FR
      02:51:50 T:140653859886976  NOTICE:         m_sampleRates     : 96000
      02:51:50 T:140653859886976  NOTICE:         m_dataFormats     : AE_FMT_S16NE,AE_FMT_S16LE
      02:51:50 T:140653859886976  NOTICE:     Device 3
      02:51:50 T:140653859886976  NOTICE:         m_deviceName      : hdmi:CARD=Generic,DEV=0
      02:51:50 T:140653859886976  NOTICE:         m_displayName     : HD-Audio Generic
      02:51:50 T:140653859886976  NOTICE:         m_displayNameExtra: HDMI
      02:51:50 T:140653859886976  NOTICE:         m_deviceType      : AE_DEVTYPE_HDMI
      02:51:50 T:140653859886976  NOTICE:         m_channels        : FL,FR
      02:51:50 T:140653859886976  NOTICE:         m_sampleRates     : 32000,44100,48000
      02:51:50 T:140653859886976  NOTICE:         m_dataFormats     : AE_FMT_S16NE,AE_FMT_S16LE

      Upon this point if you know a little bit your hardware, it will really easy to set the device you will use inside XBMC.

      In my example case (AD02 in SPDIF), i know my hardware is "hw1;1", so i can choose any device listed and related to this Hardware and test, i can also simply use the configured device in .asoundrc.

      You also have to set the Audio Passthrough. (see above)
      XBMC will automatically provide you available devices in the passthrough section, the choice should be easy enough.

      NOTE as of 02/03/2013:  ATI Catalyst driver isn't yet able to play HD (True HD and DTS-HD), so unset these 2 boxes

      Note: if your are using a .asoundrc file, you will also see referenced devices.

      Step 8: Configure power management to allow shutdown and others power management functions from XBMC

      Edit 01/07/2013: Thanks to Nick, added config to allow extinction from power button pressure

      Edit 09/29/2012: This does not seem to be required anymore with last update systems, try first to use Shutdown/Reboot from XBMC.
      If it does not work, then follow these steps

      Shutting down from XBMC:

      Without configuring it, you should not be able to shutdown or suspend your system directly from XBMC 

        Install requirements:
        sudo apt-get install policykit-1 upower acpi-support

        Edit 10/26/2012: Thanks to Lorenzo, correction for Ubuntu 12.10

        For Ubuntu 12.04:

        Create a new file "/var/lib/polkit-1/localauthority/50-local.d/custom-actions.pkla":
        [Actions for xbmc user]
        • Restart XBMC and try power management functions such as shutdown

        For Ubuntu 12.10:

        Create a new file "/etc/polkit-1/localauthority/50-local.d/xbmc_shutdown.pkla ":
        [Actions for xbmc user]
        • Restart XBMC and try power management functions such as shutdown

        You may have to do more configuration if you need wake up from USB connected devices, in my case with the Zotac AD10 and using remote control, i did not had to and powering up was working from remote control.

        Suspend / Hibernate from XBMC:

        Suspending or Hibernating does not always works, depends on your hardware and is still a cause of trouble as for now.

        Edit 10/26/2012: Catalyst 12.9 Quantal Ubuntu version seems to correct suspend issue, if you plan to use this function think about using this Catalyst version

        You can try this workaround, but with no guarantee to work:

        add a new file /etc/pm/sleep.d/99_fglrx
        case $1 in
                /usr/sbin/service lightdm stop
                /sbin/rmmod -f fglrx
                /sbin/modprobe fglrx
                /usr/sbin/service lightdm start

        make the file executeable:
        sudo chmod +x  /etc/pm/sleep.d/99_fglrx

        Allow system extinction from Power Button pressure 

        (See Nick comment in date of December 30, 2012 3:38 PM):

        Edit "/etc/acpi/events/powerbtn" and proceed to following modifications:

        • Comment the line "action=/etc/acpi/" by adding #
        • Add a new line: action=/sbin/poweroff
        • Save

        And finally execute:

        sudo acpid restart

        Step 9: Configure your Video Media Library and Home access screens using Smart Playlist

        Edit 09/09/2012:
        If you are planing to have multiple XBMC installation in your Network, you may be interested in sharing and syncing your Media Library.
        Take a look at my article:

        I will present the way i do which is absolutely personal and you may want to do completely differently ^^ 

        Probably you will have: 
        • One and probably various external storage
        • Films, but also anime for kids, music videos, comics shows and so on...
        Using the XBMC's library function associated with Smart Playlist, you will be able (assoiated with a scrapper) to automatically get film's pictures and information, so you absolutely need to organize all that.
        You can have as for an example your film's library splitted in various external storage ! 

        I Recommend:
        • Use the same directory organisation for each external storage, example:
        You have a first external drive:
        And a second with the same organization:
        • For each Film or Video, create a dedicated Directory with the official name of the Film, example:
        /media/EXTERNAL1/Multimedia/Films/Ironman 1
        /media/EXTERNAL1/Multimedia/Films/Ironman 2

        NB: Check for each film the official name on:
        • In XBMC, Go To "Video", Scroll Down and open "Files"
        • Add a Video Source for each Directory you want XBMC to scan and add to the Media Library

        Follow theses instructions:
        - Scroll Down and select the "themoviedb" as the scrapper
        - Select automatic scan- Select Each video in a dedicated directory
        - Valid and Valid scan now

        I recommend deactivate defaults Home screens as they will mix all of your Media Library.
        • In Settings>Skin, Deactivate view you don't need (such as Live TV if you don't have PVR)

        • Create your own Smart Playlist, in the following example as i use different paths for each type of media, it will be really easy to separate them
        Go back to "Video>Files" :

        Scroll up to "...":

        Select "Playlists": 

        Add your Smart Playlist:

        Choose your criteria (such as the path's name) and to forget to select "Order by" whatever you want (by Title could be a good idea)

        Go back to Settings>Skin and add your own Home screen for each category you want, example:

        - Select a CUSTOM screen, activate and configure it 

        Also, I would recommend to configure Artwork Downloader addon to centralize your fanarts into a dedicated directory, and finally set it as the background image container for your custom views:

        And set the background in your custom view ^^

        Some screenshots:

        So great no :-)

        Addon "Missing Movie Scanner":

        If you have a big Movie Library, you should consider about installing the addon "Missing Movie Scanner".

        It will provide a way to check for each video media library source you set if files haven't been recognized by the scapper and are missing from your library.

        When identified, you just have to correct folder names, retry scanning and double check missing files with this addon.

        To install see:

        To use this addon, go to video>addons (scrol down in video to get addons) or directly inside the addon page.

        Step 10 Optional: Integrate a Web Browser inside XBMC

        *** ONLY WORKS WITH DESKTOP VERSION (requires a real Window Manager) ***

        *** If you are using XFCE as the Window Manager (eg. under Xubuntu) you have to deactivate compositing (settings > Window Manager tweaks > Disable compositing)   ***

        For now this only fully works when XBMC has been launched inside a full Window Manager. (such as XFCE or LXCE which are parts of Xubuntu and Lubuntu)

        I had some success running Firefox using flushbox and openbox inside an Ubuntu Minimal and directly running XBMC, but could never get the sound to work.

        I you want to be able to use this (nice) feature, i recommend you to use a Desktop Ubuntu version, or a at least in Ubuntu Minimal to install XCFE or LXCE and running XBMC behind it.

        How to proceed:

        Using the addon "Advanced Launcher" we will create a dedicated screen that will launch our Web browser inside XBMC:

        • First install the addon "Advanced Launcher" (go to addon page, more, and Programs Addons)
        • In terminal, create a small bash script, as for an example:
        create a directory for your launchers (adapt "MY VOLUME"):

        mkdir <MY VOLUME>/launchers

        create a simple shell script, in my example i want to launch chromium-browser (open version of chrome):

        Note: If not yet installed, install chromium using "sudo apt-get install chromium-browser"

        create a new file "<MY VOLUME>/launchers/" (adapt "MY VOLUME"):
        /usr/bin/chromium-browser -start-maximized

        add execution right (adapt "MY VOLUME"):
        chmod +x <MY VOLUME>/launchers/
        • Create the launcher for our script:
        Note: You can manually create the launcher using Advanced Launcher, just ensure not to let any command argument (provided by default).
        I feel more simple to use the configuration file i provide but this is optional...

        Note: If you followed Step 5.a (amdcccle), then the directory and configuration file already exist, you have to had a new launcher section inside <launchers> </launchers>.

        create addon dir if does not exists yet:
        mkdir -p ~/.xbmc/userdata/addon_data/plugin.program.advanced.launcher

        create or replace if already exists the file "launcher.xml" with the following content:

        edit: "~/.xbmc/userdata/addon_data/plugin.program.advanced.launcher/launchers.xml" and adapt "MY VOLUME":

        <?xml version="1.0" encoding="utf-8" standalone="yes"?>
        • Add your launcher to favorites (Go in addon / Advanced Launcher and right click add to favorites upon chromuim)
        • Go to skin configuration: settings>skins
        • Add a custom page and call it as you want, example: INTERNET
        • Set a nice wallpaper
        • And test!
        Note about the sound in your Web Browser: To get the sound to work if you uninstalled pulseaudio (recommanded), ensure you set a default pcm device in your .asoundrc. (see sound section)

        Final result:

        When you will launch chromium browser, it will be opened in full page outside of XBMC.
        When closing it, the system goes back automatically to XBMC.

        Step 11: Integrate a file manager inside XBMC

        *** ONLY WORKS WITH DESKTOP VERSION (requires a real Window Manager) ***

        *** If you are using XFCE as the Window Manager (eg. under Xubuntu) you have to deactivate compositing (settings > Window Manager tweaks > Disable compositing)   ***

        I have tested it under Desktop Ubuntu versions, and it works perfectly :) (it has to be tested under Ubuntu minimal)

        You can easily integrate access to the file manager of your choice and manage your access to it directly inside XBMC, that you can manage your files without having to quit XBMC (if you use a desktop version) or have to deal with command line or anything else.

        I've tested some file manager, i found pcmanfm (Lubuntu's file manager) working real great in this situation. (could not get thunar to maximize when ran from XBMC...)

        Install pcmanfm:
        chmod +x <MY VOLUME>/launchers/

        Create your launcher:

        Then see Step 5.a and 10 to see how to add this script in Advanced Launcher, and then create your home page.


        When opened, pcmanfm will maximize until you close it, the you come back to XBMC maximized.

        Step 12: Configure Network services: UPnP, Airplay, XBMC web control interface

        UPnP: Share your Media Library with any other device

        In a few words, UPnP will allow to share and access to your Media Library from any other UPnP aware device.

        You may have a connected TV or Home Cinema and DLNA aware, you will be able to play any media from your library using your network!

        Please note UPnP server in XBMC is still under construction and may need to be improved, if you are looking for an alternative, take a look at MiniDLNA: 

        First, enable UPnP in System>Network>Services:

        And... Really that's all !!! ^^ 

        Just ensure your TV, Home Cinema, other device running XBMC, even your Ipad (and perhaps soon your fridge) is well connected to your Network and launch your DLNA explorer.

        Any DLNA Server (when activating UPnP, XBMC is acting as a DLNA server) will be automatically detected and accessible, just browse and enjoy.

        It took me around 2 minutes to access XBMC library and play video on my LG Home Cinema with absolutely no difficulties.    

        Airplay: Play your Music, Video or Pictures directly from your Iphone, Ipad or any Airplay aware device !

        Any Apple addict may already know Airplay, Apple's remote protocol that allow you to wireless play your music and so on from your Apple device.

        For that you had to buy an Apple Airport...this time is over thanks to XBMC Airplay implementation in Eden version! (real great work from XBMC developers!)

        Install requirements:
        sudo apt-get install avahi-daemon libshairport1

        Enable Airplay (deactivated by default) :

        And...that's it ^^ Take your Iphone while connected to your Wifi Network, open Music, Video or Picture and look for the Airplay icon, you'll find within a minute your XBMC!

        And play whatever you want, Again enjoy ^^

        *** IMPORTANT INFORMATION!!! ***

        Some updates seem have to broken airplay on my system, in case of trouble check your XBMX log (~/.xbmc/temp/xbmc.log), if you see this message:

        ERROR: Unable to load, reason: cannot open shared object file: No such file or directory

        Correct with:
        cd /usr/lib/x86_64-linux-gnu/ && sudo ln -s

        Then deactivate airplay and re-activate, retest and it should work ^^


        Control XBMC with a Web Interface:

        You may also find amazing or useful to control XBMC through a Web page, activate the service and set credentials:

        Open your Browser and access XBMC using the port you set, i recommend to take a look to other Web Interface available, example:

        Step 13: Configure Remote Control

        For Zotac MCE remote control (shipped with Nano AD10/AD11):

        Updated 10/17/2012

        The Zotac AD10 comes with an MCE remote control associated with an embedded IR receiver and also an optional USB IR receiver.
        I will provide 2 way to use the Remote control:

        • With the internal IR receiver using builtin lirc
        • With the external USB IR using Fermenta's HID driver

        Try both methods, after having tested 2 x Zotac AD10 and 1 x Zotac AD11, i always had issues with the external IR receiver (crazy repeating keys) so this is my opinion but i definitively recommend using the internal IR receiver !

        METHOD 1: Using the internal IR Receiver

        I really want to thank Fritsch for sharing this howto, i've been looking for this to work for a while!

        Note: That could seem evident, but don't plug the external USB IR ^^

        Major references:

        Install lirc:
        sudo apt-get install lirc

        When asked by the installator, juste say none.

        Replace following configuration files:

        # /etc/lirc/hardware.conf
        #Chosen Remote Control
        #Chosen IR Transmitter
        TRANSMITTER="SIR IrDA (built-in IR ports)"
        #Enable lircd
        #Don't start lircmd even if there seems to be a good config file
        #Try to load appropriate kernel modules
        # Default configuration files for your hardware if any

        # /etc/lirc/lircd.conf
        begin remote
          name  zboxremote
          bits            8
          flags RC6|CONST_LENGTH
          eps            30
          aeps          100
          header       2672   851
          one           457   425
          zero          457   425
          pre_data_bits   29
          pre_data       0x37FCB7B
          gap          106237
          toggle_bit_mask 0x8000
          rc6_mask    0x100000000
              begin codes
                  KEY_SLEEP                0xC2
                  KEY_WAKEUP               0x71
                  KEY_RECORD               0xC8
                  KEY_PAUSE                0xCF
                  KEY_STOP                 0xCE
                  KEY_REWIND               0xD6
                  KEY_PLAY                 0xD3
                  KEY_FASTFORWARD          0xD7
                  KEY_PREVIOUS             0xDE
                  KEY_NEXT                 0xDF
                  KEY_BACK                 0x7C
                  KEY_INFO                 0x34
                  KEY_HOME                 0xA2
                  KEY_UP                   0xA7
                  KEY_DOWN                 0xA6
                  KEY_LEFT                 0xA5
                  KEY_RIGHT                0xA4
                  KEY_OK                   0xA3
                  KEY_VOLUMEDOWN           0xEE
                  KEY_VOLUMEUP             0xEF
                  KEY_MUTE                 0xF2
                  KEY_CHANNELDOWN          0xE0
                  KEY_CHANNELUP            0xE1
                  KEY_1                    0xFE
                  KEY_2                    0xFD
                  KEY_3                    0xFC
                  KEY_4                    0xFB
                  KEY_5                    0xFA
                  KEY_6                    0xF9
                  KEY_7                    0xF8
                  KEY_8                    0xF7
                  KEY_9                    0xF6
                  KEY_0                    0xFF
                  KEY_KPASTERISK           0xCC
                  KEY_KPSLASH              0xCD
                  KEY_CLEAR                0xC5
                  KEY_TEXT                 0xD0
                  KEY_EPG                  0xC1
                  KEY_ENTER                0xCB
                  KEY_RED                  0x92
                  KEY_GREEN                0x91
                  KEY_YELLOW               0x90
                  KEY_BLUE                 0x8F
              end codes
        end remote

        Some remappings for xbmc:
            <remote device="zboxremote">

        Some additional remaps:
              <record>XBMC.ActivateWindowAndFocus(MyPVR, 34,0, 13,0)</record>

        Reboot or manually start lirc (sudo /etc/init.d/lirc start) and relaunch XBMC, you're done!

        Nb: I you have an error while trying to start lirc talking about impossibility to get staging/media, do (adapt to your current kernel version, use "uname -a" if you don't know it) :
        sudo ln -s /lib/modules/3.2.0-32-generic/kernel/drivers/staging/media/lirc /lib/modules/3.2.0-32-generic/kernel/drivers/staging/lirc

        METHOD 2: Using the external USB IR Receiver

        Major references:
        Note: I had some frustrating issues with the Howto above, so i'll provide the same version with some important mentions and corrections

        Follow carefully theses steps:
        • Plug the external USB IR receiver
        • If "LIRC" is already installed (sudo dpkg -l | grep lirc), uninstall it:
        sudo apt-get autoremove --purge lirc
        • IMPORTANT TO AVOID ISSUES: Ensure the original LIRC init script does not exist:
        sudo rm /etc/init.d/lirc
        • Install some requirements:
        sudo apt-get install automake dialog libtool

        • IMPORTANT TO AVOID ISSUES: Avoid the kernel from loading the module "ite_cir" that manages the internal IR
        Note: On some systems (i had the case under Xubuntu 12.04) if you don't do that you may go in great troubles with latency and crazy repeating keys when using the remote.

        Edit "/etc/modprobe.d/blacklist.conf" and add the following line at the end of the file:
        blacklist ite_cir
        • Download and extract Fermenta's LIRC:
        wget -O lirc.tar.gz
        tar -xvf lirc.tar.gz
        cd <EXTRACTED DIR>

        • Configure and install,  when running, select driver zotac under usb, save & configure:
        sudo make install

        • Create links in /usr/sbin:
        cd /usr/sbin
        sudo ln -s ../local/sbin/lircd lircd
        sudo ln -s ../local/sbin/lircmd lircmd

        • Set LIRC to launch at system startup (with good options) :
        Create "/etc/udev/rules.d/85-xbmc.rules":
        #Remote Control
        SUBSYSTEM=="usb" , ATTRS{idVendor}=="0471", ATTRS{idProduct}=="20cc", SYMLINK+="remote", ACTION=="add", RUN+="/sbin/initctl --quiet emit --no-wait ir-ready"

        Create "/etc/init/lirc.conf":
        description "lirc"
        emits "lirc-ready"
        expect fork
        start on (remote-filesystems
                  and local-filesystems
              and started rsyslog
              and ir-ready)
        stop on runlevel [!2345]
        pre-start script
          while [ ! -e /dev/remote ]
            sleep 1
          mkdir /var/run/lirc
        end script
        exec /usr/local/sbin/lircd --driver=zotac --device=/dev/remote
        post-start script
          ln -s /var/run/lirc/lircd /dev/lircd
        end script
        post-stop script
          rm /dev/lircd
          rm -rf /var/run/lirc
        end script

        • Stop X11 from registering the device as a keyboard:

        *** IMPORTANT REMARK ***
        Xorg upgrades will break this!
        In case you later upgrade your system, you really should ensure the file "/usr/share/X11/xorg.conf.d/10-evdev.conf" hasn't been overwritten.
        If it has been overwritten, simply re-do the step bellow. (if you don't you will go in troubles)

        Edit "/usr/share/X11/xorg.conf.d/10-evdev.conf" and add the following section at the beginning of the file:
        Section "InputClass"
          Identifier "PHILIPS MCE USB IR Receiver- Spinel plus"
          MatchProduct "PHILIPS MCE USB IR Receiver- Spinel plus"
          MatchIsKeyboard "true"
          Option "Ignore" "true"
        • Configure several files as follow:

        Replace "/etc/lirc/hardware.conf":
        # hardware.conf for Zotac
        REMOTE="Zotac MCE Remote"

        Replace "/etc/lirc/lircd.conf":
        # Please make this file available to others
        # by sending it to
        # this config file was automatically generated
        # using lirc-0.9.1-git(zotac) on Mon Apr  2 14:10:29 2012
        # contributed by
        # brand:                       zotac.conf
        # model no. of remote control:
        # devices being controlled by this remote:
        begin remote
          name  zotac.conf
          bits           32
          eps            30
          aeps          100
          one             0     0
          zero            0     0
          gap          100123
          min_repeat      9
        #  suppress_repeat 9
        #  uncomment to suppress unwanted repeats
        #  toggle_bit_mask 0x7004F
              begin codes
                  KEY_SLEEP                0x00010082
                  KEY_WAKEUP               0x00010083
                  KEY_RECORD               0x000C00B2
                  KEY_PAUSE                0x000C00B1
                  KEY_STOP                 0x000C00B7
                  KEY_REWIND               0x000C00B4
                  KEY_PLAY                 0x000C00B0
                  KEY_FORWARD              0x000C00B3
                  KEY_LEFTSHIFT            0x000C00B6
                  KEY_RIGHTSHIFT           0x000C00B5
                  KEY_BACK                 0x000C0224
                  KEY_INFO                 0x000C0209
                  KEY_MENU                 0xFFBC000D
                  KEY_UP                   0x00070052
                  KEY_LEFT                 0x00070050
                  KEY_RIGHT                0x0007004F
                  KEY_DOWN                 0x00070051
                  KEY_OK                   0x00070028
                  KEY_VOLUMEUP             0x000C00E9
                  KEY_VOLUMEDOWN           0x000C00EA
                  KEY_MUTE                 0x000C00E2
                  KEY_CHANNELUP            0x000C009C
                  KEY_CHANNELDOWN          0x000C009D
                  KEY_1                    0x0007001E
                  KEY_2                    0x0007001F
                  KEY_3                    0x00070020
                  KEY_4                    0x00070021
                  KEY_5                    0x00070022
                  KEY_6                    0x00070023
                  KEY_7                    0x00070024
                  KEY_8                    0x00070025
                  KEY_9                    0x00070026
                  KEY_0                    0x00070027
                  KEY_NUMERIC_STAR         0x10070025
                  KEY_NUMERIC_POUND        0x10070020
                  KEY_CLEAR                0x00070029
                  KEY_TEXT                 0xFFBC005A
                  KEY_TITLE                0x000C008D
                  KEY_ENTER                0x00070028
                  KEY_RED                  0xFFBC005B
                  KEY_GREEN                0xFFBC005C
                  KEY_YELLOW               0xFFBC005D
                  KEY_BLUE                 0xFFBC005E
              end codes
        end remote

        Create "~/.xbmc/userdata/Lircmap.xml" as your XBMC user:
            <remote device="zotac.conf">
        • REBOOT
        And finally test your remote control, everything should be working like a charm!

        For generic MCE remote controls:

        For others generic MCE, please see my post:

        Step 14: Optional - Use Live TV

        If you have an external TV Tuner, you may want to use it with XBMC and be able to watch Real TV on your Box.

        This is very fun and will complete your XBMC Media Center Experience :-)

        Please check my post here to see how to configure it:

        Some screenshots ^^


        • Configure ZOTAC Frame Buffer Size:
        You have to set a very important setting in Zotac UEFI, if you don't you will get playback issue.


        So to set this:

        • Power on the Zotac and access to UEFI by pressing SUPPR key at boot time
        • Go in screen "Chipset"
        • Set UMA to 1Gb (default is 256Mb)


        • Configure and install ATI Catalyst Legacy driver for non supported anymore Radeon HD cards (previous to HD5000)

        1. Install the dependencies you need to build fglrx-legacy (libc6-i386 is only needed on 64 bit systems):

        sudo apt-get install dh-make dh-modaliases execstack libqtgui4 build-essential libc6-i386

        2. Remove any graphics drivers that are leftover on your system. Unless you have nvidia hardware, leave the nvidia part in the command as I discovered some packages had found their way on to my system (despite my not having installed them) and interfered with the ATI stuff until removed.

        sudo apt-get remove fglrx* nvidia*

        3. Download and extract the legacy drivers.


        4. Build and install the drivers. (They are not compatible with Ubuntu 12.10 (Quetzal) as of 21 Oct 2012.)

        sudo sh --buildandinstallpkg

        5. Stop the xserver via terminal. (Press Ctrl+Alt+F1 to load a terminal interface if need be)

        sudo service lightdm stop

        6. Configure the drivers as outlined in the guides that you referenced, reboot, and continue with the instructions from there.

        sudo aticonfig --initial -f
        sudo aticonfig --vs=on
        sudo aticonfig --set-pcs-u32=MCIL,HWUVD_H264Level51Support,1
        sudo reboot