Diskless Frontend (automated creation)

From MythTV Official Wiki
Jump to: navigation, search

Introduction

To run a diskless computer, an operating system image needs to be held on a server for the diskless computer to execute remotely. This guide presents an automated solution to the creation of such an image for a MythTV frontend, using an image-creation tool known as Kiwi. Using the automated approach avoids much of the complication involved in installing and configuring the image: rather than fiddling around inside a chroot environment to set up each image, the entire process is performed by a single command, taking an image description as a recipe. What's more, I've set up an image description for this particular task that may be very close to meeting your requirements.

Information about Kiwi can be found here: Kiwi documentation

Restrictions

Kiwi was originally developed to run under the opensuse Linux distribution. Apparently there are versions for other distributions, but they may differ in some detail and I would not expect the image description presented here to work under them without change. If opensuse isn't your distribution of choice, you may need to install a minimal copy of opensuse in a VM to be able to run Kiwi. (Note there is no need to use opensuse as the server for the image, once created.)

The image description presented here has been tested only on opensuse 13.1

How the image description is presented

Kiwi provides a number of template image descriptions for creating minimal systems. The MythTV frontend image description is based on one of them, known as JeOS. I've taken the basic JeOS image description and transformed it into a fully configured MythTV frontend image description in a few smallish steps and recorded those steps in a git repository as commits. If the result doesn't exactly meet your requirements, you should be able browse the steps and see where to make your own little tweaks. Specific parts that are likely to need a little alteration are listed below. The instructions below are intended to be followable independently of knowledge of git, but may not manage that goal!

The image description git repository is held here: Kiwi Mythfrontend on Github

Generating the image

You'll need to:

  • checkout a local copy of the image description
  • make a few tweaks to match your own requirements
  • run kiwi to generate the image

Checking out a local copy

Clone the repository locally by running:

git clone git@github.com:Glidos/kiwi-mythfrontend.git kiwi-mythfrontend

Tweaking to match your requirements

First take a look at the list of commits that produced the image description (there are 13 and only 4 are likely to need alteration). If you know git, you can look at the commits with your favourite git tools on your local copy. Otherwise look at them listed on github here: list of steps to make the configured image description. You can click on the individual commits to see the change I made. The ones that may need altering are

  • Set up the users
  • Setup remote control using lirc
  • Use an nfs share for .mythtv directory to make it persistent
  • Add Nvidia proprietary drivers

I'll explain what may need doing for each in detail. If you know git, you may want to make the changes with git rebase -i, to create a version of the branch specific to you. Otherwise, just directly editing the checked out image description is fine.

Set up the users

This should work just fine how it is, other than you wont be able to ssh into the diskless system because the passwords aren't set up for the two users mythfronend and root. You'll see I've inserted XXXXXXXXXXXXX and YYYYYYYYYYYYY as place holders for the encrypted passwords. You'll need to run a kiwi command to generate the correct strings for your chosen passwords. The command to run is:

kiwi --createpassword

Setup remote control using lirc

With this commit, you'll see the line:

baseUpdateSysConfig /etc/sysconfig/lirc LIRCD_DEVICE /dev/input/by-id/usb-Philips_eHome_Infrared_Transceiver_PH00YzQQ-event-if00

added to the file config.sh. The device name is unlikely to match the one you have. When you first get your frontend running, you'll need to ssh into it and list the directory/dev/input/by-id/ to find out the correct name to substitute for that one. With that information, you can update your copy of the image description and then regenerate the image.

Use an nfs share for .mythtv directory to make it persistent

The frontend has only read access to the image on the server and uses overlayfs to keep written data in memory, so all changes are lost each time you power off the system. Mythfrontend stores various things that you actually don't want to lose in the directory .mythtv, so it useful to make that persistent by making it an nfs mount of a directory on the server. Also, you may have directories of audio files and image files that you want to make accessible to mythmusic and mythgallery. That is the purpose of this commit. You'll need to update the .mount files to match your server. glidos.site is the network name of my server. You'll need to replace it with your own, along with the specific paths for the shares. Of course, you'll also need to set up your server to export the shares (although that's a task involved independently of whether you use Kiwi or not).

Add Nvidia proprietary drivers

If your frontend doesn't have a vdpau capable nvidia graphics card you'll want to remove this commit completely, or edit the changes out of your local copy.

If you do have an nvidia card, you may still want to edit the packages to use the G02 drivers rather than the G03. I seem to get better image quality with the G02s, although I may be imagining it. If you do so, leave out nvidia-glG03 altogether because there is no nvidia-glG02.

run kiwi to generate the image

To generate the image, note the path of the image description, choose a path where you want the generated files to appear, and run the command

kiwi -b <image description path> -d <generated files path>

The command must be run as root.

Various files and links will appear in your chosen directory. The important ones have names with the form:

  1. initrd-netboot-suse-XXXX.kernel.YYYY-default
  2. initrd-netboot-suse-XXXX.gz
  3. MythTV.x86_64-1.0.0

These are respectively:

  1. the kernel
  2. the initial ramdisk (initrd) for the first boot stage
  3. the actual image

Setting up the server

How to setup the server is explained in the Kiwi documentation: Kiwi Chapter 13. PXE Image Thin Clients. The particular variant I am using is "Root Tree Over AoE". If you are familiar with PXE booting, you'll see that the method used with Kiwi is customary, other than having an extra file that must be served via tftp. The file should be called config.default and be placed in a subdirectory called KIWI within the tftp root. The file should contain

AOEROOT=/dev/etherd/e0.1
UNIONFS_CONFIG=tmpfs,aoe,overlay

To server the image, find out the name of your ethernet interface (eth0 say) and use vblade, starting it with command:

vblade 0 1 <ethernet interface> <path to image>

Besides that, following any guide on PXE booting should be fine.