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

Patch for loading iso images from the web



Hello

Currently it is necessary to store separate images for netbooting and
iso images for burning CDs on the web server.

This patch allows booting from an iso image instead of squashfs image
using any of the httpfs/ftpfs/wget method.

I did not try to make smbfs nor nfs work with this image type because
I do not use these boot methods.

This patch applies to current lenny live-initramfs.

I noticed some deficiencies in l-i:

 - the output that goes to live.log is no longer displayed on the
screen. I had to redirect the tail output to /dev/console for it to
show.
 - nfs boot is attempted if httpfs boot fails

I do not quite understand the nfs logic (and do not see what is going
on either due to the other issue above).

Thanks

Michal
--- usr/share/initramfs-tools/scripts/live.orig	2009-09-03 23:25:10.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live	2009-09-03 23:26:30.000000000 +0200
@@ -768,7 +768,7 @@
 		if [ -n "$url" ]
 		then
 			case "${extension}" in
-				squashfs|tgz|tar)
+				iso|squashfs|tgz|tar)
 					if [ "${webfile}" = "FETCH" ]
 					then
 						case "$url" in
@@ -797,6 +797,12 @@
 					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
 					;;
 
--- usr/share/initramfs-tools/scripts/live~	2009-09-07 05:36:51.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live	2009-09-07 16:08:41.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"
@@ -756,19 +757,25 @@
 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
 				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
@@ -799,9 +806,9 @@
 					[ "${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=${?}
+						isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
+						mount -t iso9660 "${isoloop}" "${mountpoint}"
+						rc=${?}
 					fi
 					break
 					;;
@@ -815,7 +822,12 @@
 
 	if [ ${rc} != 0 ]
 	then
-	    umount "${mountpoint}"
+		if [ -d "${ext_mountpoint}" ]
+		then
+		        umount "${ext_mountpoint}"
+			rmdir "${ext_mountpoint}"
+		fi
+		umount "${mountpoint}"
 	fi
 
 	return ${rc}
--- usr/share/initramfs-tools/scripts/live-bottom/05mountpoints~	2009-09-07 16:23:01.000000000 +0200
+++ usr/share/initramfs-tools/scripts/live-bottom/05mountpoints	2009-09-07 16:25:02.000000000 +0200
@@ -33,4 +33,10 @@
 	mount --move /live/image /root/live/image
 fi
 
+if [ -d /ext_volume ]
+then
+      mkdir -p /root/live/ext_volume
+      mount --move /ext_volume /root/live/ext_volume
+fi
+
 log_end_msg

Reply to: