Penguin
Annotated edit history of GrubNotes version 28, including all changes. View license author blame.
Rev Author # Line
27 NathanOverall 1 !! Grub 2, what's the deal?
2
3 Grub got a rewrite recently and inherently became a lot more powerful. However you may be wondering where the old menu.lst file has run off to. menu.lst (on debian at least) has been replaced by a series of scripts which build a grub.cfg (grub 2 config file) for you. Things you probably care about:
4
5 ! How do I change kernel options?
6
7 Simply edit /etc/default/grub then run update-grub
8
9 ! How do I add other OSs
10 Generally installing os-prober will solve this problem.
11
28 NathanOverall 12 <pre>
13 aptitude install os-prober
14 os-prober
15 update-grub
16 </pre>
27 NathanOverall 17
18 you should see it spit out some info about adding your other OSs
19
20 ! I want to add a new boot section to grub manually
21
22 Simply edit /etc/grub.d/40_custom and add the new section. This will be copied to /boot/grub/grub.cfg when you run update-grub next.
23
16 DanielLawson 24 !! I need to reinstall grub in my master boot record
25
22 IanMcDonald 26 Boot off a liveCD, and [chroot(8)] into your main root partition.
16 DanielLawson 27
26 LawrenceDoliveiro 28 __Remember that grub numbering starts at 0:__ __/dev/hda1__ becomes __(hd0,0)__, etc. However, note that GRUB’s disk ordering is determined by the BIOS, while the Linux kernel’s ordering is not. For instance, on an Asus Eee 701, if you change the BIOS boot order to put the SD-card slot ahead of the internal SSD, GRUB will swap their names around so the internal SSD becomes “hd1” and the SD-card becomes “hd0”. However, the kernel will still call them “sda” and “sdb” respectively.
16 DanielLawson 29
30 Run 'grub'. Issue =root (hdx,x)= if you know where your __/boot__ directory is, or use =find /boot/grub/stage1= to find it if you don't. Then issue =setup (hdx)= to install GRUB in the master boot record of drive hdx, or =setup (hdx,x)= to setup inside a partition.
20 IanMcDonald 31
32 Alternatively on many modern distros you can use [grub-install(8)] to do this e.g.
33 grub-install /dev/hda
23 JohnMcPherson 34
35 !! I get "The file /boot/grub/stage1 not read correctly" when running <tt>grub-install</tt>
36 Even if you can see the file /boot/grub/stage1 on your filesystem, this error message means that grub can't find it when it is running. Grub consults your /etc/fstab and /etc/mtab files to determine which partition/drive the '''/boot''' directory is actually on, so check those files are correct. (See the next section for more details about this.)
37
38 There are also lots of other obscure reasons why it can't be found, and unfortunately the GRUB developers don't believe in giving users better error messages. In my case, I got this because I was trying to install an MBR to boot of a drive that had linux installed on a partition that used to have windows xp. In this case, the partition type was set to "NTFS" despite containing an ext3 partition. Using ''cfdisk'' to change the partition type to be "83 (linux)" meant that when I next ran __grub-update__, it worked.
24 BruceKingsbury 39
40 !! I get "Error 15" on boot even after reinstalling GRUB from a rescue CD
41
42 This one had us stumped for a while, until I noticed that the boot order in BIOS was CDROM -> IDE-1 -> Floppy. The correct device should have been IDE-0. IDE-1 is the Primary SLAVE drive which in this case happened to exist, and also happened to have an old copy of GRUB on the MBR. Sometimes the problem isn't where you expect it to be!
16 DanielLawson 43
44 !! I get a grub> prompt on boot
45
46 This means [GRUB] can't find your config file. You can still boot into the system by issuing appropriate commands.
47
48 Eg., if I have a system which has a single disk, partitioned with __/dev/hda1__ as __/boot__ and __/dev/hda5__ as __/root__, and I have a [Kernel] called __vmlinuz__ in __/boot__, I can do:
49
50 <pre>
51 root (hd0,0)
52 kernel /vmlinuz root=/dev/hda5 ro
53 boot
54 </pre>
55
56 and it'll boot quite happily -- this time. Note that I set the [GRUB] root to __(hd0,0)__, which corresponds to __/dev/hda1__, and so the path to the kernel is relative to the top of __/dev/hda1__ (which is __/boot__ when mounted correctly). Also note that the [GRUB] shell features tab completion on filenames, so you can do __kernel /~[tab]__ and get a list of possible values. You can also use this to work out which [FileSystem]s are which, as [GRUB] will understand most [Linux] [FileSystem]s you're likely to have.
57
58 However, the real problem is that [GRUB] can't find your config file. First, check that you have one - it should be in __/boot/grub/menu.lst__ by default, but some distributions put it at __/boot/grub/grub.conf__. If the latter is the case, make a symlink between the two and reboot to test: =ln -s /boot/grub/grub.conf /boot/grub/menu.lst=
59
60 If that still doesn't work, it's possible that [GRUB] is looking in the wrong place for your config. If you installed [GRUB] using something like =grub-install --root-device=/boot '(hd0)'= it will install to __/boot/grub/__ etc, however if your __/boot__ is on a separate partition (as I described in the example above) then it's fairly likely that [GRUB] is looking in __/boot/boot/grub/__ for __menu.lst__ -- and not finding it.
61
62 Easiest fix (it stops this happening again in the future, so perhaps the best fix?) is to symlink __/boot__ into __/boot__ by doing =ln -s /boot /boot/=. You should now be able to cd into __/boot/boot/grub__ and it'll have your __menu.lst__ there.
21 IanMcDonald 63
64 !! Adding a new kernel to grub
65
66 If you're building your own kernels or doing KernelDevelopment then you need to manually edit the files for [grub(8)] or on many distros you can run [update-grub(8)]. One thing to note is that if you rearrange hard drives you need to edit the menu.lst file to tell it which drive is which and the kernel options before running [update-grub(8)]. The lines needed have a hash symbol in front of them which makes them look like a comment only, but they are not a comment at all!!
16 DanielLawson 67
68 !! Using a different kernel for the next reboot only
69
70 <pre>
71 grub
72 savedefault --default=N --once
73 ''(where N is the number of the kernel you want to boot once)''
74 quit
75 </pre>
76
77 Reboot your machine. It will boot using kernel "N".
78
79 =grub-reboot N= will do essentially the same thing and prompt to reboot the machine
80
81 !! Using [GRUB] with a serial console
82
83 In the [GRUB] config file (normally /boot/grub/menu.lst) add these lines to the top to enable the serial console in addition to the regular console:
84
85 <pre>
86 serial --unit=0 --speed=9600
87 terminal --timeout=10 serial console
88 </pre>
89
90 [GRUB] will now display on the serial console as well as locally. It will wait for a keypress for 10 seconds to determine which input is being used, before timing out and carrying on the boot process. If a key is pressed then the regular menu will be displayed and you can select a kernel as usual.
91
92 The first line configures the serial link with the following options (defaults to 9600, 8n1 from what I can gather):
93 * ''--unit=X'' which serial port to use. 0 = ttyS0, 1 = ttyS1 etc
94 * ''--speed=X'' the rate in bps the serial link should run at
95 * ''--word=X'' number of data bits
96 * ''--parity=X'' parity to use, where X is one of 'no', 'even', 'odd'
97 * ''--stop=X'' number of stop bits to use
98
99 The second line specifies which devices should be used for input/output. You can set it up so that it only displays locally, only on the serial console, or on both.
100 * ''--timeout=X'' the number of seconds [GRUB] should wait for a keypress before continuing
101 * ''serial'' if this option is present, the serial console will be used
102 * ''console'' if this option is present, the local console will be used
103 If both ''serial'' and ''console'' are present, then grub will use whichever method accepts a keypress first
104
105 ! Making your kernel do serial too!
106 If you have [GRUB] setup to use a serial console then you probably want to compile your kernel with serial console support and append the following options to your boot line, so your kernel messages appear on your serial console too. If you don't do this you'll have a big empty screen between grub loading the kernel and your getty loading, when you think that your kernel has hung!
107
108 =console=ttyS0,19200n8=
109
25 RossHamblin 110 So a full kernel boot line might look like =kernel /boot/vmlinuz ro root~=/dev/hda1 console=tty0 console=ttyS0,19200n8=
16 DanielLawson 111
112 ----
113 !! GRUB resources on the web
114
115 * [GRUB homepage | http://www.gnu.org/software/grub]
116 * [GRUB manual | http://www.gnu.org/software/grub/manual/html_node/]
18 RaymondBurgess 117 * [GRUB wiki | http://grub.enbug.org/]
16 DanielLawson 118 * [Linux+Win+GRUB HowTo | http://tldp.org/HOWTO/Linux+Win9x+Grub-HOWTO/index.html]
119 * [Linux Recovery and Boot Disk Creation with GRUB | http://promote-opensource.org/modules/mylinks/singlelink.php?cid=14&lid=94]
120 * [Win32 GRUB | http://www.skyjammer.com/files/knoppix/]
121 * [Booting with GRUB | http://www.ameritech.net/users/gholmer/booting.html]
122 * [WinGRUB | http://grub4dos.sourceforge.net/]
123 * [GRUB installer for Windows | http://www.geocities.com/lode_leroy/grubinstall/]
124 * [GRUB for DOS | http://grub.linuxeden.com/] - Bridging DOS/Windows to Unix/Linux
125 * [Comparison of GRUB and LILO|http://www-128.ibm.com/developerworks/library/l-bootload.html?ca=dgr-lnxw01LILOandGRUB]
19 IanMcDonald 126 * [GRUB FAQ | http://www.gnu.org/software/grub/grub-faq.en.html]
127 * [GRUB Manual | http://www.gnu.org/software/grub/manual/html_node/]
128 * [GRUB wiki | http://autistici.org/grub/]
129 * [Linux+Win9x+Grub HOWTO | http://www.tldp.org/HOWTO/Linux+Win9x+Grub-HOWTO/]
130 * [Multiboot with GRUB Mini-HOWTO | http://www.tldp.org/HOWTO/Multiboot-with-GRUB.html]
131 * [APC guide to dual-booting Vista/XP/Linux | http://apcmag.com/5162/the_definitive_dual_booting_guide_linux_vista_and_xp ]