User Tools

Site Tools


os:archlinux:htpc

Overview

First let me say I DON RECOMMEND THIS DEVICE! I bought the first one in February 2013 and today 1st of July is my 3rd device! Yes it died twice already! Before I used SSD to install xbmcbuntu on it (yes lazyness … ) now I'll try on an SDXC 64GB card and… Archlinux.
The purpose is to have a Home Theater PC to play music and videos directly on the TV.

FIXME Since there's no way to boot on SD card reader … I have to reinstall it on hard drive later

Outpu of lspci

00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4)
00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4)
00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4)
00:1c.3 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 4 (rev c4)
00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation 7 Series Chipset Family LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168 PCI Express Gigabit Ethernet controller (rev 06)
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168 PCI Express Gigabit Ethernet controller (rev 06)
04:00.0 USB controller: Renesas Technology Corp. uPD720202 USB 3.0 Host Controller (rev 02)
05:00.0 Network controller: Intel Corporation Centrino Wireless-N 135 (rev c4)

lsusb

Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
Bus 001 Device 004: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 004 Device 003: ID 8087:07da Intel Corp. 
Bus 004 Device 004: ID 04d9:a06b Holtek Semiconductor, Inc. 

cpuinfo

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 42
model name      : Intel(R) Celeron(R) CPU 847 @ 1.10GHz
stepping        : 7
microcode       : 0x28
cpu MHz         : 792.000
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips        : 2195.44
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:
 
processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 42
model name      : Intel(R) Celeron(R) CPU 847 @ 1.10GHz
stepping        : 7
microcode       : 0x28
cpu MHz         : 792.000
cache size      : 2048 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 2
initial apicid  : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips        : 2195.44
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

Base install

References

First install

Boot on the USB stick (I created mine using unetbootin ~ lazy :D - the isos are taken from here → https://www.archlinux.org/download/ take the mirror closest to you and select the netinstall ISO)

Basic

Remote access

Let's launch the network + sshd so we can copy paste some nice commands right from an already installed machine

ip addr show

Start sshd

systemctl start sshd

Set a root password

passwd

Partitionning

I'll have a super simple setup here:

  • swap 4GB
  • / 20GB
  • /home 40GB

Formatting

Let's format all these partitions in ext4 format.

mkfs.ext4 -L LINUX /dev/sdb1
mkfs.ext4 -L HOME /dev/sdb3
mkswap -L SWAP /dev/sdb2


Mount them

Mounting and creating mount points:

mount /dev/sdb1 /mnt
mkdir /mnt/home
mount /dev/sdb3 /mnt/home
swapon /dev/sdb2

Check

mount

Base system

I'll then install base packages plus base-devel packages

pacstrap /mnt base base-devel

Fstab

For SSD tweaks and to make it shine: SSD

  • generate fstab
genfstab -L -p /mnt >> /mnt/etc/fstab

Yes I use Labels, UUID sucks

</code>

Bootloader

I use Syslinux since it does its job well! Syslinux

pacstrap /mnt syslinux

Configuration

Environment

Let's go to our new system!

arch-chroot /mnt 
  • /etc/hostname
 echo HTPC > /etc/hostname 
  • /etc/locale.gen

I'll use en_US.utf-8/iso8859 and fr_FR.* so uncomment:

en_US.UTF-8 UTF-8
en_US ISO-8859-1
fr_FR.UTF-8 UTF-8  
fr_FR ISO-8859-1  
fr_FR@euro ISO-8859-15 

The generate locales

 locale-gen 
LANG="en_US.UTF-8"
 
# Keep the default sort order (e.g. files starting with a '.'
# should appear at the start of a directory listing.)
LC_COLLATE="C"
  • /etc/vconsole.conf

Default keyboard in console (FR … the only wireless keyboard I have ;()

echo "KEYMAP=fr" > /etc/vconsole.conf
  • /etc/localtime
ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
  • /etc/mkinitcpio.conf

No touch just regenerate it in case …

mkinitcpio -p linux
  • root password
passwd

Umount stuff cleanly

First use Ctrl+D to escape from the chroot
then:

umount /mnt/home /mnt

Now is the time to light a candle and type

reboot


Reboot

————————–I am here ——————-

Pimping up shit created by systemd

So, happily you used to refer to your network card as eth0? Forget it! Now huge brains have decided for you, even if you don't have any issue that the notation will change! Great … so my eth0 is called … wait for it: enp0s25 perfect. So let's remove that shit! (wlan0 is called wlp3s0 by the way - unfortunately, so far they didn't change the lo interface \o/ it's called … lo … what a lack of imagination!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)

ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules

Reboot! Yeah you know just like on Windows©

Network

Dhcpcd for eth 0

Once you have back a proper name for you interfaces …

 systemctl enable dhcpcd@eth0 

And then it slows down your boot! Isn't that nice? Well coded.
Reference: Network

Netctl for wifi

Reference: https://wiki.archlinux.org/index.php/Netctl

pacman -S netctl wpa_supplicant
cd /etc/netctl/examples/

Copy on of the example regarding the type of network you want to access:

cp wireless-wpa-configsection ../university

Edit the file with proper settings (SSID / user … )

cd /etc/netctl
vi university

I don't use auto-wifi service I start it when needed:

netctl start university

SSHd

Access remotely:

 pacman -Sy openssh 

Enable it at boot

 systemctl enable sshd

Security

Reference: SHA_Password

vi /etc/pam.d/passwd
password	required	pam_unix.so sha512 shadow nullok rounds=65536

Then rehash your passwords!

passwd

User

useradd -g users -m -s /bin/bash warnaud
passwd warnaud

Fix VI/VIM

# ls -altrh `which vi`
lrwxrwxrwx 1 root root 2 Nov 16 18:34 /usr/bin/vi -> ex

Prefer vim?

pacman -S vim
rm /usr/bin/vi &&  ln -s /usr/bin/vim /usr/bin/vi

GPM

Since gpm is a dependency of vim let's use it!

systemctl enable gpm
systemctl start gpm

Xorg / XDM

Xorg

Reference: Xorg & Intel Install all those packages …

# pacman -S xorg-server xorg-apps xorg-fonts xorg-fonts-100dpi xorg-fonts-75dpi xorg-twm xorg-xclock xorg-xinit xorg-xdm xterm xf86-video-intel xorg-xmessage xorg-xcalc xorg-xfontsel xorg-utils

Reply to questions:

:: There are 37 members in group xorg-apps:
:: Repository extra
   1) xorg-bdftopcf  2) xorg-iceauth  3) xorg-luit  4) xorg-mkfontdir  5) xorg-mkfontscale  6) xorg-sessreg  7) xorg-setxkbmap  8) xorg-smproxy
   9) xorg-x11perf  10) xorg-xauth  11) xorg-xbacklight  12) xorg-xcmsdb  13) xorg-xcursorgen  14) xorg-xdpyinfo  15) xorg-xdriinfo  16) xorg-xev
   17) xorg-xgamma  18) xorg-xhost  19) xorg-xinput  20) xorg-xkbcomp  21) xorg-xkbevd  22) xorg-xkbutils  23) xorg-xkill  24) xorg-xlsatoms
   25) xorg-xlsclients  26) xorg-xmodmap  27) xorg-xpr  28) xorg-xprop  29) xorg-xrandr  30) xorg-xrdb  31) xorg-xrefresh  32) xorg-xset  33) xorg-xsetroot
   34) xorg-xvinfo  35) xorg-xwd  36) xorg-xwininfo  37) xorg-xwud
 
Enter a selection (default=all):
:: There are 2 members in group xorg-fonts:
:: Repository extra
   1) xorg-font-util  2) xorg-fonts-encodings
 
Enter a selection (default=all): 1
resolving dependencies...
:: There are 4 providers available for libgl:
:: Repository extra
   1) mesa-libgl  2) nvidia-304xx-utils  3) nvidia-libgl
:: Repository community
   4) catalyst-utils
 
Enter a number (default=1): 1

Add some modules at boot for KMS

vi /etc/mkinitcpio.conf
...
MODULES="i915"
...

Acceleration method

vi /etc/X11/xorg.conf.d/20-intel.conf
Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "AccelMethod"  "sna"
EndSection
 vi /etc/X11/xorg.conf.d/10-evdev.conf 
Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "XkbLayout" "us"
        Option "XkbVariant" "intl"
EndSection

XDM

Reference: https://wiki.archlinux.org/index.php/XDM

pacman -S xorg-xdm

Enable systemd service

systemctl enable xdm.service

Optional, if you made a customize version

vi /usr/lib/systemd/system/xdm.service
[Unit]
Description=X-Window Display Manager
After=systemd-user-sessions.service
 
[Service]
ExecStart=/usr/bin/xdm -c /etc/X11/xdm/lcars-xdm/xdm-config -nodaemon
Type=notify
NotifyAccess=all
 
[Install]
Alias=display-manager.service

Copy the necessary files from /etc/skel

cp /etc/skel/.xsession ~/.

make sure its permission are 774

Fvwm

pacman -S fvwm

Import my configuration:

mkdir ~/.fvwm && cd .fvwm && svn co https://fvwm.svn.beanstalkapp.com/fvwm/trunk/bazooka . 

Alsa

Reference: https://wiki.archlinux.org/index.php/Alsa

pacman -S alsa-utils

Set volume levels:

alsamixer

Test:

speaker-test -c 2

Laptop / powersaving (doesn't work ... )

ACPID

To have access to buttons + power settings, first install acpi and acpid

pacman -S acpi acpid

Reference:https://wiki.archlinux.org/index.php/Acpi and https://wiki.archlinux.org/index.php/Acpid and https://wiki.archlinux.org/index.php/ACPI_hotkeys Start the deamon and enable it:

systemctl enable acpid
systemctl start acpid

TPB

For other nice osd display install tpb FIXME:

yaourt -S tpb

Reference:https://wiki.archlinux.org/index.php/ThinkPad_OSD Configure it:

vi /etc/tpbrc
OSDCOLOR    Green
OSDVERTICAL 0
OSDHORIZONTAL 0
OSDPOS      MIDDLE
OSDALIGN    CENTER

Udev

Create a special rule to suspend everything if battery is at 2% FIXME Doesn't work …

vi /etc/udev/rules.d/lowbat.rules
## SLEEP IF BATTERY IS LOW
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="2", RUN+="/usr/bin/systemctl suspend"

i915

Power consumption for Intel Graphics:

vi /etc/modprobe.d/modprobe.conf
options i915 i915_enable_rc6=1 i915_enable_fbc=1 lvds_downclock=1

Rebuild the kernel:

mkinitcpio -p linux && mkinitcpio -p linux-ck

TLP

Reference:https://wiki.archlinux.org/index.php/TLP Install required packages:

yaourt -S tlp tp_smapi tp_smapi-ck dkms-acpi_call-git smartmontools

FIXME tp_smapi doesn't seems to launch … Enable the service:

systemctl enable tlp

Sysctl

Reference: https://wiki.archlinux.org/index.php/Sysctl FIXME add in /etc/sysctl.conf

vm.dirty_writeback_centisecs=1500
vm.laptop_mode=5 

Thinkpad

Disable Touchpad

Deactivate the useless touchpad:

 vi /etc/X11/xorg.conf.d/10-evdev.conf 
Section "InputClass"
        Identifier "evdev touchpad catchall"
        MatchIsTouchpad "off"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

FIXME Check alternate solution:https://wiki.archlinux.org/index.php/Synaptics_Touchpad

TrackNav enhancement

This hack will enable scrolling using the middle button + the TrackPoint™®©

vi /etc/X11/xorg.conf.d/20-thinkpad.conf
Section "InputClass"
    Identifier	"Trackpoint Wheel Emulation"
    MatchProduct	    "TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint|ThinkPad USB Keyboard with TrackPoint|USB Trackpoint pointing device"
    MatchDevicePath	    "/dev/input/event*"
    Option		    "EmulateWheel"        "true"
    Option		    "EmulateWheelButton"  "2"
    Option		    "Emulate3Buttons"	  "false"
    Option		    "XAxisMapping"	  "6 7"
    Option		    "YAxisMapping"        "4 5"
EndSection

Bluetooth

Reference: https://wiki.archlinux.org/index.php/Bluetooth

pacman -S bluez

FIXME Any of this required?

Optional dependencies for bluez
    gstreamer0.10-base: bluetooth GStreamer support
    alsa-lib: Audio bluetooth devices support [installed]
    dbus-python: to run bluez-simple-agent
    pygobject: to run bluez-simple-agent
    libusb-compat: USB adapters support
    cups: CUPS backend

I kind of never use bluetooth so I start it when necessary

systemctl start bluetooth.service

FIXME .. have some fun with it

Multimedia Keys

Mute/Volume up and Down are recognized by default in xev, so with xbindkeys let's map them

pacman -S xbindkeys

Create a file that contain the definition of the buttons + the action(s)

vi ~/.xbindkeysrc.scm

Here I'll map Mute / Volume up / Volume Down

(xbindkey '("XF86AudioMute") "amixer set Master toggle")
(xbindkey '("XF86AudioRaiseVolume") "amixer set Master 2dB+ unmute")
(xbindkey '("XF86AudioLowerVolume") "amixer set Master 2dB- unmute")

Last but not least, add

xbindkeys &

To your ~/.xinitrc or whatever file launched at login

Systemd journal

It's always nice to see some logs even if they are in binary format ……

Hint: You are currently not seeing messages from other users and the system.
      Users in the 'systemd-journal' group can see all messages. Pass -q to
      turn off this notice.

Fix:

sudo gpasswd -a USERNAME systemd-journal

Other software

Archlinuxfr repository

vi /etc/pacman.conf
...
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch

\o/ No signature

Yaourt

Reference: http://archlinux.fr/yaourt-en

pacman -Sy yaourt

Sudo

pacman -S sudo
visudo
...
root ALL=(ALL) ALL
someuser ALL=(ALL) ALL

Just add the 'someuser' line

Compilation options

:!: just for fun not really mandatory Reference: https://wiki.archlinux.org/index.php/Makepkg.conf

vi /etc/makepkg.conf

Modify CFLAGS/CXXFLAGS:

# -march=native also sets the correct -mtune=
CFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
CXXFLAGS="${CFLAGS}"

Modify MAKEFLAGS (4 = output of nproc)

MAKEFLAGS="-j4"

Mandatory packages - for terminal users

List of software I use and abuse

yaourt -S screen bash-completion wavemon glances htop bmon irssi lftp rsync wget curl bc figlet toilet pmount dfc git rdesktop

I use yaourt since some of them are not in repositories and then built from aur

Cups

Reference: https://wiki.archlinux.org/index.php/Cups

pacman -S libcups cups cups-filters ghostscript gsfonts

CK Kernel

For more aggressive scheduling, you can use the ck patchset
References:

:!: Super up-to-date :!:

vi /etc/pacman.conf

Add at the end:

[repo-ck]
SigLevel = PackageRequired
Server = http://repo-ck.com/$arch

Add keys for signing shit …

pacman-key -r 5EE46C4C
pacman-key --lsign-key 5EE46C4C

Refresh pacman's database:

pacman -Sy

Install kernel-ck matching your architecture (see Repo-ck page for reference)

pacman -S linux-ck-ivybridge linux-ck-ivybridge-headers

Add a nice entry in syslinux

vi /boot/syslinux/syslinux.cfg
...
DEFAULT arch-ck
...
LABEL arch-ck
        MENU LABEL Arch Linux CK
        LINUX ../vmlinuz-linux-ck
        APPEND root=/dev/sdb3 ro
        INITRD ../initramfs-linux-ck.img quiet ipv6.disable=1 elevator=bfq
 
LABEL arch-ck-fallback
        MENU LABEL Arch Linux CK Fallback
        LINUX ../vmlinuz-linux-ck
        APPEND root=/dev/sdb3 ro
        INITRD ../initramfs-linux-ck-fallback.img
...

Bye bye IPv6 and change the schedule to Con Kolivas' bfq

URxvt

pacman -S rxvt-unicode urxvt-perls

(Not yet implemented : )

 URxvt.perl-ext-common:      default,clipboard,url-select,keyboard-select
 URxvt.url-select.launcher:  chromium
 URxvt.url-select.underline: true
 URxvt.keysym.M-u:           perl:url-select:select_next
 URxvt.keysym.M-Escape:      perl:keyboard-select:activate
 URxvt.keysym.M-s:           perl:keyboard-select:search

X11 software

yaourt -S chromium hsetroot imagemagick vlc emelfm2 flashplugin xosd

For acrobat reader/skype, there's a need for the multilib repository … well coded too!

vi /etc/pacman.conf

Uncomment:

[multilib]
Include = /etc/pacman.d/mirrorlist

Then:

yaourt -Sy acroread skype

:!: tons of 32bits libraries …. FIXME acroread libre-office* fonts skype…

Final stuff

Ntfs share

Reference: https://wiki.archlinux.org/index.php/Ntfs

pacman -S ntfs-3g
vi /etc/fstab
# 
# /etc/fstab: static file system information
#
# <file system> <dir>   <type>  <options>       <dump>  <pass>
# /dev/sdb3 UUID=34cedc78-e156-4dbb-a428-4d594d6b34a8
LABEL=LINUX             /               ext4            defaults,noatime,discard        0 1
 
# /dev/sda2 UUID=f8a1e862-64b7-41d7-ac7d-4b75b346ceb5
LABEL=VAR               /var            ext4            rw,relatime,data=ordered        0 2
 
# /dev/sda3 UUID=57552366-9356-43bf-8bd2-bb0b25a1d318
LABEL=HOME              /home           ext4            rw,relatime,data=ordered        0 2
 
# /dev/sda1 UUID=dcba8ead-fb4b-4e06-a9e5-1a55f1c353e0
LABEL=SWAP              none            swap            defaults                        0 0
 
# /dev/sda4 Windows
LABEL=DATA              /media/data     ntfs-3g         uid=warnaud,gid=users           0 0

NTP

Reference: https://wiki.archlinux.org/index.php/Ntp

pacman -S ntp
vi /etc/ntp.conf
server 0.fr.pool.ntp.org iburst
server 1.fr.pool.ntp.org iburst
server 2.fr.pool.ntp.org iburst
server 3.fr.pool.ntp.org iburst
systemctl start ntpd

Well I don't enable it since … I mostely have no connection at boot on a laptop ;-)

os/archlinux/htpc.txt · Last modified: 2021/12/29 20:00 by warnaud