summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-06-11 19:01:35 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-23 11:47:25 +0100
commit04bff65585a0dc92f8eb47d38c2c90bdbe7ce38e (patch)
tree36c7ec60c4143e0d36fc659d4a91e97775d72800
parent78bacee0ac0248b3fb82873f281b1f9d8de74b68 (diff)
downloadpoky-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>
-rw-r--r--meta/recipes-core/initrdscripts/files/init-install.sh52
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
107disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//") 107disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
108 108
109grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/')
110
111if [ $grub_version -eq 0 ] ; then
112 bios_boot_size=0
113else
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
117fi
118
109swap_size=$((disk_size*swap_ratio/100)) 119swap_size=$((disk_size*swap_ratio/100))
110rootfs_size=$((disk_size-boot_size-swap_size)) 120rootfs_size=$((disk_size-bios_boot_size-boot_size-swap_size))
111 121
112rootfs_start=$((boot_size)) 122boot_start=$((bios_boot_size))
123rootfs_start=$((bios_boot_size+boot_size))
113rootfs_end=$((rootfs_start+rootfs_size)) 124rootfs_end=$((rootfs_start+rootfs_size))
114swap_start=$((rootfs_end)) 125swap_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"
124fi 135fi
125bootfs=/dev/${device}${part_prefix}1 136
126rootfs=/dev/${device}${part_prefix}2 137if [ $grub_version -eq 0 ] ; then
127swap=/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
142else
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
147fi
128 148
129echo "*****************" 149echo "*****************"
150[ $grub_version -ne 0 ] && echo "BIOS boot partition size: $bios_boot_size MB ($bios_boot)"
130echo "Boot partition size: $boot_size MB ($bootfs)" 151echo "Boot partition size: $boot_size MB ($bootfs)"
131echo "Rootfs partition size: $rootfs_size MB ($rootfs)" 152echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
132echo "Swap partition size: $swap_size MB ($swap)" 153echo "Swap partition size: $swap_size MB ($swap)"
@@ -135,10 +156,18 @@ echo "Deleting partition table on /dev/${device} ..."
135dd if=/dev/zero of=/dev/${device} bs=512 count=2 156dd if=/dev/zero of=/dev/${device} bs=512 count=2
136 157
137echo "Creating new partition table on /dev/${device} ..." 158echo "Creating new partition table on /dev/${device} ..."
138parted /dev/${device} mklabel msdos 159if [ $grub_version -eq 0 ] ; then
139 160 parted /dev/${device} mktable msdos
140echo "Creating boot partition on $bootfs" 161 echo "Creating boot partition on $bootfs"
141parted /dev/${device} mkpart primary 0% $boot_size 162 parted /dev/${device} mkpart primary 0% $boot_size
163else
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
170fi
142 171
143echo "Creating rootfs partition on $rootfs" 172echo "Creating rootfs partition on $rootfs"
144parted /dev/${device} mkpart primary $rootfs_start $rootfs_end 173parted /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
188menuentry "Linux" { 217menuentry "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
195grub-install /dev/${device} 224grub-install /dev/${device}
196echo "(hd0) /dev/${device}" > /boot/grub/device.map 225echo "(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 227if [ $grub_version -eq 0 ] ; then
199if [ ! -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