Gentoo Archives: gentoo-dev

From: Duncan <1i5t5.duncan@×××.net>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: grub:2 keywords
Date: Sat, 30 Jun 2012 05:57:17
Message-Id: pan.2012.06.30.05.55.42@cox.net
In Reply to: Re: [gentoo-dev] grub:2 keywords by Richard Yao
1 Richard Yao posted on Fri, 29 Jun 2012 17:10:31 -0400 as excerpted:
2
3 > On 06/29/2012 05:04 PM, Mike Gilbert wrote:
4 >> On Fri, Jun 29, 2012 at 4:56 PM, Richard Yao <ryao@g.o> wrote:
5 >>> On 06/29/2012 03:04 PM, Mike Gilbert wrote:
6 >>>> On Fri, Jun 29, 2012 at 3:00 PM, Rich Freeman <rich0@g.o>
7 >>>> wrote:
8 >>>>> On Fri, Jun 29, 2012 at 2:51 PM, Richard Yao <ryao@g.o>
9 >>>>> wrote:
10 >>>>>> GRUB2 does away with the conventional stage files. It also wants a
11 >>>>>> special BIOS Boot Partition in order to function. That is where it
12 >>>>>> stores the equivalent of the stage2 bootcode.
13
14 >>>>> Now, that should make for a fun migration! Fortunately I do have a
15 >>>>> separate boot already, and I guess I can be daring and overwrite it
16 >>>>> in place and trust in grub2 to still find the kernel elsewhere.
17 >>>>>
18 >>>>> Those without a separate boot and without any free space are likely
19 >>>>> to find this to be painful. Resizing partitions isn't exactly
20 >>>>> risk-free...
21
22 >>>> I think Richard is incorrect here; grub2 can live on any filesystem,
23 >>>> so long as some combination of modules can access it.
24
25 >>> Do you know what function the BIOS Boot Partion serves? It is
26 >>> necessary when using GRUB2's ZFS support. I was under the impression
27 >>> that it stored boot code.
28
29 >> Based on a Google search I think "BIOS Boot Partition" is a GPT thing.
30 >> Not relevent if you have an MBR partition table.
31
32 > This is correct. I had forgotten that I switched to GPT
33
34 Some brief detail to de-fuzz things slightly...
35
36 1) Existing MBR installations function much like grub1 in terms of where
37 the core, which replaces stage-1.5, goes. Like grub1, one of two
38 requirements must be met:
39
40 1a) Preferable: Some slack-space between the MBR and the first
41 partition. If this exists, grub2's core gets placed here, with the MBR
42 using an absolute address to it, much like grub1 did with its stage-1.5s
43 except that grub2's core is assembled from individual modules at install
44 time and is thus able to handle anything it has modules for (as long as
45 there's slack-space enough for the stack of necessary modules), including
46 mdraid, lvm2, etc.
47
48 1b) Fallback: If no slack-space exists between the MBR and the first
49 partition or if it's not enough, grub2 can install its core, much as
50 grub1 could install its stage-1.5s, into /boot. The disadvantage in both
51 cases is that again it's accessed via absolute-address from the mbr, and
52 if the filesystem moves it around, as journaling and COW-based
53 filesystems sometimes do, the data can move out from under that absolute
54 address, breaking the boot before even grub's rescue shell is available.
55 Thus, this is STRONGLY DISCOURAGED, but it's an option for those on old
56 systems, and it generally works as long as you're using an older /boot
57 filesystem like fat or ext2 that's not going to move the data around.
58
59 (1c: As with grub1 it's also possible to install grub to a partition
60 instead of to the entire disk. However, this is much more strongly
61 discouraged with grub2 than it was with grub1, I believe for much the
62 same reasons as with 1b.)
63
64 2) BIOS-based GPT, with a dedicated BIOS partition (typically ~128 KB or
65 so in size is fine), is definitely preferable to legacy MBR for grub2.
66 This is because grub2 makes use of the (bare-partition, no-filesystem)
67 dedicated BIOS partition to place its core in, something grub1 doesn't
68 do. With no filesystem and a special partition type dedicated by GPT for
69 this purpose, this is the strongest guarantee yet that the core will
70 remain undisturbed at the absolute address grub placed it at, and thus at
71 least the core rescue shell should always be available, even if something
72 happens to /boot (which is entirely separate from the reserved BIOS
73 partition.
74
75 If a user has planned well when they setup their GPT partitioning, this
76 reserved BIOS partition should be plenty large enough for all required
77 modules, even for stacked devices such as exotic filesystem on lvm on
78 mdraid.
79
80 3) For EFI-based GPT, there's another entirely separate special reserved
81 partition for the EFI system. According to the EFI spec, this must be
82 formatted FAT32, and should be 256 MB or so. I don't have an EFI system
83 so have skipped much of the grub2 documentation on this so far and thus
84 don't know a whole lot about it.
85
86 Again, if a user has planned well when setting up their GPT, they may
87 actually have both an EFI partition and a BIOS partition (as I do here),
88 tho only one will likely be in use. But having both in the gpt layout
89 does allow migrating the disk from a legacy BIOS system to a newer EFI
90 system when the time comes, without re-gdisking (fdisking for gpt).
91
92
93 Meanwhile, for those who didn't know yet, it's worth noting that with GPT
94 there's no primary/logical partition division, they're all the same, and
95 there's room for upto 128 partition entries in the standard GPT, tho a
96 larger one is possible if needed. Additionally, there's two copies of
97 the partition table and they're checksummed, making them MUCH more
98 reliable than the old MBR scheme. AND, gpt allows direct partition
99 names, much like filesystem labels, udev maps them (tho for some reason
100 it doesn't seem to map those on mdraid devices last I checked), and mount
101 can mount by partition name using udev in much the same way as it mounts
102 by UUID or filesystem label.
103
104 --
105 Duncan - List replies preferred. No HTML msgs.
106 "Every nonfree program has a lord, a master --
107 and if you use the program, he is your master." Richard Stallman

Replies

Subject Author
Re: [gentoo-dev] Re: grub:2 keywords Maxim Kammerer <mk@×××.su>