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

[PATCH] allow ordered list for live-media option, added "usb" value



Hi

Some days ago I bought as storage media for Debian Live a new Samsung S1
Mini, see here for details:
http://www.samsung.com/global/business/hdd/productmodel.do?group=72&type=93&subtype=95&model_cd=431&tab=fea&ppmi=1087

Unfortunately, Samsung switched from the standard sector size of 512
byte to a sector size of 4096 byte in the middle of production (older S1
still had the standard sector size). This makes syslinux bail out with
the error message:
syslinux: only 512-byte sectors are supported
I contacted several hard disk vendors and they all told me that they
already switched to 4k or will switch in near future...

The only way to use these newer hard drives for Debian Live is to put
the livefs and persistency on the drive, boot from a Debian Live DVD and
let live-initramfs pick up the partitions on the hard drive.
Unfortunately, the live-initramfs option "live-media" only accepts the
options "removable-usb" and "removable".
Interestingly, /sys/block/<dev>/removable of the S1 is "0", which
results in live-initramfs not finding the livefs on the hard drive and
boot completely from DVD which sucks because it is slow, noisy and locks
the DVD drive for the whole session.

I patched live-initramfs so that the value for the live-media option can
now be an ordered comma separated list and also added support for the
value "usb" which accepts all usb devices. I also fixed some smaller
things like correct handling of the live-media-timeout option (timeout
*before* and not *while* running the scan-loop) and some small cosmetic
changes ("! -z" -> "-n").

Please accept the attached patch.

Regards

Ronny Standtke

-- 
Ronny Standtke                 Fachhochschule Nordwestschweiz
Dozent Medienpädagogik / ICT   Pädagogische Hochschule
Telefon: +41 32 627 92 47      Obere Sternengasse 7
Mobil  : +41 79 786 81 82      4502 Solothurn
diff --git a/scripts/live b/scripts/live
index 3000d78..afa85fc 100755
--- a/scripts/live
+++ b/scripts/live
@@ -1583,24 +1583,49 @@ check_dev ()
 
 find_livefs ()
 {
-	timeout="${1}"
+	# first look at the file systems in the order specified at the command line
+	for media in $(echo ${LIVE_MEDIA} | sed -e 's|,| |g')
+	do
+		case "${media}" in
+			removable-usb)
+				for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+				do
+					if [ "$(cat ${sysblock}/removable)" = "1" ]
+					then
+						if readlink ${sysblock} | grep -q usb ||
+						   readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
+						then
+							for dev in $(subdevices "${sysblock}")
+							do
+								if check_dev "${dev}"
+								then
+									return 0
+								fi
+							done
+						fi
+					fi
+				done
+				;;
 
-	# don't start autodetection before timeout has expired
-	if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
-	then
-		if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
-		then
-			return 1
-		fi
-	fi
+			removable)
+				for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+				do
+					if [ "$(cat ${sysblock}/removable)" = "1" ]
+					then
+						for dev in $(subdevices "${sysblock}")
+						do
+							if check_dev "${dev}"
+							then
+								return 0
+							fi
+						done
+					fi
+				done
+				;;
 
-	# first look at the one specified in the command line
-	case "${LIVE_MEDIA}" in
-		removable-usb)
-			for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
-			do
-				if [ "$(cat ${sysblock}/removable)" = "1" ]
-				then
+			usb)
+				for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+				do
 					if readlink ${sysblock} | grep -q usb ||
 					   readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
 					then
@@ -1612,38 +1637,20 @@ find_livefs ()
 							fi
 						done
 					fi
-				fi
-			done
-			return 1
-			;;
-
-		removable)
-			for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
-			do
-				if [ "$(cat ${sysblock}/removable)" = "1" ]
-				then
-					for dev in $(subdevices "${sysblock}")
-					do
-						if check_dev "${dev}"
-						then
-							return 0
-						fi
-					done
-				fi
-			done
-			return 1
-			;;
+				done
+				;;
 
-		*)
-			if [ ! -z "${LIVE_MEDIA}" ]
-			then
-				if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
+			*)
+				if [ -n "${media}" ]
 				then
-					return 0
+					if check_dev "null" "${media}" "skip_uuid_check"
+					then
+						return 0
+					fi
 				fi
-			fi
-			;;
-	esac
+				;;
+		esac
+	done
 
 	# or do the scan of block devices
 	# prefer removable devices over non-removable devices, so scan them first
@@ -1762,7 +1769,7 @@ mountroot ()
 
 	set_usplash_timeout
 
-	if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
+	if [ -n "${NETBOOT}" ] || [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ]
 	then
 		if do_netmount
 		then
@@ -1776,11 +1783,19 @@ mountroot ()
 			# Do a local boot from hd
 			livefs_root=${ROOT}
 		else
+			# don't start autodetection before timeout has expired
+			i=0
+			while [ "$i" -lt ${LIVE_MEDIA_TIMEOUT} ]
+			do
+				sleep 1
+				i="$(($i + 1))"
+			done
+
 			# Scan local devices for the image
 			i=0
 			while [ "$i" -lt 60 ]
 			do
-				livefs_root=$(find_livefs ${i})
+				livefs_root=$(find_livefs)
 
 				if [ -n "${livefs_root}" ]
 				then

Reply to: