1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

init-install.sh: improve hard drive searching process

Previously, only unremovable hard drives are searched and are treated
as candidates of target disks to intall into.

However, it's possible that we're going to install the live image into
a removable media such as an USB. This patch enables this possibility.

In addition, this patch presents more information about the hard drives
so that user may have more knowledge about which hard drive they are
going to install their image into.

[YOCTO #5018]

(From OE-Core rev: 358f0584d779825307eec08c023b5ff14e72cf9e)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Chen Qi
2013-08-16 17:38:09 +08:00
committed by Richard Purdie
parent a42db118a7
commit d9e7fbad52
@@ -13,46 +13,66 @@ boot_size=20
# 5% for the swap # 5% for the swap
swap_ratio=5 swap_ratio=5
found="no" # Get a list of hard drives
hdnamelist=""
live_dev_name=${1%%/*}
echo "Searching for a hard drive..." echo "Searching for hard drives ..."
for device in 'hda' 'hdb' 'sda' 'sdb' 'mmcblk0' 'mmcblk1'
do
if [ -e /sys/block/${device}/removable ]; then
if [ "$(cat /sys/block/${device}/removable)" = "0" ]; then
found="yes"
while true; do for device in `ls /sys/block/`; do
# Try sleeping here to avoid getting kernel messages case $device in
# obscuring/confusing user loop*)
sleep 5 # skip loop device
echo "Found drive at /dev/${device}. Do you want to install this image there ? [y/n]" ;;
read answer ram*)
if [ "$answer" = "y" ] ; then # skip ram device
break ;;
*)
# skip the device LiveOS is on
# Add valid hard drive name to the list
if [ $device != $live_dev_name -a -e /dev/$device ]; then
hdnamelist="$hdnamelist $device"
fi fi
;;
if [ "$answer" = "n" ] ; then esac
found=no
break
fi
echo "Please answer by y or n"
done
fi
fi
if [ "$found" = "yes" ]; then
break;
fi
done done
if [ "$found" = "no" ]; then TARGET_DEVICE_NAME=""
for hdname in $hdnamelist; do
# Display found hard drives and their basic info
echo "-------------------------------"
echo /dev/$hdname
if [ -r /sys/block/$hdname/device/vendor ]; then
echo -n "VENDOR="
cat /sys/block/$hdname/device/vendor
fi
echo -n "MODEL="
cat /sys/block/$hdname/device/model
cat /sys/block/$hdname/device/uevent
echo
# Get user choice
while true; do
echo -n "Do you want to install this image there? [y/n] "
read answer
if [ "$answer" = "y" -o "$answer" = "n" ]; then
break
fi
echo "Please answer y or n"
done
if [ "$answer" = "y" ]; then
TARGET_DEVICE_NAME=$hdname
break
fi
done
if [ -n "$TARGET_DEVICE_NAME" ]; then
echo "Installing image on /dev/$TARGET_DEVICE_NAME ..."
else
echo "No hard drive selected. Installation aborted."
exit 1 exit 1
fi fi
echo "Installing image on /dev/${device}" device=$TARGET_DEVICE_NAME
# #
# The udev automounter can cause pain here, kill it # The udev automounter can cause pain here, kill it
@@ -65,14 +85,6 @@ rm -f /etc/udev/scripts/mount*
# #
umount /dev/${device}* 2> /dev/null || /bin/true umount /dev/${device}* 2> /dev/null || /bin/true
if [ ! -b /dev/sda ] ; then
mknod /dev/sda b 8 0
fi
if [ ! -b /dev/sdb ] ; then
mknod /dev/sdb b 8 16
fi
if [ ! -b /dev/loop0 ] ; then if [ ! -b /dev/loop0 ] ; then
mknod /dev/loop0 b 7 0 mknod /dev/loop0 b 7 0
fi fi