Re: Booting Debian-live-501 over HTTP
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.
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.
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"
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.
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
Any suggestions on what should be done to avoid clash of do_iscsimount
and run-init will be helpful.
Looking forward for feedback/comments.
--
Pravin
Binary files initrd_orig/bin/fusermount and initrd_new/bin/fusermount differ
Binary files initrd_orig/bin/httpfs and initrd_new/bin/httpfs differ
Binary files initrd_orig/bin/run-init and initrd_new/bin/run-init differ
diff -uNr initrd_orig/etc/iscsi/initiatorname.iscsi initrd_new/etc/iscsi/initiatorname.iscsi
--- initrd_orig/etc/iscsi/initiatorname.iscsi 1970-01-01 01:00:00.000000000 +0100
+++ initrd_new/etc/iscsi/initiatorname.iscsi 2009-09-09 21:26:04.000000000 +0200
@@ -0,0 +1,2 @@
+# It will be used when no name is provided at boot parameter
+InitiatorName=iqn.1993-08.org.debian:01:74e6bd2d995f
diff -uNr initrd_orig/etc/iscsi/iscsid.conf initrd_new/etc/iscsi/iscsid.conf
--- initrd_orig/etc/iscsi/iscsid.conf 1970-01-01 01:00:00.000000000 +0100
+++ initrd_new/etc/iscsi/iscsid.conf 2009-09-09 21:26:04.000000000 +0200
@@ -0,0 +1,18 @@
+node.startup = automatic
+node.session.timeo.replacement_timeout = 120
+node.conn[0].timeo.login_timeout = 15
+node.conn[0].timeo.logout_timeout = 15
+node.conn[0].timeo.noop_out_interval = 5
+node.conn[0].timeo.noop_out_timeout = 5
+node.session.err_timeo.abort_timeout = 15
+node.session.err_timeo.lu_reset_timeout = 20
+node.session.initial_login_retry_max = 8
+node.session.cmds_max = 128
+node.session.queue_depth = 32
+node.session.iscsi.InitialR2T = No
+node.session.iscsi.ImmediateData = Yes
+node.session.iscsi.FirstBurstLength = 262144
+node.session.iscsi.MaxBurstLength = 16776192
+node.conn[0].iscsi.MaxRecvDataSegmentLength = 131072
+discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
+node.session.iscsi.FastAbort = Yes
Binary files initrd_orig/modules/crc32c.ko and initrd_new/modules/crc32c.ko differ
Binary files initrd_orig/modules/libcrc32c.ko and initrd_new/modules/libcrc32c.ko differ
Binary files initrd_orig/modules/loop.ko and initrd_new/modules/loop.ko differ
Binary files initrd_orig/sbin/iscsiadm and initrd_new/sbin/iscsiadm differ
Binary files initrd_orig/sbin/iscsid and initrd_new/sbin/iscsid differ
diff -uNr initrd_orig/scripts/live initrd_new/scripts/live
--- initrd_orig/scripts/live 2009-09-09 18:41:10.000000000 +0200
+++ initrd_new/scripts/live 2009-09-09 21:26:04.000000000 +0200
@@ -8,6 +8,7 @@
echo "/root/usr/lib" >> /etc/ld.so.conf
mountpoint="/live/image"
+ext_mountpoint="/ext_volume"
LIVE_MEDIA_PATH="live"
root_persistence="live-rw"
@@ -19,6 +20,9 @@
USERFULLNAME="Live user"
HOSTNAME="host"
+export RESCUEBREAK="No"
+
+
mkdir -p "${mountpoint}"
# Create /etc/mtab for debug purpose and future syncs
@@ -86,6 +90,35 @@
export HTTPFS
;;
+ iscsifs=*)
+ ISCSIFS="${ARGUMENT#iscsifs=}"
+ export ISCSIFS
+ ;;
+
+ iname=*)
+ ISCSINAME="${ARGUMENT#iname=}"
+ export ISCSINAME
+ ;;
+
+ target=*)
+ TARGET="${ARGUMENT#target=}"
+ export TARGET
+ ;;
+
+ dnsip=*)
+ DNSIP="${ARGUMENT#dnsip=}"
+ export DNSIP
+ ;;
+
+ ip=*)
+ BOOTIP="${ARGUMENT#ip=}"
+ export BOOTIP
+ ;;
+
+ rescuebreak)
+ export RESCUEBREAK="Yes"
+ ;;
+
hostname=*)
HOSTNAME="${ARGUMENT#hostname=}"
LIVECONF="changed"
@@ -687,10 +720,45 @@
return 0
}
+add_ip_to_resolv_conf ()
+{
+ if [ ! -z ${1} ]
+ then
+ echo "nameserver $1" >> /etc/resolv.conf
+ fi
+}
+
+setup_static_ip ()
+{
+ ifconfig lo 127.0.0.1 up
+ ifconfig "${DEVICE}" up
+ local myip=`echo ${BOOTIP} | cut -d: -f1`
+ local mynm=`echo ${BOOTIP} | cut -d: -f4`
+ local mygw=`echo ${BOOTIP} | cut -d: -f3`
+ echo "myip=${myip} mynm=${mynm} mygw=${mygw}"
+ ifconfig "${DEVICE}" "${myip}" netmask "${mynm}"
+ ifconfig "${DEVICE}"
+ route add default gw "${mygw}"
+ return 0
+}
+
+setup_static_dns ()
+{
+ if [ -z ${DNSIP} ]
+ then
+ add_ip_to_resolv_conf "4.2.2.2"
+ add_ip_to_resolv_conf "128.255.1.3"
+ else
+ add_ip_to_resolv_conf ${DNSIP}
+ fi
+ return 0
+}
+
do_netmount ()
{
rc=1
+
modprobe -q af_packet # For DHCP
if [ -x /sbin/udevadm ]
@@ -704,13 +772,27 @@
udevsettle
fi
- ipconfig ${DEVICE} | tee /netboot.config
+ if [ -z ${BOOTIP} ]
+ then
+ ipconfig ${DEVICE} | tee /netboot.config
+ # Adding DNS Entry
+ local ipconf_dnsip=`cat /netboot.config | grep dns0 | cut -d':' -f3 | cut -d' ' -f2`
+ if [ -z ${ipconf_dnsip}] || [ ${ipconf_dnsip} == '0.0.0.0']
+ then
+ setup_static_dns
+ else
+ add_ip_to_resolv_conf ${ipconf_dnsip}
+ fi
+ # source relevant ipconfig output
+ OLDHOSTNAME=${HOSTNAME}
+ . /tmp/net-${DEVICE}.conf
+ [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
+ export HOSTNAME
- # source relevant ipconfig output
- OLDHOSTNAME=${HOSTNAME}
- . /tmp/net-${DEVICE}.conf
- [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
- export HOSTNAME
+ else
+ setup_static_ip
+ setup_static_dns
+ fi
# Check if we have a network device at all
if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
@@ -721,10 +803,18 @@
panic "No supported network device found, maybe a non-mainline driver is required."
fi
+
if [ "${NFSROOT}" = "auto" ]
then
NFSROOT=${ROOTSERVER}:${ROOTPATH}
fi
+
+
+ if ( [ -n "${ISCSIFS}" ] ) && do_iscsimount
+ then
+ rc=0
+ return ${rc}
+ fi
if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
then
@@ -756,19 +846,27 @@
do_httpmount ()
{
rc=1
- dest="${mountpoint}/${LIVE_MEDIA_PATH}"
- mount -t ramfs ram "${mountpoint}"
- mkdir -p "${dest}"
for webfile in HTTPFS FTPFS FETCH
do
- url="$(eval echo \"\$\{${webfile}\}\")"
- extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
+ local url="$(eval echo \"\$\{${webfile}\}\")"
+ local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
if [ -n "$url" ]
then
case "${extension}" in
- squashfs|tgz|tar)
+ iso|squashfs|tgz|tar)
+ if [ "${extension}" = "iso" ]
+ then
+ mkdir -p "${ext_mountpoint}"
+ dest="${ext_mountpoint}"
+ else
+ local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
+ mount -t ramfs ram "${mountpoint}"
+ mkdir -p "${dest}"
+ fi
+
+
if [ "${webfile}" = "FETCH" ]
then
case "$url" in
@@ -793,10 +891,19 @@
FUSE_MOUNT="httpfs"
fi
modprobe fuse
+ # sometimes /dev/fuse takes time to appear, following line will avoid that problem
+ wait_for_device /dev/fuse 160
$FUSE_MOUNT "${url}" "${dest}"
fi
[ ${?} -eq 0 ] && rc=0
[ "${extension}" = "tgz" ] && live_dest="ram"
+ if [ "${extension}" = "iso" ]
+ then
+ isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
+ mount -t iso9660 "${isoloop}" "${mountpoint}"
+ rc=${?}
+ fi
+
break
;;
@@ -811,10 +918,61 @@
then
umount "${mountpoint}"
fi
+ return 0
+# return ${rc}
+}
- return ${rc}
+do_iscsimount ()
+{
+ rc=1
+ if [ ! -z ${ISCSINAME} ]
+ then
+ echo ${ISCSINAME} > /etc/iscsi/initiatorname.iscsi
+ fi
+
+ dest="${mountpoint}/${LIVE_MEDIA_PATH}"
+ mount -t ramfs ram "${mountpoint}"
+ mkdir -p "${dest}"
+ insmod /modules/libcrc32c.ko
+ insmod /modules/crc32c.ko
+ modprobe iscsi_tcp
+ modprobe ib_iser
+ mkdir /var/run
+ /sbin/iscsid
+ sleep 4
+ iscsiadm -m discovery -t st -p "${ISCSIFS}"
+ sleep 4
+ targetname=`iscsiadm -m node | grep "${TARGET}" | cut -d' ' -f2`
+ iscsiadm -m node --targetname "${targetname}" --portal "${ISCSIFS}" --login
+ export iscsidevice=/dev/disk/by-label/Debian\\x20lenny\\x2020090614-09\:11
+ wait_for_device ${iscsidevice} 160
+ mount -t iso9660 "${iscsidevice}" "${mountpoint}"
+ rc=${?}
+ sync
+ sleep 2
+# rc=0
+ return $rc
+}
+
+# waits for $2 seconds to devie/file to appear on given path ($1)
+wait_for_device ()
+{
+ local device_path=${1}
+ local max_seconds=${2}
+ local i=0
+ while [ "$i" -lt ${max_seconds} ]
+ do
+ ls -l "${device_path}" && return 0
+ i="$(($i + 1))"
+ echo "waiting for ${device_path} to appear $i"
+ sleep 1
+ sync
+ done
+ echo "Device did not appeared..."
+ return 1
}
+
do_nfsmount ()
{
rc=1
@@ -1523,6 +1681,21 @@
fi
}
+rescue_break_shell ()
+{
+ if [ "${RESCUEBREAK}" = "Yes" ];
+ then
+ echo "#################################################################"
+ echo "#### giving rescue shell, you can execute any commands here #####"
+ echo "#### When done, type exit, boot process will resume :-) #####"
+ echo "#################################################################"
+ /bin/sh
+ echo "#################################################################"
+ echo "#### Resuming Boot Process #####"
+ echo "#################################################################"
+ fi
+}
+
mountroot ()
{
if [ -x /scripts/local-top/cryptroot ]; then
@@ -1583,7 +1756,7 @@
done
fi
fi
-
+ rescue_break_shell
if [ -z "${livefs_root}" ]
then
panic "Unable to find a medium containing a live file system"
Reply to: