slitaz-boot-scripts rev 290

bootopts.sh: look for usb key device
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Mar 23 10:48:07 2012 +0100 (2012-03-23)
parents 244e4aba431e
children 4e3f09beb648
files etc/init.d/bootopts.sh
line diff
     1.1 --- a/etc/init.d/bootopts.sh	Fri Mar 23 10:39:05 2012 +0100
     1.2 +++ b/etc/init.d/bootopts.sh	Fri Mar 23 10:48:07 2012 +0100
     1.3 @@ -13,6 +13,16 @@
     1.4  EOT
     1.5  }
     1.6  
     1.7 +# Get first usb disk
     1.8 +usb_device()
     1.9 +{
    1.10 +	cd /sys/block
    1.11 +	for i in sd* sda ; do
    1.12 +		grep -q 1 $i/removable && break
    1.13 +	done
    1.14 +	echo $i
    1.15 +}
    1.16 +
    1.17  # Default user account without password (uid=1000). In live mode the option
    1.18  # user=name can be used, but user must be added before home= to have home dir.
    1.19  # This option is not handled by a loop and case like others and has no
    1.20 @@ -72,7 +82,7 @@
    1.21  			# user home dir. Note: home=usb is a shorter and easier way to
    1.22  			# have home=/dev/sda1.
    1.23  			DEVICE=${opt#home=}
    1.24 -			[ "$DEVICE" = "usb" ] && DEVICE=sda1
    1.25 +			[ "$DEVICE" = "usb" ] && DEVICE="$(usb_device)1"
    1.26  			echo "Home has been specified to $DEVICE..."
    1.27  			DEVID=`/sbin/blkid | sed 'p;s/"//g' | fgrep "$DEVICE" | sed 's/:.*//;q'`
    1.28  			if [ -z "$DEVID" ]; then