Tuesday, August 2, 2011

Installing XBMC 10.1 Live CD on Shuttle xs35gt v2

PART 4: XBMC Live CD
  • Part 1: the hardware
  • Part 2: the software choices
    • Part 3: Linux Basics / Ubuntu 10.10
    • Part 4: XBMC Live CD
This gives you a functional Ubuntu 10.04 LTS server that automatically launches XBMC by default after startup. This system can easily be expanded for other purposes. However, it will not have a desktop environment (GUI) like Gnome or K. So, this won't be a good computer for normal stuff like email, browsing, wordprocessing, etc. (Of course a GUI can be installed.)

While I had this up and running, I no longer have it installed, so I am presenting this as a record of what I did. It worked as described below. Nicholas and I can provide suggestions, but there is no system to test against. in the Part 5, I'll describe configuring OpenELEC, which I opted for in favor of the Live CD.

This guy has a good write up describing installing an older version of the Live CD on the first revision of the xs35gt. It is a good reference, but I didn't need to do a lot of what is described. Even on the new versions that I am using, wired networking was not setup during installation, meaning I had to enable it manually.

I installed this while peppering Nicholas with questions over chat because it s a lot faster to say, "Yo! Nicholas, how do I do X" than it is to google for it. Googling would definitely work, but Nicholas is faster.

Installing XBMC 10.1 Live CD on Shuttle xs35gt v2 with an SSD

Overview

The order in which I am presenting this is not the order in which we did it. The last thing we did was enable sound, but for the sake of those without SSDs, I decided to order this write up thusly:
  1. Make some changes to the BIOS
  2. Wipe all existing data from the solid state drive and install
  3. Configure wired networking
  4. Install SSH
  5. Configure HDMI sound output
  6. Configure analog sound output
This also describes steps that are particular to solid state drives. If you are installing onto a USB stick (unless it supports TRIM commands) or a traditional spinning hard disk, stop here. This first step can be presumably skipped for people installing later versions of the Live CD (greater than 10.1)
  1. Install a linux kernel that supports TRIM commands for SSDs
After confirming that your kernel supports TRIM, then you need to configure it:
  1. Set TRIM for the SSD
  2. Lower swappiness
Finally, while I never bothered to do it, here are my thoughts on what you could try to do for configuring wireless networking. I don't guarantee this will work.
  • Our thoughts on what you might have to do to enable wireless networking
1. Configure BIOS
  1. Unlike the original revision of the xs35gt, v2 shipped with a BIOS version that allows disabling of wifi power control, which is required for the wireless to work properly with linux. Personally, I am using the wired gigabit ethernet due to the much higher throughput, so I have the power control setting enabled.
  2. Set SATA to AHCI.
  3. Set an appropriate order for boot disks, such that the media from which you will install (CD or USB) is higher priority than the internal disk. (The order can be altered after installing.)
2. Install from CD or USB stick

I'm not going to describe the actual installation. In general, you'll need to:
  • Download the Live CD ISO from here.
  • Create install media from one of the following:
    • Burn ISO to CD
    • Make USB installer (Ubuntu example). Cheap USB sticks often don't work.
  • Partition and format the target disk
    • swap partition
    • Data and OS partition

There has been some discussion of if swap is a good or bad thing on SSDs. With 4 GB of RAM (or even with only 2 GB), it shouldn't be necessary if all this is doing is running XBMC. However, it is unclear how the lack of swap could affect some programs that expect it to be there. So it is probably best to create a swap partition, and then set swappiness down.

Regarding partitioning of the rest of the drive, you could 1) create a small partition for the OS and a second for data, or 2) leave it as one big partition. The former is nice if you think you might want to try multiple OSs because you can leave all your media on the data partition and just clone (backup) the OS partition. The problem is that you have to decide exactly how big to make the OS partition. Too small and you'll run out of room. Too big and it could wind up as wasted space.

I considered going with option one but in the end just made one big partition.

boot the XBMC live CD on the target computer

Once in, you want to quit XBMC. Don't shutdown the computer, just quit. This will bring you to the command line. You'll need to login with the username and password you created during installation (If my memory is failing me and you weren't prompted to create a password, try xbmc xbmc for user and pass.)

3. Configure wired networking

While the necessary drivers were installed during installation, the wired NIC probably wasn't detected, so you'll have to manually enable it:

ifconfig

If you don't see eth0 but only the loopback interface, then

sudo ifconfig eth0 up

Enter your admin password.

ifconfig

This time you should see eth0. Next you need to configure it. You'll want this XBMC box to have a static IP address. If you router supports static DHCP, you can tell your router to always assign it the same IP. If not, then when you try and find it on your network with either another computer or your android remote, it will be like hitting a moving target.

To enable DHCP using vi (see here for a list of vi commands):

sudo vi /etc/network/interfaces

Add to the end of the file

auto eth0
iface eth0 inet dhcp


Restart networking.

sudo /etc/init.d/networking restart

[NOTE: if you have never used vi, it might be best to try something different like nano.
sudo nano /etc/network/interfaces
I don't recall if nano was installed. If not, you can try installing with.

sudo apt-get install nano

You can then substitute nano for an vi commands]

To enable a Static IP (this replaces the above DHCP configuration):

auto eth0
sudo vi /etc/network/interfaces
iface eth0 inet static
       address 192.168.0.2
       netmask 255.255.255.0
       gateway 192.168.1.1


Be sure to replace the numeric values with those appropriate to your network.

4. Install SSH

I own one keyboard and it is typically at work. So without SSH, I have no way of interacting with the command line of this machine. Plus, if you are googling for things, or in my case just bombarding Nicholas with questions via a chat window, it is good to be using SSH, so you can simply paste in any commands, like the one you see here.

sudo apt-get install openssh-server

To access the the XBMC computer:

ssh username@xbmc-box's-IP-address

You'll have to accept the RSA key.

5. Configure HDMI sound output

Restart XBMC and configure your sound.

sudo /etc/init.d/xbmc-live start

(This command also takes the arguments stop and restart.)
Navigate to System/Audio and set the following to get sound working through the HDMI cable attached to you TV (if you want to listen through a stereo, see below).
  • Audio output: HDMI
  • speaker config: 2.0
  • Boost vol: on
  • AC3: on
  • DTS: on
  • Audio output device: HDA NVidia hdmi
  • passthrough: HDA Nvidia hdmi
6. Configure analog sound output

If you want to route the sound through an external stereo with the 3.5 inch headphone jack:
  • Audio output: analog
  • speaker config: 2.0
  • Boost vol: on
  • Audio output device: Defaults
7. Upgrade the kernel for TRIM support

SSD drives will slow down over time without TRIM enabled. It is included from the Linux 2.6.33 kernel and is supported by the ext4 file system. If you are installing a version of the XBMC Live CD that is greater than 10.1, then the chances are that you can skip this.

You will need to exit XBMC to the command line of SSH in from another computer.

First, check the kernel version.

uname -r

If it is greater than .33, go to the next step. If not, then you will need to install a newer kernel. XBMC 10.1 Live CD was based on 10.04 LTS. Here, we will install the 2.6.35 kernel from 10.10 to get TRIM support (see here)

sudo apt-get update && sudo apt-get install linux-image-generic-lts-backport-maverick linux-headers-generic-lts-backport-maverick

Restart the computer

sudo shutdown -r now

After rebooting, from the command line verify the new kernel

uname -r

8. Set TRIM

Finally you need to enable TRIM on your SSD. First back up the file you're about to edit. (see here)

sudo cp /etc/fstab /etc/fstab_bak-notrim

Next, you are doing to want to add discard to the fstab entry for your partitions that are ext4.

sudo vi /etc/fstab

The final thing should look something like this

UUID=[NUMS-AND-LETTERS] / ext4 discard,errors=remount-ro 0 1

9. Lower swappiness

Finally, the last thing you want to do is lower swappiness. When I did this originally, I used a value of 1. This means that the system will only write the contents of its hard memory to the swap partition on the SSD under the most extreme circumstances. (See here.)

Check the current settings

cat /proc/sys/vm/swappiness

The output I got was 60. We want to lower this by editing this file.

sudo vi /etc/rc.local

Add this line

echo 1 > /proc/sys/vm/swappiness

Reboot

sudo shutdown -r now

And check to make sure all is well.

cat /proc/sys/vm/swappiness

You should get back 1.

Our thoughts on what you might have to do to enable wireless networking

Because the xs35gt v2 has gigabit wired ethernet, and because I can't write to the ext4 partitions directly with my notebook that stores my music, I decided it would be best to use wired networking for file transfers. I meant to try out the wireless but I completely forgot to before wiping out this system. If I was to try and get wireless working, this is what I'd do.
  1. Boot into BIOS and disable Wireless Power Control
  2. try to bring up wireless
    sudo ifconfig wlan0 up
  3. Next, look for it
    ifconfig
If it shows up in the ifconfig output, Then try enaling it with DHCP first.

sudo vi /etc/network/interfaces

Add to the end of the file

auto wlan0
iface wlan0 inet dhcp


Restart networking.

sudo /etc/init.d/networking restart

If it works, you can try switching to a static address.

auto wlan0
sudo vi /etc/network/interfaces
iface wlan0 inet static
       address 192.168.0.2
       netmask 255.255.255.0
       gateway 192.168.1.1


If it doesn't work, then you are probably going to need to install drivers.

5 comments:

  1. Do you find yourself running anything else other than XBMC once you have an always-on server? Subsonic or ampache to stream your music when you're out, freeswitch or asterisk to route SIP and GTalk calls, rtorrent and rss catchers for p2p, ushare to stream video to devices other than your tv, etc?

    ReplyDelete
  2. ht03a→atrix tokyoAugust 4, 2011 at 11:09 PM

    I wondered the same thing...how are you - or, should i say, ARE YOU - streaming out to your phone when out and about. For music, I just use the audiogalaxy app (mac os to android); for video I just use the plex app (mac os to android)...audiogalaxy works well for audio, but plex has it's issues...wondered if XMBC offered a solution...?

    ReplyDelete
  3. I'm not running it all the time.

    So I'm not doing any streaming. Two reasons: 1) I don't have unlimited data on my phone. 2) When we are supposed to be finding ways to reduce energy usage, it seems wrong to implement a 24/7 server, even if it is low wattage.

    I haven't got around to posting the configuration that I am running, but this system was wiped in favor of an embedded linux that servers only one purpose. running xbmc. The computer is off all day until I want to hear some music or watch a dvd or youtube or whatever, then I turn it on with the power button, and by the time I've turned on the stereo and TV, xbmc is up, running, and responsive.

    In part one, I think I mentioned that I was originally planning on a pbx server and open vpn, but then I realized I really wouldn't use it. Maybe at a later date, I'll look into it.

    If Ubuntu 11 really boots as fast as they say, once xbmc is compatible, I might make the switch to a full blown linux install.

    ReplyDelete
  4. I am running an older version of the one SBS Droid has and using Ubuntu 10.10. I have a torent manager on it and also have Apache running on it. I have assigned an internal ip to host a website that goes to where the download directory is. That way I can just click a link and download files wirelessly to my tablet.

    Also Astro file manager can connect to the server using SSH and allows me to manage the files on it.

    ReplyDelete
  5. Nice article - after reading parts 1 to 4 I think the XS35GT V2 is probably the best choice for me, as my major concern is to build a fanless and affordable HTPC.

    I started with choosing the software and had a look at XBMC Live and openELEC.tv (temporarily re-purposing my netbook ;) ), which is my favourite so far (going to give ztreambox a try next week).

    At first I looked for a stylish (= good WAF) case and found the Zotac ZBox (w/ DVD or BD drive), but rethinking it a box mounted at the rear of the TV might be the better solution - which is where the XS35GT V2 comes into play.

    So I am looking forward to part 5 and your thoughts and experiences regarding openELEC.tv.

    ReplyDelete