summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMichal Suchanek <hramrach@centrum.cz>2010-06-04 17:47:36 +0200
committerDaniel Baumann <daniel@debian.org>2011-03-09 17:53:26 +0100
commit47f7432ee17090e441591148833a73baa4f0bdad (patch)
tree4a8d4da19f69971bfba62444dbd84e31f9bafa61 /scripts
parent5ec220d6bf96059c31488b1708ed570f8763028f (diff)
downloadlive-boot-47f7432ee17090e441591148833a73baa4f0bdad.tar.gz
live-boot-47f7432ee17090e441591148833a73baa4f0bdad.zip
Adding initial iSCSI boot support.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/live78
1 files changed, 76 insertions, 2 deletions
diff --git a/scripts/live b/scripts/live
index 7ee3e7f..2e40b45 100755
--- a/scripts/live
+++ b/scripts/live
@@ -122,6 +122,19 @@ Arguments ()
httpfs=*)
HTTPFS="${ARGUMENT#httpfs=}"
export HTTPFS
+ ;;
+
+ iscsi=*)
+ ISCSI="${ARGUMENT#iscsi=}"
+ #ip:port - separated by ;
+ ISCSI_PORTAL="${ISCSI%;*}"
+ if echo "${ISCSI_PORTAL}" | grep -q , ; then
+ ISCSI_SERVER="${ISCSI_PORTAL%,*}"
+ ISCSI_PORT="${ISCSI_PORTAL#*,}"
+ fi
+ #target name
+ ISCSI_TARGET="${ISCSI#*;}"
+ export ISCSI ISCSI_PORTAL ISCSI_TARGET ISCSI_SERVER ISCSI_PORT
;;
isofrom=*|fromiso=*)
@@ -589,7 +602,7 @@ copy_live_to ()
return 0
}
-do_netmount ()
+do_netsetup ()
{
modprobe -q af_packet # For DHCP
@@ -653,6 +666,11 @@ do_netmount ()
[ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
export HOSTNAME
+ if [ -n "${DEVICE}" ]
+ then
+ HWADDR="$(cat /sys/class/net/${DEVICE}/address)"
+ fi
+
# Check if we have a network device at all
if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
@@ -662,6 +680,11 @@ do_netmount ()
then
panic "No supported network device found, maybe a non-mainline driver is required."
fi
+}
+
+do_netmount()
+{
+ do_netsetup
if [ "${NFSROOT}" = "auto" ]
then
@@ -697,6 +720,54 @@ do_netmount ()
return ${rc}
}
+do_iscsi()
+{
+ do_netsetup
+ #modprobe ib_iser
+ modprobe iscsi_tcp
+ local debugopt=""
+ [ "${DEBUG}" == "Yes" ] && debugopt="-d 8"
+ #FIXME this name is supposed to be unique - some date + ifconfig hash?
+ ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
+ export ISCSI_INITIATORNAME
+ if [ -n "${ISCSI_SERVER}" ] ; then
+ iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_SERVER}" -p "${ISCSI_PORT}"
+ else
+ iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_PORTAL}" -p 3260
+ fi
+ if [ $? != 0 ]
+ then
+ panic "Failed to log into iscsi target"
+ fi
+ local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
+ /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
+ if [ -n "${host}" ]
+ then
+ local devices=""
+ local i=0
+ while [ -z "${devices}" -a $i -lt 60 ]
+ do
+ sleep 1
+ devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* \
+ /sys/class/scsi_device/${host}*/device/block/* | sed -e 's!.*[:/]!!')"
+ i=$(expr $i + 1)
+ echo -ne $i\\r
+ done
+ for dev in $devices
+ do
+ if check_dev "null" "/dev/$dev"
+ then
+ return 0;
+ fi
+ done
+ panic "Failed to locate a live device on iSCSI devices (tried: $devices)."
+ else
+ panic "Failed to locate iSCSI host in /sys"
+ fi
+ NETBOOT="iscsi"
+ export NETBOOT
+}
+
do_httpmount ()
{
rc=1
@@ -1653,7 +1724,10 @@ mountroot ()
panic "Unable to find a live file system on the network"
fi
else
- if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
+ if [ -n "${ISCSI_PORTAL}" ]
+ then
+ do_iscsi && livefs_root="${mountpoint}"
+ elif [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
then
# Do a local boot from hd
livefs_root=${ROOT}