[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Booting Debian-live-501 over HTTP



2009/9/9 Pravin <shindepravin@gmail.com>:
> Hi,
>
> 2009/9/7 Michal Suchanek <hramrach@centrum.cz>:
>>
>> All moinpoints have to be moved under /root for run-init to work so I
>> added one more move since unpacking an iso requires an additional
>> mountpoint.
>>
>
> I tested your patch.
> It works :-)
> There was only small timing issue as  after doing "modprobe fuse"
> the "/dev/fuse" was not appearing immediately.
> So, I have added small code which will wait till "/dev/fuse" actually appears.

I have never seen this issue on various systems I am booting for hdd
testing/cloning.

What system did you test on?

>
> Other than that, I have cleaned up the iscsi related patch.
> Removed all the comments from iscsi configuration files.
> The iscsi initiator name can be passed with boot parameter "iname".
> In case this parameter is not present, then defualt name
> preconfigured in initramfs is used.

You still hardcode the volume name which is more of a problem than the
initiator name which is irrelevant.
I create an initiator name from an arbitrary string and mac address
but it seems live-initramfs has md5sum so it should be possible to
generate hashes of arbitrary data to stick at the end of the template.

>
> in addition to DHCP networking,  current patch contains support for
> static IP booting.
> User can provide boot parameter "ip" and this will be used to setup
> the networking.
> Relevant code is in function "setup_static_ip"

This was supported by debian-live already.

>
> Unfortunately DNS IP is not part of standard IP boot parameter,
> http://syslinux.zytor.com/wiki/index.php/SYSLINUX#IPAPPEND_flag_val_.5BPXELINUX_only.5D
>
> so one need pass it separately.  User can use "dnsip" boot time
> parameter for providing DNS ip.
> In case there is no DNS entry in dhcp output then it is configured statically.

I noticed that you hardcode the dns server IP in your script which is
certainly wrong. There were some issues with getting dns working but I
use IPs only so I would not know.

>
> The do_httpmount part works properly without clashing with run-init.
> but do_iscsimount is clashing with run-init.
> in do_iscsimount,  I am directly mounting the iso image on ${mountpoint}
> without extra mount-point ${ext_mountpoint} needed in do_httpmount

Actually mounting an iso is the standard case but mount_httpfs has to
first mount a filesystem containing the iso and create a loop which
requires the additional mountpoint.

>
> Any suggestions on what should be done to avoid clash of do_iscsimount
> and run-init will be helpful.

Putting iSCSI outside of the netmount code path because it does not
really belong there.

It just creates a device which should be handled by the standard code path.

Unfortunately the code that searches for iso does not find it on the
iSCSI disk but probing it manually should work.

Attaching a patch that should (mostly) work. Before adding the last
hunk it just mounted the iSCSI disk and exited.

Thanks

Michal
--- usr/share/initramfs-tools/hooks/live.0	2009-09-09 17:33:41.000000000 +0200
+++ usr/share/initramfs-tools/hooks/live	2009-09-09 17:36:47.000000000 +0200
@@ -176,3 +176,13 @@
 then
 	copy_exec /usr/bin/curlftpfs /bin
 fi
+
+# iSCSI
+if [ -x /usr/bin/iscsiadm ] && [ -x /usr/sbin/iscsid ]
+then
+    copy_exec /usr/bin/iscsiadm /bin
+    copy_exec /usr/sbin/iscsid /bin
+    #manual_add_modules ib_iser
+    manual_add_modules iscsi_tcp
+    manual_add_modules crc32c
+fi
--- usr/share/initramfs-tools/scripts/live.0	2009-09-09 17:33:25.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live	2009-09-09 17:37:58.000000000 +0200
@@ -87,6 +87,15 @@
 				export HTTPFS
 				;;
 
+			iscsi=*)
+				ISCSI="${ARGUMENT#iscsi=}"
+				#ip:port - separated by , from target
+				ISCSI_PORTAL="${ISCSI%,*}"
+				#target name
+				ISCSI_TARGET="${ISCSI#*,}"
+				export ISCSI ISCSI_PORTAL ISCSI_TARGET
+				;;
+
 			hostname=*)
 				HOSTNAME="${ARGUMENT#hostname=}"
 				LIVECONF="changed"
@@ -688,7 +697,7 @@
 	return 0
 }
 
-do_netmount ()
+do_netsetup ()
 {
 	rc=1
 
@@ -713,6 +722,11 @@
 	[ -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/eth0 > /dev/null 2>&1 && \
 	   ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
@@ -721,6 +735,11 @@
 	then
 		panic "No supported network device found, maybe a non-mainline driver is required."
 	fi
+}
+
+do_netmount()
+{
+	do_netsetup
 
 	if [ "${NFSROOT}" = "auto" ]
 	then
@@ -754,6 +773,24 @@
 	return ${rc}
 }
 
+do_iscsi()
+{
+	do_netsetup
+	#modprobe ib_iser
+	modprobe iscsi_tcp
+	mkdir -p /etc/iscsi
+	#FIXME this name is supposed to be unique - some date + ifconfig hash?
+	echo "InitiatorName=iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)" > /etc/iscsi/initiatorname.iscsi
+	iscsid -f &
+	iscsiadm --mode discovery --type sendtargets --portal "${ISCSI_PORTAL}" -I default
+	iscsiadm --mode node --targetname "${ISCSI_TARGET}" --portal "${ISCSI_PORTAL}" --login
+	if [ $? != 0 ]
+	then
+		panic "Failed to log into iscsi target"
+	fi
+	#FIXME set the iscsi device name into ROOT
+}
+
 do_httpmount ()
 {
 	rc=1
@@ -1580,6 +1617,10 @@
 			panic "Unable to find a live file system on the network"
 		fi
 	else
+		if [ -n "${ISCSI_PORTAL}" ]
+		then
+			do_iscsi
+		fi
 		if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
 		then
 			# Do a local boot from hd
--- usr/share/initramfs-tools/scripts/live~	2009-09-09 18:04:25.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live	2009-09-09 18:09:24.000000000 +0200
@@ -779,11 +779,13 @@
 	#modprobe ib_iser
 	modprobe iscsi_tcp
 	mkdir -p /etc/iscsi
+	local debugopt=""
+	[ "${DEBUG}" == "Yes" ] && debugopt="-d 8"
 	#FIXME this name is supposed to be unique - some date + ifconfig hash?
 	echo "InitiatorName=iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)" > /etc/iscsi/initiatorname.iscsi
-	iscsid -f &
-	iscsiadm --mode discovery --type sendtargets --portal "${ISCSI_PORTAL}" -I default
-	iscsiadm --mode node --targetname "${ISCSI_TARGET}" --portal "${ISCSI_PORTAL}" --login
+	iscsid $debugopt -f &
+	iscsiadm $debugopt --mode discovery --type sendtargets --portal "${ISCSI_PORTAL}" -I default
+	iscsiadm $debugopt --mode node --targetname "${ISCSI_TARGET}" --portal "${ISCSI_PORTAL}" --login
 	if [ $? != 0 ]
 	then
 		panic "Failed to log into iscsi target"
--- usr/share/initramfs-tools/scripts/live~	2009-09-09 19:05:55.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live	2009-09-09 20:08:49.000000000 +0200
@@ -790,7 +790,21 @@
 	then
 		panic "Failed to log into iscsi target"
 	fi
-	#FIXME set the iscsi device name into ROOT
+	local host="$(ls -d /sys/class/scsi_host/host?/device/iscsi_host:host? | sed -e 's:/device.*::' -e 's:.*host::')"
+	if [ -n "${host}" ]
+	then
+		local devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* | sed -e 's/.*://')"
+		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
 }
 
 do_httpmount ()
@@ -1623,6 +1637,7 @@
 		if [ -n "${ISCSI_PORTAL}" ]
 		then
 			do_iscsi
+			livefs_root="${mountpoint}"
 		fi
 		if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
 		then
--- usr/share/initramfs-tools/scripts/live~	2009-09-09 20:08:49.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live	2009-09-09 20:17:45.000000000 +0200
@@ -793,7 +793,14 @@
 	local host="$(ls -d /sys/class/scsi_host/host?/device/iscsi_host:host? | sed -e 's:/device.*::' -e 's:.*host::')"
 	if [ -n "${host}" ]
 	then
-		local devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* | sed -e 's/.*://')"
+		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:* | sed -e 's/.*://')"
+			i=$(expr $i + 1)
+		done
 		for dev in $devices
 		do
 			if check_dev "null" "/dev/$dev"
--- usr/share/initramfs-tools/scripts/live~	2009-09-09 21:11:21.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live	2009-09-09 23:03:16.000000000 +0200
@@ -1642,10 +1642,8 @@
 	else
 		if [ -n "${ISCSI_PORTAL}" ]
 		then
-			do_iscsi
-			livefs_root="${mountpoint}"
-		fi
-		if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
+		    livefs_root="$(do_iscsi)"
+		elif [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
 		then
 			# Do a local boot from hd
 			livefs_root=${ROOT}

Reply to: