Linux Terminal Server for Home Media PCs

March 7, 2006 on 2:28 am | In Blah Blah, Sysadmin | 19 Comments

AOpen Pandora MiniPCSo I bought this new AOpen Pandora box (yes - a beige box Mac Mini ripoff). I got a Pentium M 1.73GHz and 512Mb of RAM. It comes with a DVD Reader/CDRW and I didn’t buy a harddisk or anything else. My goal was to run a single terminal server for all the Media PCs in my apartment (I have 1 in the living room & 1 in the bedroom… thinking of putting one in the bathroom).

I figured my main computer can be the Terminal Server, but as I started building it I realized that building an i386 client image on an AMD64 box was an utter pain (the script that generated it complained all the time, even after I hardcoded my arch values into it). So I figured I will just create it inside VMWare running a i386. Luckily I had latest flight of Dapper there already.

The result is a VMWare image of a Terminal Server for Media PCs (running Freevo or MythTV) that can be deployed anywhere with the free VMWare player or just by coping the files to a bootable filesystem.

Preparation

To setup a Media PC Terminal Server: I installed the latest Ubuntu Dapper Flight 4 release i386 under VMWare. It is still very rough, but usable. I figured that running a terminal server in VMWare should be sufficient for testing, and if it is too slow I can always transfer the client images to be served from my main computer.
I started by reading this:

The key line I was looking for is how to use the local resources for certain applications, in my case a video player. I found it in the section about local applications:

In an LTSP environment, you have a choice of running the applications locally on the workstation, or remotely on the server (Source).

Actually it turned out that this wasn’t what I would need, but would still be useful for running Firefox, Amarok, etc using local resources, rather then the Terminal Server’s. Nevertheless, I decided to get my hands dirty.

Hit the command-line

AOpen Pandora MiniPC
This post is not intended as a HowTo - it is more of a journal of my adventure and notes to avoid my mistakes. While I talk about Freevo & VMWare a lot - they are not required. This same process will work for any application you want to run on the local resources of a terminal client or server. I imagine many people, who setup Linux media PCs, would benefit from a centralized client image and PXE boot ability.

I will not willy-nilly around the process. Here is the meat of setting it up:

On the Terminal Server box (in my case VMWare VM):

  sudo apt-get install ltsp-server-standalone \
           ltsp-utils student-control-panel \
           openssh-server
	
  sudo ltsp-build-client
  sudo ltsp-update-sshkeys

Configure the DHCP server (turn off any other ones if you have them):

/etc/ltsp/dhcpd.conf
	
  authoritative;
  default-lease-time            21600;
  max-lease-time                21600;
	
  subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.10 10.0.0.50;
    option domain-name “domain.com”;
    option domain-name-servers 10.0.0.1;
    option broadcast-address 10.0.0.255;
    option routers 10.0.0.1;
    option subnet-mask 255.255.255.0;
	
    filename “/ltsp/pxelinux.0″;
    option root-path “/opt/ltsp/i386″;
  }
	
  group   {
    use-host-decl-names       on;
    option log-servers        10.0.0.2;
	
    host pandora {
        hardware ethernet     00:00:00:00:00:00;
        fixed-address         10.0.0.3;
    }
  }

For the sake of this example my gateway is 10.0.0.1, my terminal server is 10.0.0.2, my terminal client (new AOpen box) is 10.0.0.3. All other terminal clients will get an address from .10 to .50

The picture there is my test environment. Laptop booted of PXE running Freevo on the right, 1TB storage computer under the desk, main computer running VMWare in the center & the AOpen Pandora box on my desk powering the right screen - showing the login prompt to the terminal server.

First Tests & First Problems

Now simply reboot the Terminal Server (or just restart tftp, nfs, portmap, dhcp, etc services). When the terminal server comes up - check that DHCP server is up too.

Pick any other computer (or another VMWare machine) and boot it off the network (PXE only). You should see it talk to the tftp server, get and IP and start to boot a kernel.

Now, this is where the problems will start.

Very briefly:

  • If nothing happens - be sure your BIOS settings are set to PXE boot or network boot (if on a laptop use the onboard lan, not the wireless)
  • If PXE comes up but doesn’t pick up the kernel - check TFTP and dhcp settings;
  • If kernel boots and you see the ubuntu boot splash - you are on the right track.
  • If it crashes mounting the root fs - check your NFS config (/etc/exports) also check that your are not binding portmapper on to localhost /etc/default/portmap).
  • If X doesn’t start check out the /etc/X11/xorg.conf on the client system (because the host’s version gets modified in the process of the boot). I personally hate configuring X (I’ve been doing it since 1999, when it was hip) so if looking at that file gives you a headache - here is a good trick: boot Ubuntu Live CD and copy it from there (presuming it booted fine). In case you do need to replace the xorg.conf file - don’t bother editing it on the system - it is running in a tmpfs and your changes will be lost. Instead read on to how to configure lts.conf file.
  • If you got a login prompt, but it doesn’t let you log in - well you’re on your own… read some logs… check the ssh keys…

If you are lucky (or careful) you will just get a prompt - login using an account that works on the terminal server - and enjoy the remote desktop. Also try the CTRL-ALT-F1…F6 - you should get vterms and be able to login locally (but only as the user that exists on the terminal client image - you will have to create one)

Configuring Terminal Clients

My Terminal Server is not solely for MediaPCs. I am planning to use for just general desktop as well (if it works well). So I decided to get a client working the way I like it.

First off, it doesn’t hurt to read over the ltsp setup script: /opt/ltsp/i386/etc/init.d/ltsp-client-setup. Refer to this script to understand why crazy things are happening to your client. Also, this is a the place to include /etc/hosts information and /etc/fstab what will be used by the clients - these files are generated by the script (among others).

Next I configured the /opt/ltsp/i386/etc/lts.conf with the following info:

[Default]
        SERVER = 10.0.0.2
        SOUND = Y
        SOUND_DAEMON = esd
        VOLUME = 75
	
# Pandora Specific
[10.0.0.3]
        XF86CONFIG_FILE = /etc/xorg.conf.pandora
        LOCAL_APPS = Y
        LOCAL_DEVICE_01 = /dev/hdb:cdrom
        LOCAL_DEVICE_02 = /dev/sda:usb
        SCREEN_01 = freevo

As you can see - I enable sound by default, but for the AOpen Pandora (my MediaPC) I issues a custom xorg.conf file (which is actually placed in that location on the client image), local cdrom and USB. I also set the SCREEN_01 to start freevo.

To enable the freevo screen script - go to this folder: /opt/ltsp/i386/usr/lib/ltsp/screen.d and add this script:

/opt/ltsp/i386/usr/lib/ltsp/screen.d/freevo
	
   #!/bin/bash
   killall esd
   su - tv /usr/bin/xinit /usr/bin/freevo
	

Be sure the script is chmod’ed 755.

In the script I kill esd (which I start it in the terminal server setup) this may seem silly, but it works such that if you boot into the desktop you have sound over esd, and if you start Freevo you have sound over oss.

Both sound & local media were rather problematic. I googled around and settled on following the advice of these pages:

Local Media Config - http://wiki.ltsp.org/twiki/bin/view/Ltsp/LocalMedia#Configuration
Sound Config - http://wiki.ltsp.org/twiki/bin/view/Ltsp/Sound

Getting Freevo into the Local Client Image

Installing things to the client image couldn’t be easier. On the host system, just update the sources.list in /opt/ltsp/i386/etc/apt/sources.list and chroot to the image:

   sudo chroot /opt/ltsp/i386
	
   apt-get update
   apt-get dist-upgrade

This is assuming you have the sources for freevo and mplayer as well as universe and multiverse. If you don’t know what I mean - check out this sources.list file.

After chrooting to the system and upgrading - I just ran this:

  apt-get install freevo mencoder tvtime xine-ui \
                           w32codecs libdvdcss2 libdvdcss \
                           libxine-extracodecs libjpeg-progs \
                           exiftran lame flac cdparanoia
   freevo setup
   freevo plugins -a

Last command lists all the installed modules. Most are not activated, but look over them and pick what you might think is useful.

Configure your Freevo as you like - edit the /etc/freevo/local_conf.py (if you are still chrooted). This post isn’t really about Freevo, as much as LTSP. You should have the same success with MythTV (also an excellent piece of software) or any other such application (for Linux, or course).

Just as a small tip, if you are using Freevo, add this to your local_conf.py

    plugin.activate('headlines', level=45)
    HEADLINES_LOCATIONS = [
       ('Slashdot', 'http://rss.slashdot.org/Slashdot/slashdot'),
       ('Digg', 'http://digg.com/rss/index.xml'),
       ('BBC World', 'http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml'),
       ('CNN', 'http://www.cnn.com/services/rss/')]

(Note: Freevo config (Python) doesn’t allow leading spaces - the parameter has to be the first character of the line)

Some useful Freevo pages:

If you are going to be starting freevo after a login (as a session or from a specific user) - this may be helpful. To have the user auto-login:

/etc/X11/gdm/gdm.conf
	
   AutomaticLoginEnable=true
   AutomaticLogin=USER

Where USER is the Freevo-enabled user. Then add this script:

AOpen Pandora MiniPC

/usr/share/xsessions/freevo.desktop
	
  [Desktop Entry]
  Encoding=UTF-8
  Name=Freevo
  Comment=Freevo
  TryExec=/usr/bin/freevo
  Exec=/usr/bin/freevo
  Icon=
  Type=Application

Last you will need to add a ~/.dmrc file to the home dir of the freevo users that says:

  [Desktop]
  Session=freevo

Now just restart gdm (/etc/init.d/gdm restart) and freevo will just come up.

To make the folder look nice - follow this advice:

Moreover you can specify an image to display in the folder’s parent menu by adding an image to the folder called cover.jpg or cover.png. The size of the image depends on the current type of the menu. For movies you have something like DVD covers or movie poster, for audio a cd cover. So the image will be resized to 280×200 for movies, 200×200 for audio and 200×160 for images. These sizes will also be used for the directory images. (Source Freevo Wiki)

The picture is my finished bedroom setup. The Pandora box boots off PXE, mounts root filesystem and all the media shares (music, videos, pictures). Headlines are provided by the rss streams described above.

All your remote are belong to lirc

I will shoot myself before I finish my lirc setup… but lots of people online talk about it working… Sooner or later I will fill in this section. For now I got a USB keyboard and a long cable. UPDATE: I just got a wireless keyboard with multimedia buttons - I think it is even better then a remote - because I can type emails or just browse the web with it.

Can’t blog anymore… Gotta go watch something.

If this helped someone - I am glad… I sure tried to find a guide like this while reading every script in ltsp. In the end - it works! And it works great! Uses 5% on my client system resources to play video and uses the VMWare terminal server for NFS only (1-2% occasionally). Everything is fast, the sound is synced, video is crispy.

Now, am I going to keep it on VMWare or move it to the main system? I sort of did this in VMWare as a testbed, but now I think I will keep it. It runs fast. It is portable, so I can have it setup on several computers. I can take to a friend’s house. The whole image (both server and client) works out to be just under 3Gb - easily fits on a DVD with the free VMWare player.

Post a comment if you have questions.

Alex Pachikov - 2006 - Digg this Page

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^