summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/grub-efi.bbclass2
-rw-r--r--meta/recipes-core/images/core-image-minimal-initramfs.bb2
-rw-r--r--meta/recipes-core/initrdscripts/files/init-install-efi.sh175
-rw-r--r--meta/recipes-core/initrdscripts/files/init-live.sh6
-rw-r--r--meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb22
5 files changed, 203 insertions, 4 deletions
diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
index 1efb43b805..147accc895 100644
--- a/meta/classes/grub-efi.bbclass
+++ b/meta/classes/grub-efi.bbclass
@@ -99,6 +99,8 @@ python build_grub_cfg() {
99 bb.data.update_data(localdata) 99 bb.data.update_data(localdata)
100 100
101 cfgfile.write('\nmenuentry \'%s\'{\n' % (label)) 101 cfgfile.write('\nmenuentry \'%s\'{\n' % (label))
102 if label == "install":
103 label = "install-efi"
102 cfgfile.write('linux /vmlinuz LABEL=%s' % (label)) 104 cfgfile.write('linux /vmlinuz LABEL=%s' % (label))
103 105
104 append = localdata.getVar('APPEND', True) 106 append = localdata.getVar('APPEND', True)
diff --git a/meta/recipes-core/images/core-image-minimal-initramfs.bb b/meta/recipes-core/images/core-image-minimal-initramfs.bb
index 4aeb6188f7..7f6826ceb1 100644
--- a/meta/recipes-core/images/core-image-minimal-initramfs.bb
+++ b/meta/recipes-core/images/core-image-minimal-initramfs.bb
@@ -3,7 +3,7 @@ DESCRIPTION = "Small image capable of booting a device. The kernel includes \
3the Minimal RAM-based Initial Root Filesystem (initramfs), which finds the \ 3the Minimal RAM-based Initial Root Filesystem (initramfs), which finds the \
4first “init” program more efficiently." 4first “init” program more efficiently."
5 5
6IMAGE_INSTALL = "initramfs-live-boot initramfs-live-install busybox udev base-passwd" 6IMAGE_INSTALL = "initramfs-live-boot initramfs-live-install initramfs-live-install-efi busybox udev base-passwd"
7 7
8# Do not pollute the initrd image with rootfs features 8# Do not pollute the initrd image with rootfs features
9IMAGE_FEATURES = "" 9IMAGE_FEATURES = ""
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
new file mode 100644
index 0000000000..23228c92c4
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -0,0 +1,175 @@
1#!/bin/sh -e
2#
3# Copyright (c) 2012, Intel Corporation.
4# All rights reserved.
5#
6# install.sh [device_name] [rootfs_name]
7#
8
9PATH=/sbin:/bin:/usr/sbin:/usr/bin
10
11# We need 20 Mb for the boot partition
12boot_size=20
13
14# 5% for swap
15swap_ratio=5
16
17found="no"
18
19echo "Searching for a hard drive..."
20for device in 'hda' 'hdb' 'sda' 'sdb' 'mmcblk0' 'mmcblk1'
21do
22 if [ -e /sys/block/${device}/removable ]; then
23 if [ "$(cat /sys/block/${device}/removable)" = "0" ]; then
24 found="yes"
25
26 while true; do
27 # Try sleeping here to avoid getting kernel messages
28 # obscuring/confusing user
29 sleep 5
30 echo "Found drive at /dev/${device}. Do you want to install this image there ? [y/n]"
31 read answer
32 if [ "$answer" = "y" ] ; then
33 break
34 fi
35
36 if [ "$answer" = "n" ] ; then
37 found=no
38 break
39 fi
40
41 echo "Please answer y or n"
42 done
43 fi
44 fi
45
46 if [ "$found" = "yes" ]; then
47 break;
48 fi
49
50done
51
52if [ "$found" = "no" ]; then
53 exit 1
54fi
55
56echo "Installing image on /dev/${device}"
57
58#
59# The udev automounter can cause pain here, kill it
60#
61rm -f /etc/udev/scripts/mount*
62
63#
64# Unmount anything the automounter had mounted
65#
66umount /dev/${device}* 2> /dev/null || /bin/true
67
68mkdir -p /tmp
69cat /proc/mounts > /etc/mtab
70
71disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
72
73swap_size=$((disk_size*swap_ratio/100))
74rootfs_size=$((disk_size-boot_size-swap_size))
75
76rootfs_start=$((boot_size))
77rootfs_end=$((rootfs_start+rootfs_size))
78swap_start=$((rootfs_end))
79
80# MMC devices are special in a couple of ways
81# 1) they use a partition prefix character 'p'
82# 2) they are detected asynchronously (need rootwait)
83rootwait=""
84part_prefix=""
85if [ ! "${device#mmcblk}" = "${device}" ]; then
86 part_prefix="p"
87 rootwait="rootwait"
88fi
89bootfs=/dev/${device}${part_prefix}1
90rootfs=/dev/${device}${part_prefix}2
91swap=/dev/${device}${part_prefix}3
92
93echo "*****************"
94echo "Boot partition size: $boot_size MB ($bootfs)"
95echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
96echo "Swap partition size: $swap_size MB ($swap)"
97echo "*****************"
98echo "Deleting partition table on /dev/${device} ..."
99dd if=/dev/zero of=/dev/${device} bs=512 count=2
100
101echo "Creating new partition table on /dev/${device} ..."
102parted /dev/${device} mklabel gpt
103
104echo "Creating boot partition on $bootfs"
105parted /dev/${device} mkpart primary 0% $boot_size
106
107echo "Creating rootfs partition on $rootfs"
108parted /dev/${device} mkpart primary $rootfs_start $rootfs_end
109
110echo "Creating swap partition on $swap"
111parted /dev/${device} mkpart primary $swap_start 100%
112
113parted /dev/${device} print
114
115echo "Formatting $bootfs to vfat..."
116mkfs.vfat $bootfs
117
118echo "Formatting $rootfs to ext3..."
119mkfs.ext3 $rootfs
120
121echo "Formatting swap partition...($swap)"
122mkswap $swap
123
124mkdir /ssd
125mkdir /rootmnt
126mkdir /bootmnt
127
128mount $rootfs /ssd
129mount -o rw,loop,noatime,nodiratime /media/$1/$2 /rootmnt
130
131echo "Copying rootfs files..."
132cp -a /rootmnt/* /ssd
133
134if [ -d /ssd/etc/ ] ; then
135 echo "$swap swap swap defaults 0 0" >> /ssd/etc/fstab
136
137 # We dont want udev to mount our root device while we're booting...
138 if [ -d /ssd/etc/udev/ ] ; then
139 echo "/dev/${device}" >> /ssd/etc/udev/mount.blacklist
140 fi
141fi
142
143umount /ssd
144umount /rootmnt
145
146echo "Preparing boot partition..."
147mount $bootfs /ssd
148
149EFIDIR="/ssd/EFI/BOOT"
150mkdir -p $EFIDIR
151GRUBCFG="$EFIDIR/grub.cfg"
152
153cp /media/$1/vmlinuz /ssd
154# Copy the efi loader and config (booti*.efi and grub.cfg)
155cp /media/$1/EFI/BOOT/* $EFIDIR
156
157# Update grub config for the installed image
158# Delete the install entry
159sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
160# Delete the initrd lines
161sed -i "/initrd /d" $GRUBCFG
162# Delete any LABEL= strings
163sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
164# Replace the ramdisk root with the install device and include other options
165sed -i "s@ root=[^ ]*@ root=$rootfs rw $rootwait quiet@" $GRUBCFG
166
167umount /ssd
168sync
169
170echo "Remove your installation media, and press ENTER"
171
172read enter
173
174echo "Rebooting..."
175reboot -f
diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index d5e241a620..3fba7dc3a1 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -116,11 +116,11 @@ case $label in
116 fi 116 fi
117 fi 117 fi
118 ;; 118 ;;
119 install) 119 install|install-efi)
120 if [ -f /media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then 120 if [ -f /media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then
121 ./install.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params 121 ./$label.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params
122 else 122 else
123 fatal "Could not find install script" 123 fatal "Could not find $label script"
124 fi 124 fi
125 125
126 # If we're getting here, we failed... 126 # If we're getting here, we failed...
diff --git a/meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb
new file mode 100644
index 0000000000..8ad47d476b
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb
@@ -0,0 +1,22 @@
1DESCRIPTION = "A live image init script for grub-efi"
2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4SRC_URI = "file://init-install-efi.sh"
5
6PR = "r0"
7
8RDEPENDS_${PN} = "parted e2fsprogs-mke2fs dosfstools"
9
10do_install() {
11 install -m 0755 ${WORKDIR}/init-install-efi.sh ${D}/install-efi.sh
12}
13
14# While this package maybe an allarch due to it being a
15# simple script, reality is that it is Host specific based
16# on the COMPATIBLE_HOST below, which needs to take precedence
17#inherit allarch
18INHIBIT_DEFAULT_DEPS = "1"
19
20FILES_${PN} = " /install-efi.sh "
21
22COMPATIBLE_HOST = "(i.86|x86_64).*-linux"