Gentoo Archives: gentoo-user

From: walt <w41ter@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: A tiny titillating taste of grub2
Date: Sun, 09 Jan 2011 20:07:47
Message-Id: igd12e$bc2$1@dough.gmane.org
In Reply to: Re: [gentoo-user] A tiny titillating taste of grub2 by Alan McKinnon
1 On 01/09/2011 04:10 AM, Alan McKinnon wrote:
2 > Apparently, though unproven, at 02:44 on Sunday 09 January 2011, Dale did
3 > opine thusly:
4 >
5 >> I have not tried grub2 yet but I did fine these:
6 >>
7 >> https://help.ubuntu.com/community/Grub2
8 >> http://en.gentoo-wiki.com/wiki/Grub2
9 >> http://grub.enbug.org/grub.cfg
10
11 Thanks Dale, the ubuntu link may be what I need.
12
13 > I don't quite agree with Volker's viewpoint but don't totally disagree with
14 > him either. grub2 has a whole whack of bloat all of it's own.
15
16 Indeed it does, except for grub.info, which is not nearly complete.
17
18 > Methinks a modular build system is in order here. Why should I build support
19 > for sparc when I know for a fact I'm building an x86 installer?
20
21 Here is how I do that manually, FWIW. (I've not run the grub2 install scripts
22 because I haven't read them yet, which makes me nervous in a boot loader :)
23
24 $cd ~/src #in my home directory, so I don't need root
25 $tar -xvzf /usr/portage/distfiles/grub-1.98.tar.gz
26 $cd grub-1.98
27 $./configure --prefix=$HOME --disable-werror
28 $make all install
29
30 At this point grub2 has merely saved some files in your home directory, it
31 has *not* messed with your boot sector or touched legacy grub in any way.
32
33 $ls ~/bin/grub*
34 /home/wa1ter/bin/grub-bin2h /home/wa1ter/bin/grub-mkisofs
35 /home/wa1ter/bin/grub-editenv /home/wa1ter/bin/grub-mkpasswd-pbkdf2
36 /home/wa1ter/bin/grub-fstest /home/wa1ter/bin/grub-mkrelpath
37 /home/wa1ter/bin/grub-mkelfimage /home/wa1ter/bin/grub-mkrescue
38 /home/wa1ter/bin/grub-mkfont /home/wa1ter/bin/grub-script-check
39 /home/wa1ter/bin/grub-mkimage
40
41 $ls ~/lib/grub/i386-pc/
42 acpi.mod font.mod linux16.mod reboot.mod
43 affs.mod fs.lst lnxboot.img reiserfs.mod
44 afs.mod fshelp.mod loadenv.mod relocator.mod
45 <dozens more grub2 modules snipped for brevity>
46
47 That's where the bloat comes from, as you pointed out. There are tons
48 of those *.mod files you won't need, so the trick is to compile a list
49 of them you *do* need, and then feed the list to grub-mkimage as described
50 below.
51
52 NOTE: I can't recall exactly why but the ata* modules conflict with some
53 other modules, so *don't use them* unless you know what you are doing.
54
55 Create a list of all grub2 modules:
56
57 $ls ~/lib/grub/i386pc/*.mod > /tmp/modlist
58
59 Now edit that file and delete any modules you know you don't need, e.g.
60 I deleted reiserfs.mod and ntfs.mod and the raid*.mod because I don't
61 use those items. Don't touch anything you don't clearly recognize, but
62 *do* delete ata.mod and ata_pthru.mod.
63
64 Now it's time to build the grub2 binary executable:
65
66 $~/bin/grub-mkimage -o /tmp/grub2bin `cat /tmp/modlist`
67
68 Your file grub2bin is actually formatted as a tiny pseudo kernel, which
69 your legacy grub can boot using the usual grub sytax:
70
71 title try grub2
72 root (hdX,X)
73 kernel /tmp/grub2bin (or wherever else you want to put it. NOTE: so far
74 I've done nothing requiring root privileges :)
75
76 That menu item will start a grub2 running so you can experiment with
77 it all you want, but still use legacy grub to boot as you always do.
78 (You won't yet have a menu file for grub2, so you will see only the
79 usual grub command prompt instead of a menu.)
80
81 The grub2 shell is a bit different, so you might want to type "set" to
82 see what variables you can change, "ls" to see your disks, and of course
83 hit the tab key when you don't know what else to type.
84
85 Type "help search" for the real excitement.
86
87 A few more grub2 differences: the 'linux' command replaces 'kernel' to
88 load your (linux) kernel. 'multiboot' is used to load any true multiboot
89 kernel e.g. NetBSD. Not sure, but I think you still need to chainload
90 the Windows booter -- sadly, I can't test it anymore :D
91
92 One problem I encountered on my old amd32 machine is that I had to remove
93 the USB-related grub2 modules or grub2 would crash while probing for disks.
94 The newer amd64 machine works fine with the USB stuff included. Dunno why.
95
96 NOTE: if grub2 names your disks (ataN,N) instead of (hdN,N) that means
97 you are using the ata* grub2 modules -- I haven't figured out how to make
98 that configuration work yet.

Replies

Subject Author
Re: [gentoo-user] Re: A tiny titillating taste of grub2 Dale <rdalek1967@×××××.com>
[gentoo-user] Re: A tiny titillating taste of grub2 walt <w41ter@×××××.com>
[gentoo-user] Re: A tiny titillating taste of grub2 walt <w41ter@×××××.com>