diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2013-08-16 17:38:09 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-20 15:31:25 +0100 |
commit | d9e7fbad52844ec18cf74b3be27bdd9f98b140b2 (patch) | |
tree | 5c43d271931caf770dda9b094234223ac70cfd66 /meta/recipes-core/initrdscripts | |
parent | a42db118a74f7b4dc4789969f9761b3c7ee41c11 (diff) | |
download | poky-d9e7fbad52844ec18cf74b3be27bdd9f98b140b2.tar.gz |
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>
Diffstat (limited to 'meta/recipes-core/initrdscripts')
-rw-r--r-- | meta/recipes-core/initrdscripts/files/init-install.sh | 98 |
1 files changed, 55 insertions, 43 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh index d2a0db3183..c892075145 100644 --- a/meta/recipes-core/initrdscripts/files/init-install.sh +++ b/meta/recipes-core/initrdscripts/files/init-install.sh | |||
@@ -13,46 +13,66 @@ boot_size=20 | |||
13 | # 5% for the swap | 13 | # 5% for the swap |
14 | swap_ratio=5 | 14 | swap_ratio=5 |
15 | 15 | ||
16 | found="no" | 16 | # Get a list of hard drives |
17 | 17 | hdnamelist="" | |
18 | echo "Searching for a hard drive..." | 18 | live_dev_name=${1%%/*} |
19 | for device in 'hda' 'hdb' 'sda' 'sdb' 'mmcblk0' 'mmcblk1' | 19 | |
20 | do | 20 | echo "Searching for hard drives ..." |
21 | if [ -e /sys/block/${device}/removable ]; then | 21 | |
22 | if [ "$(cat /sys/block/${device}/removable)" = "0" ]; then | 22 | for device in `ls /sys/block/`; do |
23 | found="yes" | 23 | case $device in |
24 | 24 | loop*) | |
25 | while true; do | 25 | # skip loop device |
26 | # Try sleeping here to avoid getting kernel messages | 26 | ;; |
27 | # obscuring/confusing user | 27 | ram*) |
28 | sleep 5 | 28 | # skip ram device |
29 | echo "Found drive at /dev/${device}. Do you want to install this image there ? [y/n]" | 29 | ;; |
30 | read answer | 30 | *) |
31 | if [ "$answer" = "y" ] ; then | 31 | # skip the device LiveOS is on |
32 | break | 32 | # Add valid hard drive name to the list |
33 | fi | 33 | if [ $device != $live_dev_name -a -e /dev/$device ]; then |
34 | 34 | hdnamelist="$hdnamelist $device" | |
35 | if [ "$answer" = "n" ] ; then | 35 | fi |
36 | found=no | 36 | ;; |
37 | break | 37 | esac |
38 | fi | 38 | done |
39 | |||
40 | echo "Please answer by y or n" | ||
41 | done | ||
42 | fi | ||
43 | fi | ||
44 | |||
45 | if [ "$found" = "yes" ]; then | ||
46 | break; | ||
47 | fi | ||
48 | 39 | ||
40 | TARGET_DEVICE_NAME="" | ||
41 | for hdname in $hdnamelist; do | ||
42 | # Display found hard drives and their basic info | ||
43 | echo "-------------------------------" | ||
44 | echo /dev/$hdname | ||
45 | if [ -r /sys/block/$hdname/device/vendor ]; then | ||
46 | echo -n "VENDOR=" | ||
47 | cat /sys/block/$hdname/device/vendor | ||
48 | fi | ||
49 | echo -n "MODEL=" | ||
50 | cat /sys/block/$hdname/device/model | ||
51 | cat /sys/block/$hdname/device/uevent | ||
52 | echo | ||
53 | # Get user choice | ||
54 | while true; do | ||
55 | echo -n "Do you want to install this image there? [y/n] " | ||
56 | read answer | ||
57 | if [ "$answer" = "y" -o "$answer" = "n" ]; then | ||
58 | break | ||
59 | fi | ||
60 | echo "Please answer y or n" | ||
61 | done | ||
62 | if [ "$answer" = "y" ]; then | ||
63 | TARGET_DEVICE_NAME=$hdname | ||
64 | break | ||
65 | fi | ||
49 | done | 66 | done |
50 | 67 | ||
51 | if [ "$found" = "no" ]; then | 68 | if [ -n "$TARGET_DEVICE_NAME" ]; then |
52 | exit 1 | 69 | echo "Installing image on /dev/$TARGET_DEVICE_NAME ..." |
70 | else | ||
71 | echo "No hard drive selected. Installation aborted." | ||
72 | exit 1 | ||
53 | fi | 73 | fi |
54 | 74 | ||
55 | echo "Installing image on /dev/${device}" | 75 | device=$TARGET_DEVICE_NAME |
56 | 76 | ||
57 | # | 77 | # |
58 | # The udev automounter can cause pain here, kill it | 78 | # The udev automounter can cause pain here, kill it |
@@ -65,14 +85,6 @@ rm -f /etc/udev/scripts/mount* | |||
65 | # | 85 | # |
66 | umount /dev/${device}* 2> /dev/null || /bin/true | 86 | umount /dev/${device}* 2> /dev/null || /bin/true |
67 | 87 | ||
68 | if [ ! -b /dev/sda ] ; then | ||
69 | mknod /dev/sda b 8 0 | ||
70 | fi | ||
71 | |||
72 | if [ ! -b /dev/sdb ] ; then | ||
73 | mknod /dev/sdb b 8 16 | ||
74 | fi | ||
75 | |||
76 | if [ ! -b /dev/loop0 ] ; then | 88 | if [ ! -b /dev/loop0 ] ; then |
77 | mknod /dev/loop0 b 7 0 | 89 | mknod /dev/loop0 b 7 0 |
78 | fi | 90 | fi |