Diskless Mac-Mini Howto

From MythTV Official Wiki
Jump to: navigation, search

Time.png Outdated: The information on this page may no longer be relevant to the current release of MythTV, 0.27.3. Please consider helping to update it.

Minimyth.jpg

This Diskless Mac-Mini Howto should allow you to netboot a Mac Mini MythTV frontend (powerpc, not the newer intel mini!) from a Fedora 4 server, without altering anything on the Mac Mini's disk. This howto uses a script to install the netboot environment for the mac-mini, this script has only been tested on fedora core 4 (fc4), however it's very likely that it will work on any distribution, as long as rpm and chroot are available.

Before you Start

This is a work in progress... At the moment this guide should allow you to netboot a Mac Mini from a fedora 4 server, without altering anything on the Mac Mini's disk. OS X will remain functional, so this is a great way to experiment with a linux mythfrontend on a Mac Mini. The fedora 4 server does not have to be a ppc platform, in fact, this howto will only work on a i386 (or x86_64 with 32bit compat libraries) system. The script is known to work on fedora core 4, but should work (with perhaps some minor modifications) on distribution for which rpm (the redhat package manager) is available.

At this moment, this should allow you to run a stable mythfrontend (both 0.18.1, and 0.19, and 0.20 which is the default). Please note that it is also possible to run an OS X frontend (Myth on Mac OS X), you can get binaries at: thesniderpad.

Minor problems at this moment:

  • newest kernel (2.6.18+) have an nfs cache feature, which prevents two directories on one disk to be mounted both read/write and read only. This breaks redhats diskless scripts. I guess this will be fixed soon, but for the moment don't use the 2.6.18 kernel. To do this, add this line to the beginning of the mkrootfs-ppc script:
FORCEKERNELVERSION="2.6.17-1.2187_FC5"
  • sleep doesn't work (at least I can't get it to work.. )
  • newest kernel (2.6.16.1+) has some swapping over NFS problems. This can cause a deadlock on 256MB machines, for me typing this before compiling mplayer/myth solves the problem:
sysctl vm.swappiness=95
sysctl vm.min_free_kbytes=16384

if somehow compiling still fails, delete the last (empty) .o file, and continue were the mini crashed.

Major benefits over an OS X frontend:

  • Much faster (~75% idle, and runs without swap on a 1.25GHz, 256MB Mac Mini. With kerneldeint and denoise3d ~10% idle)
  • Allows aspect ratio changes
  • Allows most plugins (mythgame is disabled at the moment)
  • Netboot allows the harddrive to be spun down. I really hate that whine in my otherwise very quiet Mini.

Although this is a bit experimental, it shouldn't be too hard to get things working. If you are a complete linux noob, and terms like dhcp, named and so forth mean nothing to you, then it might be a bit of a challenge.

Bas Hulsken

Prerequisites

Package.png You'll need the following packages installed on your server:

  • tftp-server ( allows systems to netboot from this machine )
  • dhcp ( allows systems to obtain ip address from this machine )
  • rpm ( always present in fedora systems, if you have another distribution, you might have to install it)

Now, download the collection of scripts and tools to build the diskless environment: diskless-0.4.tar.bz2 (my DSL link is a bit slow, but the file is not big...)

Setting up the server

Configuring the dhcp server

Make sure your dhcp server is started at boot:

chkconfig dhcpd on

And make sure it is configured correctly. Howto do this is beyond the scope of this howto, but see for instance: John Cooke's guide. Here is the dhcpd.conf that I use, which allows for dynamic dns:

authoritative;
ddns-update-style              interim;
ddns-updates                   on;
ignore client-updates;
update-optimization            off;

key DHCP_UPDATER {
        algorithm hmac-md5;
        secret "secret md5 hash, created with: dnssec-keygen -a HMAC-MD5 -b 128 -n USER DHCP_UPDATER";
};

zone steadydecline.net. {
        primary 127.0.0.1;
        key DHCP_UPDATER;
}

zone 1.168.192.in-addr.arpa. {
        primary 127.0.0.1;
        key DHCP_UPDATER;
}

subnet 192.168.1.0 netmask 255.255.255.0 {
        range dynamic-bootp            192.168.1.2 192.168.1.254;
        default-lease-time             7200;
        max-lease-time                 43200;
        option domain-name             "steadydecline.net";
        option domain-name-servers     192.168.1.1;
        option netbios-dd-server       192.168.1.1;
        option netbios-name-servers    192.168.1.1;
        option netbios-node-type       0x8;
        option routers                 192.168.1.1;
        option subnet-mask             255.255.255.0;
        option time-offset             3600;
        ddns-domainname                "steadydecline.net";
        option ntp-servers             192.168.1.1;
}

class "minimyth" {
# matches only the MacMini, which has hardware ethernet address: 00:0d:93:5e:3f:bc
        match if substring (hardware, 1, 6) = 00:0d:93:5e:3f:bc;
        ddns-hostname                  "minimyth";
        default-lease-time             43200;
}

On the discussion page you'll find a comment from Klaus Weidner about static ip. I'm still not sure if it's necessary to define a static ip, on my system it seems to work with a dynamic ip. Mythtv uses the hostname, and the netboot script installs files in a directory named after the hostname, not the ip. Anyway, if a dynamic ip is troublesome for you, use a fixed one, by adding these lines to dhcpd.conf:

host minimyth {
        hardware ethernet 00:0d:93:77:77:77;
        fixed-address 192.168.1.999;
}

and remove these lines:

class "minimyth" {
# matches only the MacMini, which has hardware ethernet address: 00:0d:93:5e:3f:bc
        match if substring (hardware, 1, 6) = 00:0d:93:5e:3f:bc;
        ddns-hostname                  "minimyth";
        default-lease-time             43200;
}

Configuring the tftp server

tftp in fedora core 4 is a part of the xinet daemon. So make sure xinetd is started at boot:

chkconfig xinetd on

and make sure the tftp service is allowed (disable = no) in the file /etc/xinetd.d/tftp

Configuring NFS

For netbooting from this server, two NFS exports are required, one directory for the static root file system, and one directory containing a snapshot for each diskless system booting from this server. Add these two lines to /etc/exports (my domain is steadydecline.net, change to your own, the script defaults to using fc5 on the mini, if you change this to fc4 or fc6, then also change the exported directories):

/diskless/ppc/fc5/root/ *.steadydecline.net(ro,sync,no_root_squash)
/diskless/ppc/fc5/snapshot/ *.steadydecline.net(rw,sync,no_root_squash)

And re-export filesystems

exportfs -a

Important.png Note: re-exporting the filesystems doesn't always work for me. If this won't work, just restart the nfs daemon

with:
/etc/init.d/nfs restart

Configuring a lirc server

If you own an ATi remote wonder II (a radio-frequency remote control) that is connected to the fc4 server, then you can setup a lirc server. This is pretty straightforward, this /etc/sysconfig/lircd allows lirc on the server to listen on port 8765 for network connections:

/sbin/modprobe lirc_atiusb
LIRCD_OPTIONS="--listen=8765 --device=/dev/lirc0"
ENABLE_LIRCMD="no"
LIRCMD_OPTIONS=""
ENABLE_IREXEC="no"

Of course, on the server you will need the appropriate /etc/lircd.conf for your remote. See the lirc documentation, LIRC, and ATI Remote Wonder II.

Creating the diskless environment

Now unzip the build environment (diskless-0.4.tar.bz2) to the root filesystem. Please note that this build environment is for i386 linux, this is because it uses some scratchbox binaries compiled for i386. It should work on x86_64 if the right 32bit libraries are installed. But it won't work on ppc. On ppc there should be no need for the scratchbox binaries anyway, you can edit the script a bit to disable the scratchbox parts (if you do this with the proper conditionals, I'll take over the changes in my script). Now type the following as root, to extract the build environment to the root filesystem:

cd /
bzip2 -cd diskless-0.4.tar.bz2 | tar xfv -

Enter the /diskless directory, and read and edit the script as you see fit. Some configuration files that will be installed in the diskless environment are located in /diskless/conf. Edit those for your Mac Mini. In particular edit these files:

  • /diskless/conf/xorg.conf (edit monitor settings for your screen, if you have a DELL 2005FPW, this xorg.conf should work)
  • /diskless/conf/lircd.conf (replace with the lircd.conf from your server, if you are using lirc)

Now run the script as root (RPM relies on chroot to install in different locations, chroot works only as root, sorry about this.. you'll have to trust me.. or carefully read the script):

cd /diskless
./mkrootfs-ppc

Now a whole bunch of files will be downloaded (only once), and a diskless enviroment will be built. Somewhere you'll be asked for a password for vnc. Remember this password, you can use it later on to connect to the macmini with the vncviewer program. After this is done, copy the kernel, the initrd image, the bootloader and the bootloader config to the tftpboot directory.

cp /diskless/tftpboot.fc5/* /tftpboot/

Now the netboot environment should be ready!


Important.png Note: the yaboot binary included in fc5 has been a bit troublesome for me, it just puts me in the openfirmware menu instead of booting.. I have no idea why this happens, and if its limited to my machine. If the same happens for you, just copy the yaboot binary from the fc4 package. It's located at /usr/lib/yaboot. You can use midnight commander (mc) to extract it from the rpm.

If you want to use mythtv and mplayer on the Mac Mini, you have to compile them on the Mini. I've written two simple scripts to download svn/cvs versions of mythtv and mplayer into the diskless environment. It also applies a few patches (agains libcdaudio, and mythmusic). If you want to use these scripts, you should run them before booting the mini! Run the scripts in the /diskless directory like this:

./getmythtv
./getmplayer

Make sure that all files/cvs/svn are downloaded/checked out! Sometimes sourceforge or ftp servers are temporarily offline.

Forcing the Mac Mini to boot from the net

Now netboot has to be made the default for the Mac Mini. Boot the Mini into OS X, open a command prompt (or just ssh into it), and type the following:

sudo nvram boot-device="enet:192.168.1.1,yaboot"

where 192.168.1.1 is the ip address of the fc4 server you are going to boot from. If all is well, the next time you boot the Mac Mini, it should boot into linux from the net! You can access your Mini with ssh, as user root, with the same password as the root user on your server. Also once you start X, you can use vncviewer to control the mini.

Once you are tired of Linux, you can boot from disk by default by typing this on the Linux commandline (of the Mac Mini!, as root):

nvsetenv boot-device hd:,\\\\:tbxi

Important.png Note: If the mini can't boot from the net, then it will wait for a very long time (around 10minutes I think) and then boot from the harddrive. So you can't really ruin your mini with these lines. Although it may seem dead for some time, don't panic! Just wait, and restore to normal boot behaviour with the line shown above.

The first time you netboot the mini, a lot of data will be copied (~500MB), also the bootscript will generate the module dependency list, and dynamic library cache. Depending on your network speed this can take upto 60 minutes! The new version of the bootscript (version: diskless-0.3 and higher) forces a reboot after all the copying is done, to use the newly generated modules.dep and ldconfig.cache.

Building mythfrontend on the Mac Mini

The mythfrontend has to be built on the Mac Mini itself, as there are no ppc RPMS available (as far as I know). The same goes for mplayer. If you've downloaded the myth and mplayer sources with my scripts (as explained in the previous chapter) then compiling and installing myth and mplayer is very simple. Log in to the mac mini with secure shell (remember, user: root, password the same as on the computer you build the diskless environment on), and:

cd ~/sources
./buildmythtv
./buildmplayer

This compiles mythtv +plugins and mplayer, and installs them in /usr/local. This will take a long time! Moreover, it might crash if your mini has only 256MB of memory (mine has). If that happens, do the following:

  • reboot the mini
  • delete the empty .o file where the compilation process stopped, this is very important!! Otherwise make will skip that file, and the compilation will fail later on.
  • edit the buildscript to continue where it crashed (means you have to run make again, but not ./configure !)
  • hope it will finish this time, if not, just repeat the whole exercise. Eventually it will compile!

Now you can start the frontend by typing:

/etc/init.d/mythfrontend start

or even easier just reboot the mini:

reboot

The next time you netboot your mini, mythfrontend will start automatically.

Running mythfrontend on the Mac Mini

Now your Mini is a fullblown MiniMyth frontend! Mythfrontend should start automatically on boot. You can use vncviewer to control the mini, or set up a decent lirc configuration. Make sure to use 'ALSA:default' as the sound device, also set the mixer to 'default'. Oss emulation sounds ugly! If you got this far, and your setup is working, don't forget to report it in the table below!

Configurations known to work

known working configurations
server distribution mini distribution myth version mini type script version reported by
fedora core 4 fedora core 4 0.19-fixes 1.25Ghz ppc 256MB WiFi+Bluetooth DVD+CDRW diskless-0.3 Bas Hulsken (--Bas 18:43, 22 October 2006 (UTC))
fedora core 4 fedora core 5 0.20-fixes 1.25Ghz ppc 256MB WiFi+Bluetooth DVD+CDRW diskless-0.4 Bas Hulsken (--Bas 18:43, 22 October 2006 (UTC))