From MythTV Official Wiki
Jump to: navigation, search



Combined (secondary) backend/frontend

  • AMD Athlon64 X2 5050e (2.6GHz); 2GB DDR2
  • ASUS M3N78-VM (onboard 8200)
  • 2x PVR-150; 1x HVR-1250
  • 2x 320GB for recordings
  • Network boot (iscsi) from FSERVE
  • Gentoo and MythTV trunk

This machine sits in the basement, and is attached to the TV directly above it through a hole cut in the floor.


Frontend only

  • AMD Athlon64 2GHz; 1GB DDR
  • Geforce 8400GS PCIe; Audigy 2 ZS
  • Network boot (iscsi) from FSERVE
  • Gentoo and MythTV trunk


Frontend only

  • AMD Opteron 165; 3GB DDR
  • Geforce 8400GS PCI; SB Live 5.1
  • Network boot (iscsi) from FSERVE
  • Gentoo and MythTV trunk


Primary backend, archival storage, recording storage

  • AMD Phenom II X2 560; 4GB DDR
  • Areca ARC-1230; 9x750GB RAID6 ZFS (5250GB)
  • 2x320GB RAID1 ZFS boot, 2x2TB additional storage
  • 1x HDHomeRun
  • FreeBSD 8.0 and MythTV Trunk
  • Also runs Mythweb, MYSQL, Windows PDC, NFS and iSCSI targets, PXE/TFTP boot server

The case (Codegen S-201) has storage for 11 5.25" bays, 8 of which are configured for 12 3.5" hotswap bays.

iSCSI Boot (work in progress)

These instructions are on how to set up a machine to boot off an iSCSI disk. While this procedure should work on any distro, it is designed for Gentoo.

Install Open-iSCSI

Open-iSCSI is the primary software target and initiator for linux. While this can be used to set up your iSCSI server (target) as well, this guide will be solely for the client machine (initiator). Remember that with iSCSI, you mount shares as if they were a local disk, so you cannot use the same image on multiple systems simultaneously using standard file systems. Open-iSCSI exists partially as a kernel module, so make sure to get the correct version for your kernel. The necessary modules now come shipped with the linux kernel source and can be used instead.

Once Open-iSCSI is installed, make sure to set up the initiator in /etc/iscsi/initiatorname.iscsi

Mount Disk

Open-iSCSI must be loaded and started first.

# /etc/init.d/iscsid start

If you installed manually rather than through a package manager, run:

# modprobe scsi_transport_iscsi
# modprobe libiscsi
# modprobe libiscsi_tcp
# modprobe iscsi_tcp
# /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

Enumerate available targets on your iSCSI server.

# iscsiadm --mode discovery --type sendtargets --portal,1,1,1,1,1,1,1

Connect to your disk.

# iscsiadm --mode node --targetname --login
Logging in to [iface: default, target:, portal:,3260]
Login to [iface: default, target:, portal:,3260]: successful

You should now have a new disk listed as /dev/sd<n>. For the purposes of this example, the boot disk will be running JFS, and will have two partitions: 1GB for swap, and 4GB for data. Use whatever method you need to create a new system install on this new disk. Be sure to install and set up Open-iSCSI on it.

PXELinux config

The kernel needs to know what target to connect to on boot. Setting that on the command line allows one kernel to be used for multiple machines. Make sure to set your initiator tag to the one you will be using on the new system as defined in /etc/iscsi/initiator.iscsi.

LABEL my_label
  menu default
  menu label ^my iSCSI boot image
  KERNEL /images/gentoo_2.6.31.r4_amd64_iscsi
  APPEND iscsi_tip= iscsi_tgt=2 iscsi_tag=iqn.2009-12.localdomain.localserver:openiscsi

Create initramfs

This boot image will load any necessary modules, connect to and mount the iSCSI share, switch to the new root, and continue booting.

Directory Structure

|     |----modules/

Creating dev nodes

Since this is all occurring before the services that usually generate dynamic device nodes is started, these will have to be statically created using the mknod command.

mknod <name> <type> <major> <minor>
mknod console c 5 1
mknod sda b 8 0

Nodes that should be created are as follows.

crw-r--r-- 1 root root 5, 1 Oct  9 03:45 console
crw-r--r-- 1 root root 1, 3 Oct  9 03:59 null
crw-r--r-- 1 root root 5, 2 Oct  9 04:00 ptmx
brw-r--r-- 1 root root 8, 0 Oct  9 03:45 sda
brw-r--r-- 1 root root 8, 1 Oct  9 03:45 sda1
brw-r--r-- 1 root root 8, 2 Oct  9 03:45 sda2
crw-r--r-- 1 root root 4, 0 Oct  9 03:59 systty
crw-r--r-- 1 root root 5, 0 Oct  9 04:00 tty
crw-r--r-- 1 root root 4, 0 Oct  9 04:00 tty0
crw-r--r-- 1 root root 4, 1 Oct  9 04:00 tty1
crw-r--r-- 1 root root 4, 2 Oct  9 04:00 tty2
crw-r--r-- 1 root root 4, 3 Oct  9 04:00 tty3
crw-r--r-- 1 root root 1, 5 Oct  9 03:59 zero

init script

When the initramfs is loaded, the kernel will call the init function in the base directory. Here is a basic example. It parses the newly generated disk from the kernel logs, and allows for use with locally attached disks. It also loops over the setup portion repeatedly before failing to an emergency terminal. This is to correct for network cards that may take some amount of time to come online after being brought up.

Script.png /init

#!/bin/busybox sh

  # Grabbing network address and routes
  ifconfig eth0 up
  udhcpc -t2 -q -n -s/bin/udhcpc.script

  # Connect the iSCSI drive
  iscsistart -i "${ISCSI_TAG}" -t "${ISCSI_TGT}" -g 1 -a ${ISCSI_TIP}
  sleep 1

  # Parse disk name
  BUS=`dmesg | sed -e '/ scsi[0-9]* : iSCSI /!d; s/.* scsi//; s/ :.*//' | tail -n1`
  DISK=`dmesg | sed "/sd $BUS:0:0:0:/!d; 1d; s/.*:0:0:0: \[//; s/\].*//" | tail -n1`
  if [ -z $DISK ]; then
      echo disk not found

  # Check FS image
  echo fscking file system
  /bin/fsck.jfs /dev/${DISK}2

  # Mount FS
  echo mounting jfs read only
  mount -t jfs -o ro /dev/${DISK}2 /sysroot

  # Check mount
  if [ -f /sysroot/sbin/init ]; then
    umount /proc
    umount /sys
    exec switch_root /sysroot /sbin/init

# Mount /proc and /sys
echo Mounting /proc filesystem
mount -t proc none /proc
echo Mounting sysfs
mount -t sysfs none /sys

# Loading Modules
insmod /lib/modules/scsi_transport_iscsi.ko
insmod /lib/modules/libiscsi.ko
insmod /lib/modules/libiscsi_tcp.ko
insmod /lib/modules/iscsi_tcp.ko

###### command line variables #######
# iscsi_tip - target ip
# iscsi_tgt - read/write target
# iscsi_tag - initiator tag

CMDLINE=$(cat /proc/cmdline)




echo iSCSI Tag:    $ISCSI_TAG
echo iSCSI Target:${ISCSI_TGT}
echo iSCSI IP:     $ISCSI_TIP

for i in 1 2 3 4 5 6; do
  echo Running boot attempt
  sleep 5

# boot failed, drop to emergency terminal
echo Failed to mount root
echo iSCSI Tag:    $ISCSI_TAG
echo iSCSI Target:${ISCSI_TGT}
echo iSCSI IP:     $ISCSI_TIP
exec /bin/busybox sh


udhcpc script

Script.png /bin/udhcpd.script

#!/bin/busybox sh

[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"

case "$1" in
                ifconfig $interface
                ifconfig $interface $ip $BROADCAST $NETMASK

                if [ -n "$router" ] ; then
                        echo "deleting routers"
                        while route del default gw dev $interface ; do

                        for i in $router ; do
                                route add default gw $i dev $interface

                echo -n > $RESOLV_CONF
                [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
                for i in $dns ; do
                        echo adding dns $i
                        echo nameserver $i >> $RESOLV_CONF


exit 0


Install binaries

The initramfs image will need `busybox`, `iscsistart`, `fsck.jfs`, and the above udhcpc script. Use `ldd` to figure out which libraries you need, and copy them into /lib. Copy the four iscsi kernel modules listed above into /lib/modules. Also be sure to copy any needed network and file system modules not included in the kernel.

Finish Up

Shutdown scripts

Since your filesystem is now accessed by iSCSI, both iscsid and network must remain active until the system shuts down. The shutdown scripts must be modified to prevent these services from being terminated prematurely.a