Difference between revisions of "User:Wagnerrp"

From MythTV Official Wiki
Jump to: navigation, search
m (machinery updates)
(document booting off iscsi)
Line 1: Line 1:
 +
=Machines=
 
===mythbe===
 
===mythbe===
 
Combined (secondary) backend/frontend
 
Combined (secondary) backend/frontend
Line 5: Line 6:
 
*2x PVR-150; 1x HVR-1250
 
*2x PVR-150; 1x HVR-1250
 
*Network boot (iscsi) from FSERVE
 
*Network boot (iscsi) from FSERVE
*Gentoo 2008.0 and MythTV trunk
+
*Gentoo nd MythTV trunk
  
 
This machine sits in the basement, and is attached to the TV directly above it through a hole cut in the floor.
 
This machine sits in the basement, and is attached to the TV directly above it through a hole cut in the floor.
Line 14: Line 15:
 
*Geforce 8400GS PCIe; Audigy 2 ZS
 
*Geforce 8400GS PCIe; Audigy 2 ZS
 
*Network boot (iscsi) from FSERVE
 
*Network boot (iscsi) from FSERVE
*Gentoo 2008.0 and MythTV trunk
+
*Gentoo and MythTV trunk
  
 
===myth2===
 
===myth2===
Line 21: Line 22:
 
*Geforce 6200 AGP; SB Live 5.1
 
*Geforce 6200 AGP; SB Live 5.1
 
*Network boot (iscsi) from FSERVE
 
*Network boot (iscsi) from FSERVE
*Gentoo 2008.0 and MythTV trunk
+
*Gentoo and MythTV trunk
  
 
===fserve===
 
===fserve===
Primary backend, archival storage
+
Primary backend, archival storage, recording storage
 
*AMD Opteron 165; 2GB DDR
 
*AMD Opteron 165; 2GB DDR
 
*Geforce 6500 PCIe
 
*Geforce 6500 PCIe
Line 30: Line 31:
 
*1x250GB boot, 3x300GB for storage
 
*1x250GB boot, 3x300GB for storage
 
*1x HDHomeRun
 
*1x HDHomeRun
*FreeBSD 7.2 and MythTV Trunk
+
*FreeBSD 8.0 and MythTV Trunk
 
*Also runs Mythweb, MYSQL, Windows PDC, NFS and iSCSI targets, PXE/TFTP boot server
 
*Also runs Mythweb, MYSQL, Windows PDC, NFS and iSCSI targets, PXE/TFTP boot server
 
The case ([http://www.newegg.com/product/product.aspx?item=N82E16811182551 Codegen S-201]) has storage for 11 5.25" bays, 8 of which are configured for 12 3.5" hotswap bays.
 
The case ([http://www.newegg.com/product/product.aspx?item=N82E16811182551 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==
 +
[http://www.open-iscsi.org/ 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.
 +
 +
==Prep Disk==
 +
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.
 +
 +
==PXELinux config==
 +
<pre>
 +
LABEL my_label
 +
  menu default
 +
  menu label ^my iSCSI boot image
 +
  KERNEL /images/gentoo_2.6.31.r4_amd64_iscsi
 +
  APPEND iscsi_tip=192.168.1.1 iscsi_tgt=2 iscsi_tag=iqn.2006-05.localdomain.localserver:openiscsi
 +
</pre>
 +
 +
==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===
 +
<pre>
 +
base
 +
|----bin/
 +
|----dev/
 +
|----etc/
 +
|----lib/
 +
|----proc/
 +
|----sys/
 +
|----sysroot/
 +
|----init
 +
</pre>
 +
 +
===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.
 +
 +
<pre>
 +
mknod <name> <type> <major> <minor>
 +
mknod console c 5 1
 +
mknod sda b 8 0
 +
</pre>
 +
 +
Nodes that should be created are as follows.
 +
 +
<pre>
 +
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
 +
</pre>
 +
 +
===init script===
 +
When the initramfs is loaded, the kernel will call the init function in the base directory.  Here is a basic example.
 +
 +
<pre>
 +
#!/bin/busybox sh
 +
 +
insmod /lib/modules/scsi_transport_iscsi.ko
 +
insmod /lib/modules/libiscsi.ko
 +
insmod /lib/modules/libiscsi_tcp.ko
 +
insmod /lib/modules/iscsi_tcp.ko
 +
 +
mount -t proc none /proc
 +
mount -t sysfs none /sys
 +
 +
ifconfig eth0 up
 +
udhcpc -t2 -q -n -s/bin/udhcpc.script
 +
 +
CMDLINE=$(cat /proc/cmdline)
 +
 +
TMPVAR=${CMDLINE#*iscsi_tip=}
 +
ISCSI_TIP=${TMPVAR%% *}
 +
 +
TMPVAR=${CMDLINE#*iscsi_tgt=}
 +
ISCSI_TGT=${TMPVAR%% *}
 +
 +
TMPVAR=${CMDLINE#*iscsi_tag=}
 +
ISCSI_TAG=${TMPVAR%% *}
 +
 +
iscsistart -i "${ISCSI_TAG}" -t "iqn.1994-04.org.netbsd.iscsi-target:target${ISCSI_TGT}" -g 1 -a ${ISCSI_TIP}
 +
 +
sleep 1
 +
 +
/bin/fsck.jfs /dev/sda2
 +
mount -t jfs -o ro /dev/sda2 /sysroot
 +
 +
umount /proc
 +
umount /sys
 +
 +
exec switch_root /sysroot /sbin/init
 +
 +
echo Failed to switch root
 +
mount -t proc none /proc
 +
mount -t sysfs none /sys
 +
exec /bin/busybox sh
 +
</pre>
 +
 +
===udhcpc script===
 +
<pre>
 +
#!/bin/busybox sh
 +
 +
RESOLV_CONF="/etc/resolv.conf"
 +
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
 +
[ -n "$subnet" ] && NETMASK="netmask $subnet"
 +
 +
case "$1" in
 +
        deconfig)
 +
                ifconfig $interface 0.0.0.0
 +
                ;;
 +
        renew|bound)
 +
                ifconfig $interface $ip $BROADCAST $NETMASK
 +
 +
                if [ -n "$router" ] ; then
 +
                        echo "deleting routers"
 +
                        while route del default gw 0.0.0.0 dev $interface ; do
 +
                                :
 +
                        done
 +
 +
                        for i in $router ; do
 +
                                route add default gw $i dev $interface
 +
                        done
 +
                fi
 +
 +
                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
 +
                done
 +
                ;;
 +
 +
esac
 +
 +
exit 0
 +
</pre>
 +
 +
==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.

Revision as of 09:20, 21 December 2009

Machines

mythbe

Combined (secondary) backend/frontend

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

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

myth1

Frontend only

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

myth2

Frontend only

  • AMD Athlon 2600+; 1GB DDR
  • Geforce 6200 AGP; SB Live 5.1
  • Network boot (iscsi) from FSERVE
  • Gentoo and MythTV trunk

fserve

Primary backend, archival storage, recording storage

  • AMD Opteron 165; 2GB DDR
  • Geforce 6500 PCIe
  • Areca ARC-1230; 9x750GB RAID6 ZFS (5250GB); 2x320GB RAID1 ZFS (320GB)
  • 1x250GB boot, 3x300GB for 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.

Prep Disk

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.

PXELinux config

LABEL my_label
  menu default
  menu label ^my iSCSI boot image
  KERNEL /images/gentoo_2.6.31.r4_amd64_iscsi
  APPEND iscsi_tip=192.168.1.1 iscsi_tgt=2 iscsi_tag=iqn.2006-05.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

base
|----bin/
|----dev/
|----etc/
|----lib/
|----proc/
|----sys/
|----sysroot/
|----init

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.

#!/bin/busybox sh

insmod /lib/modules/scsi_transport_iscsi.ko
insmod /lib/modules/libiscsi.ko
insmod /lib/modules/libiscsi_tcp.ko
insmod /lib/modules/iscsi_tcp.ko

mount -t proc none /proc
mount -t sysfs none /sys

ifconfig eth0 up
udhcpc -t2 -q -n -s/bin/udhcpc.script

CMDLINE=$(cat /proc/cmdline)

TMPVAR=${CMDLINE#*iscsi_tip=}
ISCSI_TIP=${TMPVAR%% *}

TMPVAR=${CMDLINE#*iscsi_tgt=}
ISCSI_TGT=${TMPVAR%% *}

TMPVAR=${CMDLINE#*iscsi_tag=}
ISCSI_TAG=${TMPVAR%% *}

iscsistart -i "${ISCSI_TAG}" -t "iqn.1994-04.org.netbsd.iscsi-target:target${ISCSI_TGT}" -g 1 -a ${ISCSI_TIP}

sleep 1

/bin/fsck.jfs /dev/sda2
mount -t jfs -o ro /dev/sda2 /sysroot

umount /proc
umount /sys

exec switch_root /sysroot /sbin/init

echo Failed to switch root
mount -t proc none /proc
mount -t sysfs none /sys
exec /bin/busybox sh

udhcpc script

#!/bin/busybox sh

RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"

case "$1" in
        deconfig)
                ifconfig $interface 0.0.0.0
                ;;
        renew|bound)
                ifconfig $interface $ip $BROADCAST $NETMASK

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

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

                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
                done
                ;;

esac

exit 0

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.