diff options
author | Darren Hart <dvhart@linux.intel.com> | 2012-05-01 17:21:59 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-31 21:15:12 +0100 |
commit | a74fb01b6b15cfa69fd507eb083cca26d2685867 (patch) | |
tree | b1f819a071bc85a91ff485f0e023856542a2a997 /meta/recipes-core/initrdscripts/files/init-install.sh | |
parent | c003c045905ae068aae9b9a62662b20b1d14068a (diff) | |
download | poky-a74fb01b6b15cfa69fd507eb083cca26d2685867.tar.gz |
initrdscripts: Update install.sh to work with mmc devices
Fixes [YOCTO #2385]
The installer only searches for hd[ab] sd[ab]. Some newer BSPs have mmcblk
devices that should be used as the install target. These devices also have a
partition prefix (mmcblk0p1 instead of mmcblk01). As they are detected
asynchronously, it is necessary to add the rootwait kernel parameter to avoid
a race condition trying to mount the root device.
As BSPs like the FRI2 and the sys940x have mmc devices and will have a 1.2
release, we should push this to 1.2.1. The changes are perfectly contained and
easily verified.
Test for an mmcblk device and add the p partition prefix if necessary. Add the
rootwait kernel parameter when an mmcblk device is detected. Replace the series
of explicit umount commands with a single umount using a wildcard. This will
find all the partitions and will not try to unmount non-existant devices. Avoid
copy and paste errors by replacing /dev/${device}${pX} references with the
previously assigned rootfs, bootfs, and swap variables.
These changes have been tested on the FRI2 Sato image which installed to
/dev/mmcblk0 as well as the N450 Sato image which installed to /dev/sda. Both
were successful.
(From OE-Core rev: 36634e16c0a0c80674bacf20f9841e3b042bd5fd)
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/initrdscripts/files/init-install.sh')
-rw-r--r-- | meta/recipes-core/initrdscripts/files/init-install.sh | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh index 90978dd36a..01ff82926a 100644 --- a/meta/recipes-core/initrdscripts/files/init-install.sh +++ b/meta/recipes-core/initrdscripts/files/init-install.sh | |||
@@ -16,7 +16,7 @@ swap_ratio=5 | |||
16 | found="no" | 16 | found="no" |
17 | 17 | ||
18 | echo "Searching for a hard drive..." | 18 | echo "Searching for a hard drive..." |
19 | for device in 'hda' 'hdb' 'sda' 'sdb' | 19 | for device in 'hda' 'hdb' 'sda' 'sdb' 'mmcblk0' 'mmcblk1' |
20 | do | 20 | do |
21 | if [ -e /sys/block/${device}/removable ]; then | 21 | if [ -e /sys/block/${device}/removable ]; then |
22 | if [ "$(cat /sys/block/${device}/removable)" = "0" ]; then | 22 | if [ "$(cat /sys/block/${device}/removable)" = "0" ]; then |
@@ -62,13 +62,7 @@ rm -f /etc/udev/scripts/mount* | |||
62 | # | 62 | # |
63 | # Unmount anything the automounter had mounted | 63 | # Unmount anything the automounter had mounted |
64 | # | 64 | # |
65 | umount /dev/${device} 2> /dev/null || /bin/true | 65 | umount /dev/${device}* 2> /dev/null || /bin/true |
66 | umount /dev/${device}1 2> /dev/null || /bin/true | ||
67 | umount /dev/${device}2 2> /dev/null || /bin/true | ||
68 | umount /dev/${device}3 2> /dev/null || /bin/true | ||
69 | umount /dev/${device}4 2> /dev/null || /bin/true | ||
70 | umount /dev/${device}5 2> /dev/null || /bin/true | ||
71 | umount /dev/${device}6 2> /dev/null || /bin/true | ||
72 | 66 | ||
73 | if [ ! -b /dev/sda ] ; then | 67 | if [ ! -b /dev/sda ] ; then |
74 | mknod /dev/sda b 8 0 | 68 | mknod /dev/sda b 8 0 |
@@ -94,14 +88,23 @@ rootfs_start=$((boot_size + 1)) | |||
94 | rootfs_end=$((rootfs_start+rootfs_size)) | 88 | rootfs_end=$((rootfs_start+rootfs_size)) |
95 | swap_start=$((rootfs_end+1)) | 89 | swap_start=$((rootfs_end+1)) |
96 | 90 | ||
97 | bootfs=/dev/${device}1 | 91 | # MMC devices are special in a couple of ways |
98 | rootfs=/dev/${device}2 | 92 | # 1) they use a partition prefix character 'p' |
99 | swap=/dev/${device}3 | 93 | # 2) they are detected asynchronously (need rootwait) |
94 | rootwait="" | ||
95 | part_prefix="" | ||
96 | if [ ! "${device#mmcblk}" = "${device}" ]; then | ||
97 | part_prefix="p" | ||
98 | rootwait="rootwait" | ||
99 | fi | ||
100 | bootfs=/dev/${device}${part_prefix}1 | ||
101 | rootfs=/dev/${device}${part_prefix}2 | ||
102 | swap=/dev/${device}${part_prefix}3 | ||
100 | 103 | ||
101 | echo "*****************" | 104 | echo "*****************" |
102 | echo "Boot partition size: $boot_size MB (/dev/${device}1)" | 105 | echo "Boot partition size: $boot_size MB ($bootfs)" |
103 | echo "Rootfs partition size: $rootfs_size MB (/dev/${device}2)" | 106 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" |
104 | echo "Swap partition size: $swap_size MB (/dev/${device}3)" | 107 | echo "Swap partition size: $swap_size MB ($swap)" |
105 | echo "*****************" | 108 | echo "*****************" |
106 | echo "Deleting partition table on /dev/${device} ..." | 109 | echo "Deleting partition table on /dev/${device} ..." |
107 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | 110 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 |
@@ -109,24 +112,24 @@ dd if=/dev/zero of=/dev/${device} bs=512 count=2 | |||
109 | echo "Creating new partition table on /dev/${device} ..." | 112 | echo "Creating new partition table on /dev/${device} ..." |
110 | parted /dev/${device} mklabel msdos | 113 | parted /dev/${device} mklabel msdos |
111 | 114 | ||
112 | echo "Creating boot partition on /dev/${device}1" | 115 | echo "Creating boot partition on $bootfs" |
113 | parted /dev/${device} mkpart primary 1 $boot_size | 116 | parted /dev/${device} mkpart primary 1 $boot_size |
114 | 117 | ||
115 | echo "Creating rootfs partition on /dev/${device}2" | 118 | echo "Creating rootfs partition on $rootfs" |
116 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end | 119 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end |
117 | 120 | ||
118 | echo "Creating swap partition on /dev/${device}3" | 121 | echo "Creating swap partition on $swap" |
119 | parted /dev/${device} mkpart primary $swap_start $disk_size | 122 | parted /dev/${device} mkpart primary $swap_start $disk_size |
120 | 123 | ||
121 | parted /dev/${device} print | 124 | parted /dev/${device} print |
122 | 125 | ||
123 | echo "Formatting /dev/${device}1 to ext2..." | 126 | echo "Formatting $bootfs to ext2..." |
124 | mkfs.ext3 $bootfs | 127 | mkfs.ext3 $bootfs |
125 | 128 | ||
126 | echo "Formatting /dev/${device}2 to ext3..." | 129 | echo "Formatting $rootfs to ext3..." |
127 | mkfs.ext3 $rootfs | 130 | mkfs.ext3 $rootfs |
128 | 131 | ||
129 | echo "Formatting swap partition...(/dev/${device}3)" | 132 | echo "Formatting swap partition...($swap)" |
130 | mkswap $swap | 133 | mkswap $swap |
131 | 134 | ||
132 | mkdir /ssd | 135 | mkdir /ssd |
@@ -150,7 +153,7 @@ fi | |||
150 | 153 | ||
151 | if [ -f /ssd/etc/grub.d/40_custom ] ; then | 154 | if [ -f /ssd/etc/grub.d/40_custom ] ; then |
152 | echo "Preparing custom grub2 menu..." | 155 | echo "Preparing custom grub2 menu..." |
153 | sed -i "s@__ROOTFS__@$rootfs@g" /ssd/etc/grub.d/40_custom | 156 | sed -i "s@__ROOTFS__@$rootfs $rootwait@g" /ssd/etc/grub.d/40_custom |
154 | sed -i "s/__VIDEO_MODE__/$3/g" /ssd/etc/grub.d/40_custom | 157 | sed -i "s/__VIDEO_MODE__/$3/g" /ssd/etc/grub.d/40_custom |
155 | sed -i "s/__VGA_MODE__/$4/g" /ssd/etc/grub.d/40_custom | 158 | sed -i "s/__VGA_MODE__/$4/g" /ssd/etc/grub.d/40_custom |
156 | mount $bootfs /bootmnt | 159 | mount $bootfs /bootmnt |