diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2013-08-16 17:38:10 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-08-20 15:31:25 +0100 |
commit | 059db226a096198801174a4d6e73d8101996ee5e (patch) | |
tree | cf5756da3da34349d0bc6e472f4cc9fb1fcbf207 /meta | |
parent | d9e7fbad52844ec18cf74b3be27bdd9f98b140b2 (diff) | |
download | poky-059db226a096198801174a4d6e73d8101996ee5e.tar.gz |
init-install.sh: fix to handle the boot partition correctly
Previously, the boot partition was created for the target hard drive
but there was no corresponding entry for it in /etc/fstab. Besides,
even if the boot partition was mounted, it would just result in odd
directory hierarchy like /boot/boot/grub. However, what we really need
is /boot/grub. This patch fixes this problem.
Besides, for future maintance work, this patch also renames some of the
intermediate directories. It uses more descriptive names like /tgt_root
and /src_root. The name of /ssd is dropped.
[YOCTO #5018]
(From OE-Core rev: aa67b1333b4774e1845f562085f7048df65a644f)
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')
-rwxr-xr-x | meta/recipes-bsp/grub/grub-2.00/40_custom | 2 | ||||
-rw-r--r-- | meta/recipes-core/initrdscripts/files/init-install.sh | 62 |
2 files changed, 30 insertions, 34 deletions
diff --git a/meta/recipes-bsp/grub/grub-2.00/40_custom b/meta/recipes-bsp/grub/grub-2.00/40_custom index ba488308b6..f891b02779 100755 --- a/meta/recipes-bsp/grub/grub-2.00/40_custom +++ b/meta/recipes-bsp/grub/grub-2.00/40_custom | |||
@@ -5,5 +5,5 @@ exec tail -n +3 $0 | |||
5 | # the 'exec tail' line above. | 5 | # the 'exec tail' line above. |
6 | menuentry "Linux" { | 6 | menuentry "Linux" { |
7 | set root=(hd0,1) | 7 | set root=(hd0,1) |
8 | linux /boot/vmlinuz root=__ROOTFS__ rw __CONSOLE__ __VIDEO_MODE__ __VGA_MODE__ quiet | 8 | linux /vmlinuz root=__ROOTFS__ rw __CONSOLE__ __VIDEO_MODE__ __VGA_MODE__ quiet |
9 | } | 9 | } |
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh index c892075145..8e433d5eda 100644 --- a/meta/recipes-core/initrdscripts/files/init-install.sh +++ b/meta/recipes-core/initrdscripts/files/init-install.sh | |||
@@ -145,29 +145,32 @@ mkfs.ext3 $rootfs | |||
145 | echo "Formatting swap partition...($swap)" | 145 | echo "Formatting swap partition...($swap)" |
146 | mkswap $swap | 146 | mkswap $swap |
147 | 147 | ||
148 | mkdir /ssd | 148 | mkdir /tgt_root |
149 | mkdir /rootmnt | 149 | mkdir /src_root |
150 | mkdir /bootmnt | 150 | mkdir -p /boot |
151 | |||
152 | mount $rootfs /ssd | ||
153 | mount -o rw,loop,noatime,nodiratime /media/$1/$2 /rootmnt | ||
154 | 151 | ||
152 | # Handling of the target root partition | ||
153 | mount $rootfs /tgt_root | ||
154 | mount -o rw,loop,noatime,nodiratime /media/$1/$2 /src_root | ||
155 | echo "Copying rootfs files..." | 155 | echo "Copying rootfs files..." |
156 | cp -a /rootmnt/* /ssd | 156 | cp -a /src_root/* /tgt_root |
157 | 157 | if [ -d /tgt_root/etc/ ] ; then | |
158 | if [ -d /ssd/etc/ ] ; then | 158 | echo "$swap swap swap defaults 0 0" >> /tgt_root/etc/fstab |
159 | echo "$swap swap swap defaults 0 0" >> /ssd/etc/fstab | 159 | echo "$bootfs /boot ext3 defaults 1 2" >> /tgt_root/etc/fstab |
160 | |||
161 | # We dont want udev to mount our root device while we're booting... | 160 | # We dont want udev to mount our root device while we're booting... |
162 | if [ -d /ssd/etc/udev/ ] ; then | 161 | if [ -d /tgt_root/etc/udev/ ] ; then |
163 | echo "/dev/${device}" >> /ssd/etc/udev/mount.blacklist | 162 | echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist |
164 | fi | 163 | fi |
165 | fi | 164 | fi |
165 | umount /tgt_root | ||
166 | umount /src_root | ||
166 | 167 | ||
168 | # Handling of the target boot partition | ||
169 | mount $bootfs /boot | ||
170 | echo "Preparing boot partition..." | ||
167 | if [ -f /etc/grub.d/40_custom ] ; then | 171 | if [ -f /etc/grub.d/40_custom ] ; then |
168 | echo "Preparing custom grub2 menu..." | 172 | echo "Preparing custom grub2 menu..." |
169 | GRUBCFG="/bootmnt/boot/grub/grub.cfg" | 173 | GRUBCFG="/boot/grub/grub.cfg" |
170 | mount $bootfs /bootmnt | ||
171 | mkdir -p $(dirname $GRUBCFG) | 174 | mkdir -p $(dirname $GRUBCFG) |
172 | cp /etc/grub.d/40_custom $GRUBCFG | 175 | cp /etc/grub.d/40_custom $GRUBCFG |
173 | sed -i "s@__ROOTFS__@$rootfs $rootwait@g" $GRUBCFG | 176 | sed -i "s@__ROOTFS__@$rootfs $rootwait@g" $GRUBCFG |
@@ -177,31 +180,24 @@ if [ -f /etc/grub.d/40_custom ] ; then | |||
177 | sed -i "/#/d" $GRUBCFG | 180 | sed -i "/#/d" $GRUBCFG |
178 | sed -i "/exec tail/d" $GRUBCFG | 181 | sed -i "/exec tail/d" $GRUBCFG |
179 | chmod 0444 $GRUBCFG | 182 | chmod 0444 $GRUBCFG |
180 | umount /bootmnt | ||
181 | fi | 183 | fi |
182 | 184 | grub-install /dev/${device} | |
183 | umount /ssd | 185 | echo "(hd0) /dev/${device}" > /boot/grub/device.map |
184 | umount /rootmnt | ||
185 | |||
186 | echo "Preparing boot partition..." | ||
187 | mount $bootfs /ssd | ||
188 | grub-install --root-directory=/ssd /dev/${device} | ||
189 | |||
190 | echo "(hd0) /dev/${device}" > /ssd/boot/grub/device.map | ||
191 | 186 | ||
192 | # If grub.cfg doesn't exist, assume GRUB 0.97 and create a menu.lst | 187 | # If grub.cfg doesn't exist, assume GRUB 0.97 and create a menu.lst |
193 | if [ ! -f /ssd/boot/grub/grub.cfg ] ; then | 188 | if [ ! -f /boot/grub/grub.cfg ] ; then |
194 | echo "Preparing custom grub menu..." | 189 | echo "Preparing custom grub menu..." |
195 | echo "default 0" > /ssd/boot/grub/menu.lst | 190 | echo "default 0" > /boot/grub/menu.lst |
196 | echo "timeout 30" >> /ssd/boot/grub/menu.lst | 191 | echo "timeout 30" >> /boot/grub/menu.lst |
197 | echo "title Live Boot/Install-Image" >> /ssd/boot/grub/menu.lst | 192 | echo "title Live Boot/Install-Image" >> /boot/grub/menu.lst |
198 | echo "root (hd0,0)" >> /ssd/boot/grub/menu.lst | 193 | echo "root (hd0,0)" >> /boot/grub/menu.lst |
199 | echo "kernel /boot/vmlinuz root=$rootfs rw $3 $4 quiet" >> /ssd/boot/grub/menu.lst | 194 | echo "kernel /vmlinuz root=$rootfs rw $3 $4 quiet" >> /boot/grub/menu.lst |
200 | fi | 195 | fi |
201 | 196 | ||
202 | cp /media/$1/vmlinuz /ssd/boot/ | 197 | cp /media/$1/vmlinuz /boot/ |
198 | |||
199 | umount /boot | ||
203 | 200 | ||
204 | umount /ssd | ||
205 | sync | 201 | sync |
206 | 202 | ||
207 | echo "Remove your installation media, and press ENTER" | 203 | echo "Remove your installation media, and press ENTER" |