Friday, May 31, 2013

Arch Linux + XBMC Installation guide







Edit: This guide is outdated, use this new one instead.

Ok, here is my first post on Linux!

A while back, I needed to reinstall the operating system on my HTPC. I had some difficulties with this, so I decided to create a step-by-step guide for if I ever need to do it again. It seemed a bit selfish to keep it to myself (or so I'm told), so I thought I'd share it here.

I will not go into what XBMC does or how to set it up here. That is very individual, and there is a wealth of information available on this in other places.

If you are a beginner with Linux, and don't want to know anything about the stuff that goes on "beneath the surface", Arch Linux is probably not for you. Instead, I'd recommend XBMCbuntu, which is a ready-made distribution for XBMC that you can download directly from the XBMC homepage. There is a graphical installer which is very easy to use.

If on the other hand, you are used to working with Linux, and/or you want to learn more about it, Arch Linux is a good way to go. There is no graphical installer, all settings, configurations, and installations have to be done by hand. On the up-side, you will get a system that is exactly the way you want it to be, and with no unnecessary SW installed.

My installation has no window manager, it is just XBMC on top of Arch Linux. If you want to be able to switch to a "normal" desktop environment for using a web-browser etc, then you can easily do that in addition to the things described in this guide, Google is your friend here.

Some of the things in this guide are optional, or HW-dependent. For both these cases I have clearly marked them as such, as well as describing what they are for.

Preparation

Download the latest version of ArchLinux from archlinux.org and burn onto a CD/DVD or use a tool like Unetbootin to install to a USB-drive.
Boot the computer from this drive and select the appropriate version.
Once booted into the live environment, you can open additional terminals and switch between them with ALT+Fx, where x is the number of the terminal, the original one is 1. Login is “root” with no password needed. It is a good idea to open at least one other terminal and open the official installation guide there, with “less install.txt”.

Arch Linux has a very active community, and a great resource is the ArchWiki. This has entries on most things that might give you trouble.

Installation

  • If needed change keyboard layout with the “loadkeys” command, the available keymaps can be sound under /usr/share/kbd/keymaps
    • loadkeys sv-latin1 (Swedish keyboard in this case)
  • Partition disks
    • I didn't need to, so unfortunately I have no specific instructions for this
  • Find, format (to ext4 filesystem in this case) and name your root partition
    • blkid/lsblk are useful commands for finding the correct partition
    • mkfs -t ext4 /dev/<partition>
    • e2lable /dev/<partition> <label>
  • Repeat previous step for any other partitions you want to format
  • Mount the new root partition under /mnt
    • mount -t ext4 /dev/<partition> /mnt
  • Edit the mirrorlist for the update tool so that the mirror closest to you is at the top
    • nano /etc/pacman.d/mirrorlist
  • Install the base system
    • pacstrap /mnt base base-devel
  • Install GRUB
    • arch-chroot /mnt pacman -S grub-bios
  • Generate basic fstab
    • genfstab -U -p /mnt >> /mnt /etc/fstab
  • chroot into the new system
    • arch-chroot /mnt
  • If you want to have other disks automounted, edit fstab and add drives, find the UUID with blkid. This can be done later during the setup or any other time as well.
    • nano /etc/fstab
    #
    # /etc/fstab: static file system information
    #
    # <file system> <dir> <type> <options> <dump> <pass>
    # /dev/sdb6 LABEL=root
    UUID=fb22b964-b38f-42df-bded-d9ac6df54ec5 / ext4 rw,relatime,data=ordered 0 1
    # /dev/sdb5 LABEL=swap
    UUID=21ecefbb-1c9d-48fa-a5f3-c9ba9a09b547 swap swap defaults 0 0
    # /dev/sdb6 LABEL=home
    UUID=d0e114fa-b428-4605-851d-504c86c0e7ac /home ext4 defaults 0 1 
    • Open /etc/hostname and add you computers name
      • nano /etc/hostname
    • Symlink your local time with the correct timezone
      • ln -s /usr/share/zoneinfo/Europe/Stockholm /etc/localtime
    • Add language config
      • nano /etc/locale.conf
      • Add “LANG=”en_US.UFT8”” for the case of english_US
    • Open locale.gen, uncomment the language profile you selected above and generate the profile
      • nano /etc/locale.gen
      • locale-gen
    • Add permanent keyboard mapping
      • nano /etc/vconsole.conf
      • Add “KEYMAP=sv-latin1” (Swedish keyboard in this case)
    • If needed, edit mkinitcpio.conf
      • nano /etc/mkinitcpio.conf
      • HW-dependent: Add “i915” under MODULES if using compatible intel video-card
    • Generate initial RAM-disk
      • mkinitcpio -p linux
    • Install GRUB
      • modprobe dm-mod
      • grub-install –recheck /dev/sdx (where x is the device that root is on. DO NOT USE THE NUMBER THAT USUALLY FOLLOWS, this is installed on the device, not the partition.
    • Configure GRUB
      • If needed you can configure grub in /etc/default/grub
        • nano /etc/default/grub
        • Change GRUB_TIMEOUT to preferred value
        • HW-dependent: If using Intel Sandy Bridge  video drivers, change so that GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.i915_enable_rc6=0" 
        • grub-mkconfig -o /boot/grub/grub.cfg
    • Set root password
    • passwd
    • Exit chroot
      • exit
    • Unmount root partition
      • umount /mnt
    • Reboot

    Setup

    • Find the name of your network card, it should be in the list generated by this command
      • ls /sys/class/net
    • Setup the network (This is for wired connection and static IP, if you want something else you will need to do it differently, please the Network Configuration article on the ArchWiki. Also, the device and IP-adresses below are for my system, so replace them with the appropriate ones for your environment)
      • Create file, network.service in /etc/systemd/system/
    [Unit]
    Description=Wired Static IP Connectivity
    Wants=network.target
    Before=network.target
    After=sys-subsystem-net-devices-enp4s0.device
    Requires=sys-subsystem-net-devices-enp4s0.device
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    EnvironmentFile=/etc/conf.d/network
    ExecStart=/sbin/ip link set ${interface} up
    ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
    ExecStart=/sbin/ip route add default via ${gateway}
    ExecStop=/sbin/ip addr flush dev ${interface}
    ExecStop=/sbin/ip lik set dev ${interface} down
    [Install]
    WantedBy=multi-user.target
      • Create file, network (config file) in /etc/conf.d/
    interface=enp4s0
    address=192.168.1.200
    netmask=24
    broadcast=192.168.1.255
    gateway=192.168.1.1 
      • Add DNS in /etc/conf.d
      • nano /etc/conf.d
      • Add “nameserver 192.168.1.1”
      • Enable and start network service
        • systemctl enable network
        • systemctl start network
    • Add user and add that user to appropriate groups(replace username with your actual username)
      • useradd -m -g users -G video, audio, storage, power, games username
    • Set password for new user (replace username with your actual username)
      • passwd username
    • Install additional packages (The ones marked in red are optional)
      • pacman -Syu mesa alsa-utils ntp avahi nss-mdns openssh samba polkit xbmc xorg-server xorg-xinit xorg-utils xorg-server-utils upower udisks
        • ntp: For synching the time with a network serve
        • avahi & nss-mdns: For Airplay support
        • openssh: Allows remote access to command line of the PC
        • samba: For Windows file-sharing (also in Linux)
    • Install video drivers
      • HW-dependent: For Intel: pacman -Syu xf86-video-intel libva-intel-driver
    • HW-dependent: For intel video drivers, add config file to disable compositing
      • /etc/X11/xorg.conf.d/20-intel.conf
    Section "Device"
    Identifier "Intel Graphics"
    Driver "intel"
    # Option "AccelMethod" "sna"
    # Option "TearFree" "true"
    EndSection
    Section "Extensions"
    # fixes tearing
    Option "Composite" "Disable"
    EndSection
    • Add config file to enable XBMC to power off and reboot
      • /etc/polkit-1/rules.d/10-xbmc.rules
    polkit.addRule(function(action, subject) {
    if(action.id.match("org.freedesktop.login1.") && subject.isInGroup("power")) {
    return polkit.Result.YES;
    }
    });
    • Optional, perform if samba was installed: Configure Samba server (Of course, replace user and paths to match your system)
      • Create configuration file
        • cp /etc/samba/smb.conf.default /etc/samba/smb.conf
      • Set correct workgroup (probably WORKGROUP)
      • Set “security = share“
      • Comment out default share and create the one that you want
    [XBMC]
    comment = XBMC media
    path = /home/jimper
    public = yes
    browseable = yes
    force user = jimper
    available = yes
    writable = yes 
    • Make sure that the folder that you share and everything beneath is accessible by all or it will not mount
      • chmod -R a+rwx /home/jimper
    • Enable services
      • Optional, perform if ntpd was installed: systemctl enable ntpd
      • Optional, perform if avahi was installed: systemctl enable avahi-daemon
      • Optional, perform if openssh was installed: systemctl enable sshd
      • Optional, perform if samba was installed: systemctl enable smbd
      • Optional, perform if samba was installed: systemctl enable nmbd
      • systemctl enable xbmc
    • Reboot









    No comments:

    Post a Comment