1 |
On 01/23/2011 02:28 PM, walt wrote: |
2 |
> Okay, I genuinely have grub2 installed and doing exactly what it's |
3 |
> supposed to do: boot your machine using only partition LABELS, not |
4 |
> device names/numbers... |
5 |
|
6 |
If you got through part 1 you should have all the files you need to |
7 |
install grub2 to your drive's boot block -- that's the part that is |
8 |
potentially dangerous, so practice installing to a USB thumb drive |
9 |
*before* you try it for real. |
10 |
|
11 |
All of my USB thumb drives were formatted FAT16 at the factory, and |
12 |
grub2 (being a bit of a pig) won't fit in a FAT16 partition table. |
13 |
|
14 |
The answer is to reformat the drive to FAT32 or ext2, or you can use |
15 |
a tool like gparted to shrink the FAT16 fs and create a new very tiny |
16 |
partition for ext2. Even 3MB is big enough to hold grub -- the size |
17 |
of the file system isn't important -- it's the partition table that's |
18 |
too small in FAT16. |
19 |
|
20 |
Assume you have the ext2 partition of the thumb drive mounted on |
21 |
/mnt/floppy, for example, and the thumb drive is /dev/sdc. |
22 |
|
23 |
For the actual install you need to be root because you will be |
24 |
writing to the device as well as the ext2 fs on the device. |
25 |
|
26 |
# mkdir -p /mnt/floppy/boot/grub |
27 |
# /home/walt/sbin/grub-install --boot-directory=/mnt/floppy/boot/ /dev/sdc |
28 |
|
29 |
That second step will write the actual grub2 boot block to the thumb |
30 |
drive, as well as copying lots of grub modules to /mnt/floppy/boot/grub |
31 |
from /home/walt/lib/grub/i386-c. |
32 |
|
33 |
All of those grub 'modules' contain the actually code that does things |
34 |
like print the boot menu on your screen and accept keystrokes from |
35 |
your keyboard, search for partition LABELs, UUIDs, display boot splash |
36 |
screens, play idiotic tunes, load custom fonts and fancy colors, and |
37 |
tons of other stuff you won't ever want if you're still sane. |
38 |
|
39 |
That should be enough to let you boot into the grub2 shell from your |
40 |
thumb drive, assuming you set your BIOS to allow it. |
41 |
|
42 |
Just like legacy grub, the grub2 command shell will always show you |
43 |
what you can type next if you hit the tab key -- and there is quite |
44 |
a long list. |
45 |
|
46 |
The important commands to learn are 'ls', 'search', 'probe', 'help', |
47 |
and 'linux'. That 'linux' command is what actually loads your kernel |
48 |
from the /boot partition after you have located it with the search |
49 |
and (possibly) the probe commands. |
50 |
|
51 |
Use the help command and the tab key whenever you don't know what to |
52 |
do next. You'll pick it up very quickly that way -- far faster than |
53 |
trying to read any of the incomplete documentation. |
54 |
|
55 |
One very clueful tool is the brand new utility 'grub-menulst2cfg' which |
56 |
you should find in your ~/bin directory. Running that on your existing |
57 |
/boot/grub/menu.lst will show you the equivalent commands for your new |
58 |
/boot/grub/grub.cfg file. Very neat, and isn't included in the current |
59 |
stable grub-1.98. |
60 |
|
61 |
Once you play with the grub2 command shell you will easily see how to |
62 |
use the same commands in grub.cfg because the syntax is the same. |
63 |
|
64 |
Next time I'll explain how to use GPT (GUID Partition Table) to let |
65 |
your kernel find and mount your root partition using its UUID without |
66 |
an initrd. Very nifty! |