Building HTPC

Upgrade time... Installing everything from scratch, using same hardware (AT3N7A-I from ASUSTeK) as in previous articles including update. This time Fedora18 64bit and XBMC 12 from RPMFusion will be installed.

Just to comment about: this procedure will not work on 32bit server.

Preparing NFS on server

Create LV for it:

# lvcreate -n fc18xbmc -L6g /dev/rootvg
  Logical volume "fc18xbmc" created
# mkfs.ext4 -j -m0 /dev/rootvg/fc18xbmc
# mkdir /fc18xbmc ; mount /dev/rootvg/fc18xbmc /fc18xbmc

Update /etc/fstab about new FS. Add line to /etc/exports


Command exportfs -a reread config file and start serve new share.

Create yum repository file:

# cat > /etc/yum.repos.d/fc18xbmc.repo << EOF

Let's populate new FS !!

# yum --disablerepo="*" --enablerepo=fc18xbmc --installroot=/fc18xbmc install yum fedora-release

Create script to easy work within chroot environment, copy resolv.conf, and enter to chrooted environment:

# cd /fc18xbmc && cat > command_mount_chroot << EOF
mount -o bind /proc proc
mount -o bind /sys sys
mount -o bind /dev dev
chroot . /bin/bash -i
umount dev
umount sys
umount proc
# cp -v /etc/resolv.conf etc/
# sh command_mount_chroot
bash-4.2# export PS1="CHROOT# "

You are in chrooted, almost empty environment. Now let's install RPM Fusion repository:

CHROOT# rpm -ihv \

Configure system as following:

CHROOT# echo "NETWORKING=yes" > /etc/sysconfig/network
CHROOT# cat > /etc/fstab << EOF  /    nfs     nolock,nfsvers=3,tcp  0 0
tmpfs                   /tmp         tmpfs   mode=1777       0 0
tmpfs                   /dev/shm     tmpfs   defaults        0 0
devpts                  /dev/pts     devpts  gid=5,mode=620  0 0
sysfs                   /sys         sysfs   defaults        0 0
proc                    /proc        proc    defaults        0 0

Now install all required packages:

CHROOT# yum install -y kmod-nvidia xorg-x11-drv-nvidia vdpauinfo libvdpau twm xterm kdm xbmc nfs-utils \
	vim dracut-network passwd openssh-server syslog-ng pavucontrol pulseaudio-module-x11 \
	glx-utils xorg-x11-drv-keyboard xorg-x11-drv-mouse binutils gcc make kernel-devel \
	xorg-x11-fonts-cyrillic xorg-x11-font-utils xorg-x11-fonts-Type1 xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi \
	xorg-x11-xdm xorg-x11-drv-evdev lsof strings ntp dhclient autofs alsa-utils

Configure new system:

CHROOT# rm -f /etc/systemd/system/
CHROOT# ln -s /lib/systemd/system/ /etc/systemd/system/
CHROOT# cat > /etc/syslog-ng/syslog-ng.conf << EOF
source s_sys {
    file ("/proc/kmsg" program_override("kernel") flags(kernel));
    unix-dgram ("/dev/log");
destination d_loghost { udp("" port(514)); };
log { source(s_sys); destination(d_loghost); };
CHROOT# ln -s /lib/systemd/system/sshd.service /etc/systemd/system/
CHROOT# ln -s /lib/systemd/system/syslog-ng.service /etc/systemd/system/
CHROOT# password

Prepare dracut configuration file and rebuild initrd file:

CHROOT# cat > /etc/dracut.conf.d/NFS_root.conf << EOF
dracutmodules+="nfs network base"
omit_dracutmodules+="xen btrfs dm dmraid dmsquash-live lvm mdraid multipath"
add_dracutmodules+="network nfs"
CHROOT# cd /boot && dracut -f initramfs-3.8.4-202.fc18.x86_64.img 3.8.4-202.fc18.x86_64
CHROOT# exit

Copy kernel and initrd files to /tftpboot directory:

# cp /fc18xbmc/boot/vmlinuz-3.8.4-202.fc18.x86_64 /tftpboot/fc18xbmc.krl
# cp /fc18xbmc/boot/initramfs-3.8.4-202.fc18.x86_64.img /tftpboot/fc18xbmc.ird

Create PXE boot file and link it to correct MAC address:

# cat > /tftpboot/pxelinux.cfg/fc18xbmc << EOF
DEFAULT fc18xbmc

LABEL fc18xbmc
  KERNEL fc18xbmc.krl
  APPEND initrd=fc18xbmc.ird root=nfs:,tcp,nfsvers=3 rd.ip=auto rd.debug vmalloc=192MB
# ln -s fc18xbmc /tftpboot/pxelinux.cfg/01-90-e6-ba-cc-b7-2e

Boot HTPC. Probably you can login via SSH, and saw syslog messages on "loghost". If not, try fix things in NFS server and restart HTPC. Log in to HTPC, either local, or by SSH.

Configuring Video

Default xorg configuration work but do not give "native" resolution on HDMI TV. This file is suits fo my hardware and my so called "HDMI ready" (720p) TV.

# cat > /etc/X11/xorg.conf << EOF
Section "ServerLayout"
        Identifier "Default Layout"
        Screen 0 "Screen0" 0 0
        InputDevice "Keyboard0" "CoreKeyboard"

Section "ServerFlags"
        Option "AIGLX" "on"

Section "InputDevice"
        Identifier "Keyboard0"
        Driver "kbd"
        Option "XkbModel" "pc105"
        Option "XkbLayout" "us+inet"

Section "Device"
        Identifier "Videocard0"
        Driver "nvidia"
        Option "AddARGBGLXVisuals" "True"
        Option "UseEDIDFreqs" "False"
        Option "ModeValidation" "NoWidthAlignmentCheck, NoDFPNativeResolutionCheck"
        Option "UseEvents" "True"
        Option "UseEdidDpi" "FALSE"
        Option "ExactModeTimingsDVI" "TRUE"

Section "Monitor"
        Identifier "Vizio37"
        HorizSync 31.0 - 70.0
        VertRefresh 50.0 - 85.0
        Modeline "1368x768_60.00" 85.9 1368 1440 1584 1800 768 769 772 795 -hsync +vsync
        # Option "DPMS"
        Option "ModeValidation" "NoDFPNativeResolutionCheck"

Section "Screen"
        Identifier "Screen0"
        Device "Videocard0"
        Monitor "Vizio37"
        Option "UseEdidDpi" "FALSE"
        Option "DPI" "100 x 100"
        #Option "TVStandard" "HD1080i"
        Option "NoLogo" "1"
        Option "TVStandard" "HD720p"
        Option "TVOverScan" ".7"
        Option "ConnectedMonitor" "DFP"
        Option "ExactModeTimingsDVI" "True"
        DefaultDepth 24
        SubSection "Display"
                Viewport 0 0
                Depth 24
                Modes "1368x768_60.00"

Section "Extensions"
        Option "Composite" "Enable"

Try startx, check /var/log/Xorg.0.log. Set gray background by command xsetroot -gray. Verify that resolution is native. The background should be gray without waves.

Setting Audio

First of all unmute everything by alsamixer -c0. In my case HDMI output named S/PDIF 1. Save the state as system default by alsactl store command.

Command pulseaudio -C starts interactive session to examine current settings and set desired parameters. When started, you can ask for help about commands. Usefull command is list-cards which list your hardware and it's state. Here is an output form my hardware, most relevant info bolded by me:

-bash-4.2# pulseaudio -C
W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.Spawn.ExecFailed:
 /bin/dbus-launch terminated abnormally without any error message
W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.Spawn.ExecFailed: /bin/dbus-launch
 terminated abnormally without any error message
Welcome to PulseAudio! Use "help" for usage information.
>>> list-cards
1 card(s) available.
    index: 0
        name: <alsa_card.pci-0000_00_08.0>
        driver: <module-alsa-card.c>
        owner module: 4
                alsa.card = "0"
                alsa.card_name = "HDA NVidia"
                alsa.long_card_name = "HDA NVidia at 0xf9f78000 irq 23"
                alsa.driver_name = "snd_hda_intel"
                device.bus_path = "pci-0000:00:08.0"
                sysfs.path = "/devices/pci0000:00/0000:00:08.0/sound/card0"
                device.bus = "pci"
       = "10de"
       = "NVIDIA Corporation"
       = "0ac0"
                device.form_factor = "internal"
                device.string = "0"
                device.description = "Built-in Audio"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
                output:analog-stereo: Analog Stereo Output (priority 6000)
                output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6060)
                output:analog-surround-40: Analog Surround 4.0 Output (priority 700)
                output:analog-surround-40+input:analog-stereo: Analog Surround 4.0 Output + Analog Stereo Input (priority 760)
                output:analog-surround-41: Analog Surround 4.1 Output (priority 800)
                output:analog-surround-41+input:analog-stereo: Analog Surround 4.1 Output + Analog Stereo Input (priority 860)
                output:analog-surround-50: Analog Surround 5.0 Output (priority 700)
                output:analog-surround-50+input:analog-stereo: Analog Surround 5.0 Output + Analog Stereo Input (priority 760)
                output:analog-surround-51: Analog Surround 5.1 Output (priority 800)
                output:analog-surround-51+input:analog-stereo: Analog Surround 5.1 Output + Analog Stereo Input (priority 860)
                output:analog-surround-71: Analog Surround 7.1 Output (priority 700)
                output:analog-surround-71+input:analog-stereo: Analog Surround 7.1 Output + Analog Stereo Input (priority 760)
                output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500)
                output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (priority 5560)
                output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5400)
                output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Output + Analog Stereo Input (priority 5460)
                output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 300)
                output:hdmi-surround+input:analog-stereo: Digital Surround 5.1 (HDMI) Output + Analog Stereo Input (priority 360)
                input:analog-stereo: Analog Stereo Input (priority 60)
                off: Off (priority 0)
        active profile: <output:analog-stereo+input:analog-stereo>
                alsa_output.pci-0000_00_08.0.analog-stereo/#0: Built-in Audio Analog Stereo
                alsa_output.pci-0000_00_08.0.analog-stereo.monitor/#0: Monitor of Built-in Audio Analog Stereo
                alsa_input.pci-0000_00_08.0.analog-stereo/#1: Built-in Audio Analog Stereo
                analog-output: Analog Output (priority 9900, available: unknown)

                analog-output-headphones: Headphones (priority 9000, available: no)

                analog-input-microphone-front: Front Microphone (priority 8500, available: no)

                analog-input-microphone-rear: Rear Microphone (priority 8200, available: no)

                analog-input-linein: Line In (priority 8100, available: no)

                iec958-stereo-output: Digital Output (S/PDIF) (priority 0, available: unknown)

                hdmi-output-0: HDMI / DisplayPort (priority 5900, available: unknown)

>>> set-card-profile 0 output:hdmi-stereo
>>> list-cards
        active profile: <output:hdmi-stereo>

Once desired command detected, put it system wide and startup default:

-bash-4.2# echo "set-card-profile 0 output:hdmi-stereo" >> /etc/pulse/

Setting XBMC

Set up XBMC user and autostart programm.

# groupadd -g 507 xbmc
# useradd -u 507 -g xbmc -G audio,video,pulse-access,pulse xbmc
# password xbmc
Configure HTPS boot to graphic mode:
# rm -f /etc/systemd/system/ && ln -s /lib/systemd/system/ /etc/systemd/system/

Restart HTPC, at graphic login enter user "xbmc", password for it and select XBMC session type (by mouse).

Now fix autologin to xbmc user on system start. Edit file /etc/kde/kdm/kdmrc:

# Core config for 1st local display
# Enable automatic login. USE WITH EXTREME CARE! Default is false
# The user to log in automatically. NEVER specify root! Default is ""
# The password for the user to log in automatically. This is NOT required
# unless the user is logged into a NIS or Kerberos domain. If you use this
# option, you should "chmod 600 kdmrc" for obvious reasons.
# Default is ""

Misc settings

My HTPC mounts it's media sources via automount. Edit /etc/sysconfig/autofs file to use NFSv3 instead of NFSv4. Enable autofs service by:

# systemctl enable autofs.service
# systemctl start autofs.service

Remote control

Download Official XBMC Remote - Android Apps on Google Play. Now your android phone is xbmc remote control.
If this was helpfull, please donate
Updated on Thu Jun 6 13:38:36 IDT 2013 by Oleg Volkov More documentations here