1 config BR2_TARGET_GRUB2
3 depends on BR2_i386 || BR2_x86_64
5 GNU GRUB is a Multiboot boot loader. It was derived from
6 GRUB, the GRand Unified Bootloader, which was originally
7 designed and implemented by Erich Stefan Boleyn. GRUB 2 has
8 replaced what was formerly known as GRUB (i.e. version
9 0.9x), which has, in turn, become GRUB Legacy.
11 Amongst others, GRUB2 offers EFI support, which GRUB Legacy
14 Notes on using Grub2 for BIOS-based platforms
15 =============================================
17 1. Create a disk image
18 dd if=/dev/zero of=disk.img bs=1M count=32
19 2. Partition it (either legacy or GPT style partitions work)
21 - Create one partition, type Linux, for the root
22 filesystem. The only constraint is to make sure there
23 is enough free space *before* the first partition to
24 store Grub2. Leaving 1 MB of free space is safe.
25 3. Setup loop device and loop partitions
26 sudo losetup -f disk.img
27 sudo partx -a /dev/loop0
28 4. Prepare the root partition
29 sudo mkfs.ext3 -L root /dev/loop0p1
30 sudo mount /dev/loop0p1 /mnt
31 sudo tar -C /mnt -xf output/images/rootfs.tar
34 sudo ./output/host/usr/sbin/grub-bios-setup \
35 -b ./output/host/usr/lib/grub/i386-pc/boot.img \
36 -c ./output/images/grub.img -d . /dev/loop0
37 6. Cleanup loop device
38 sudo partx -d /dev/loop0
39 sudo losetup -d /dev/loop0
40 7. Your disk.img is ready!
45 If you use genimage to generate your complete image,
46 installing Grub can be tricky. Here is how to achieve Grub's
47 installation with genimage:
50 in-partition-table = "no"
51 image = "path_to_boot.img"
56 in-partition-table = "no"
57 image = "path_to_grub.img"
61 The result is not byte to byte identical to what
62 grub-bios-setup does but it works anyway.
64 To test your BIOS image in Qemu
65 -------------------------------
67 qemu-system-{i386,x86-64} -hda disk.img
69 Notes on using Grub2 for EFI-based platforms
70 ============================================
72 1. Create a disk image
73 dd if=/dev/zero of=disk.img bs=1M count=32
74 2. Partition it with GPT partitions
76 - Create a first partition, type EF00, for the
77 bootloader and kernel image
78 - Create a second partition, type 8300, for the root
80 3. Setup loop device and loop partitions
81 sudo losetup -f disk.img
82 sudo partx -a /dev/loop0
83 4. Prepare the boot partition
84 sudo mkfs.vfat -n boot /dev/loop0p1
85 sudo mount /dev/loop0p1 /mnt
86 sudo cp -a output/images/efi-part/* /mnt/
87 sudo cp output/images/bzImage /mnt/
89 5. Prepare the root partition
90 sudo mkfs.ext3 -L root /dev/loop0p2
91 sudo mount /dev/loop0p2 /mnt
92 sudo tar -C /mnt -xf output/images/rootfs.tar
95 sudo partx -d /dev/loop0
96 sudo losetup -d /dev/loop0
97 7. Your disk.img is ready!
99 To test your EFI image in Qemu
100 ------------------------------
102 1. Download the EFI BIOS for Qemu
103 Version IA32 or X64 depending on the chosen Grub2
104 platform (i386-efi vs. x86-64-efi)
105 http://sourceforge.net/projects/edk2/files/OVMF/
106 2. Extract, and rename OVMF.fd to bios.bin and
107 CirrusLogic5446.rom to vgabios-cirrus.bin.
108 3. qemu-system-{i386,x86-64} -L ovmf-dir/ -hda disk.img
109 4. Make sure to pass pci=nocrs to the kernel command line,
110 to workaround a bug in the EFI BIOS regarding the
113 http://www.gnu.org/software/grub/
120 config BR2_TARGET_GRUB2_I386_PC
123 Select this option if the platform you're targetting is a
124 x86 or x86-64 legacy BIOS based platform.
126 config BR2_TARGET_GRUB2_I386_EFI
129 Select this option if the platform you're targetting has a
130 32 bits EFI BIOS. Note that some x86-64 platforms use a 32
131 bits EFI BIOS, and this option should be used in this case.
133 config BR2_TARGET_GRUB2_X86_64_EFI
135 depends on BR2_ARCH_IS_64
137 Select this option if the platform you're targetting has a
142 if BR2_TARGET_GRUB2_I386_PC
144 config BR2_TARGET_GRUB2_BOOT_PARTITION
145 string "boot partition"
148 Specify the partition where the /boot/grub/grub.cfg file is
149 located. Use 'hd0,msdos1' for the first partition of the
150 first disk if using a legacy partition table, or 'hd0,gpt1'
151 if using GPT partition table.
153 endif # BR2_TARGET_GRUB2_I386_PC
155 config BR2_TARGET_GRUB2_BUILTIN_MODULES
156 string "builtin modules"
157 default "boot linux ext2 fat squash4 part_msdos part_gpt normal biosdisk" if BR2_TARGET_GRUB2_I386_PC
158 default "boot linux ext2 fat squash4 part_msdos part_gpt normal efi_gop" \
159 if BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI
161 config BR2_TARGET_GRUB2_BUILTIN_CONFIG
162 string "builtin config"
164 Path to a Grub 2 configuration file that will be embedded
165 into the Grub image itself. This allows to set the root
166 device and other configuration parameters, but however menu
167 entries cannot be described in this embedded configuration.
169 endif # BR2_TARGET_GRUB2