diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2015-06-11 19:01:35 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-23 11:47:25 +0100 |
commit | 04bff65585a0dc92f8eb47d38c2c90bdbe7ce38e (patch) | |
tree | 36c7ec60c4143e0d36fc659d4a91e97775d72800 /meta/recipes-core | |
parent | 78bacee0ac0248b3fb82873f281b1f9d8de74b68 (diff) | |
download | poky-04bff65585a0dc92f8eb47d38c2c90bdbe7ce38e.tar.gz |
init-install: Use GPT table with GRUB 2
Changed partition type from 'msdos' to 'gpt'.
Added special partition for grub stage2 bootloader.
NOTE: This is done only for GRUB 2 as legacy GRUB is
rarely used and doesn't support GPT partitions.
(From OE-Core rev: 9544ac920d65edb7ddb267482c84d6fc1b464912)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r-- | meta/recipes-core/initrdscripts/files/init-install.sh | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh index cb261630d0..298ea8d529 100644 --- a/meta/recipes-core/initrdscripts/files/init-install.sh +++ b/meta/recipes-core/initrdscripts/files/init-install.sh | |||
@@ -106,10 +106,21 @@ fi | |||
106 | 106 | ||
107 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") | 107 | disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") |
108 | 108 | ||
109 | grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/') | ||
110 | |||
111 | if [ $grub_version -eq 0 ] ; then | ||
112 | bios_boot_size=0 | ||
113 | else | ||
114 | # For GRUB 2 we need separate parition to store stage2 grub image | ||
115 | # 2Mb value is chosen to align partition for best performance. | ||
116 | bios_boot_size=2 | ||
117 | fi | ||
118 | |||
109 | swap_size=$((disk_size*swap_ratio/100)) | 119 | swap_size=$((disk_size*swap_ratio/100)) |
110 | rootfs_size=$((disk_size-boot_size-swap_size)) | 120 | rootfs_size=$((disk_size-bios_boot_size-boot_size-swap_size)) |
111 | 121 | ||
112 | rootfs_start=$((boot_size)) | 122 | boot_start=$((bios_boot_size)) |
123 | rootfs_start=$((bios_boot_size+boot_size)) | ||
113 | rootfs_end=$((rootfs_start+rootfs_size)) | 124 | rootfs_end=$((rootfs_start+rootfs_size)) |
114 | swap_start=$((rootfs_end)) | 125 | swap_start=$((rootfs_end)) |
115 | 126 | ||
@@ -122,11 +133,21 @@ if [ ! "${device#mmcblk}" = "${device}" ]; then | |||
122 | part_prefix="p" | 133 | part_prefix="p" |
123 | rootwait="rootwait" | 134 | rootwait="rootwait" |
124 | fi | 135 | fi |
125 | bootfs=/dev/${device}${part_prefix}1 | 136 | |
126 | rootfs=/dev/${device}${part_prefix}2 | 137 | if [ $grub_version -eq 0 ] ; then |
127 | swap=/dev/${device}${part_prefix}3 | 138 | bios_boot='' |
139 | bootfs=/dev/${device}${part_prefix}1 | ||
140 | rootfs=/dev/${device}${part_prefix}2 | ||
141 | swap=/dev/${device}${part_prefix}3 | ||
142 | else | ||
143 | bios_boot=/dev/${device}${part_prefix}1 | ||
144 | bootfs=/dev/${device}${part_prefix}2 | ||
145 | rootfs=/dev/${device}${part_prefix}3 | ||
146 | swap=/dev/${device}${part_prefix}4 | ||
147 | fi | ||
128 | 148 | ||
129 | echo "*****************" | 149 | echo "*****************" |
150 | [ $grub_version -ne 0 ] && echo "BIOS boot partition size: $bios_boot_size MB ($bios_boot)" | ||
130 | echo "Boot partition size: $boot_size MB ($bootfs)" | 151 | echo "Boot partition size: $boot_size MB ($bootfs)" |
131 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" | 152 | echo "Rootfs partition size: $rootfs_size MB ($rootfs)" |
132 | echo "Swap partition size: $swap_size MB ($swap)" | 153 | echo "Swap partition size: $swap_size MB ($swap)" |
@@ -135,10 +156,18 @@ echo "Deleting partition table on /dev/${device} ..." | |||
135 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 | 156 | dd if=/dev/zero of=/dev/${device} bs=512 count=2 |
136 | 157 | ||
137 | echo "Creating new partition table on /dev/${device} ..." | 158 | echo "Creating new partition table on /dev/${device} ..." |
138 | parted /dev/${device} mklabel msdos | 159 | if [ $grub_version -eq 0 ] ; then |
139 | 160 | parted /dev/${device} mktable msdos | |
140 | echo "Creating boot partition on $bootfs" | 161 | echo "Creating boot partition on $bootfs" |
141 | parted /dev/${device} mkpart primary 0% $boot_size | 162 | parted /dev/${device} mkpart primary 0% $boot_size |
163 | else | ||
164 | parted /dev/${device} mktable gpt | ||
165 | echo "Creating BIOS boot partition on $bios_boot" | ||
166 | parted /dev/${device} mkpart primary 0% $bios_boot_size | ||
167 | parted /dev/${device} set 1 bios_grub on | ||
168 | echo "Creating boot partition on $bootfs" | ||
169 | parted /dev/${device} mkpart primary $boot_start $boot_size | ||
170 | fi | ||
142 | 171 | ||
143 | echo "Creating rootfs partition on $rootfs" | 172 | echo "Creating rootfs partition on $rootfs" |
144 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end | 173 | parted /dev/${device} mkpart primary $rootfs_start $rootfs_end |
@@ -186,7 +215,7 @@ if [ -f /etc/grub.d/00_header ] ; then | |||
186 | mkdir -p $(dirname $GRUBCFG) | 215 | mkdir -p $(dirname $GRUBCFG) |
187 | cat >$GRUBCFG <<_EOF | 216 | cat >$GRUBCFG <<_EOF |
188 | menuentry "Linux" { | 217 | menuentry "Linux" { |
189 | set root=(hd0,1) | 218 | set root=(hd0,2) |
190 | linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet | 219 | linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet |
191 | } | 220 | } |
192 | _EOF | 221 | _EOF |
@@ -195,8 +224,7 @@ fi | |||
195 | grub-install /dev/${device} | 224 | grub-install /dev/${device} |
196 | echo "(hd0) /dev/${device}" > /boot/grub/device.map | 225 | echo "(hd0) /dev/${device}" > /boot/grub/device.map |
197 | 226 | ||
198 | # If grub.cfg doesn't exist, assume GRUB 0.97 and create a menu.lst | 227 | if [ $grub_version -eq 0 ] ; then |
199 | if [ ! -f /boot/grub/grub.cfg ] ; then | ||
200 | echo "Preparing custom grub menu..." | 228 | echo "Preparing custom grub menu..." |
201 | echo "default 0" > /boot/grub/menu.lst | 229 | echo "default 0" > /boot/grub/menu.lst |
202 | echo "timeout 30" >> /boot/grub/menu.lst | 230 | echo "timeout 30" >> /boot/grub/menu.lst |