User:Wagnerrp
From MythTV
Contents |
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.
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 192.168.1.1 192.168.1.1:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target0 192.168.1.1:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target1 192.168.1.1:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target2 192.168.1.1:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target3 192.168.1.1:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target4 192.168.1.1:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target5 192.168.1.1:3260,1 iqn.1994-04.org.netbsd.iscsi-target:target6
Connect to your disk.
# iscsiadm --mode node --targetname iqn.1994-04.org.netbsd.iscsi-target:target2 --login Logging in to [iface: default, target: iqn.1994-04.org.netbsd.iscsi-target:target2, portal: 192.168.1.1,3260] Login to [iface: default, target: iqn.1994-04.org.netbsd.iscsi-target:target2, portal: 192.168.1.1,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=192.168.1.1 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
base |----bin/ |----dev/ |----etc/ |----lib/ | |----modules/ |----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
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.
