Template:Article summary heading Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end
- 1 Installing Grub package
- 2 Installing or Restoring GRUB to the Master Boot Record
- 3 Boot loader configuration
- 4 LiLO and GRUB interaction
- 5 Framebuffer Resolution
- 6 Troubleshooting
- 7 External Resources
Installing Grub package
First install grub with pacman
pacman -Sy grub
Edit the menu.lst with your settings
Note: Use hd[a-z] for ide and sd[a-z] for scsi and sata
Here is mine for example:
# Config file for GRUB - The GNU GRand Unified Bootloader # /boot/grub/menu.lst # DEVICE NAME CONVERSIONS # # Linux Grub # ------------------------- # /dev/fd0 (fd0) # /dev/hda (hd0) # /dev/hdb2 (hd1,1) # /dev/hda3 (hd0,2) # # FRAMEBUFFER RESOLUTION SETTINGS # +-------------------------------------------------+ # | 640x480 800x600 1024x768 1280x1024 # ----+-------------------------------------------- # 256 | 0x301=769 0x303=771 0x305=773 0x307=775 # 32K | 0x310=784 0x313=787 0x316=790 0x319=793 # 64K | 0x311=785 0x314=788 0x317=791 0x31A=794 # 16M | 0x312=786 0x315=789 0x318=792 0x31B=795 # +-------------------------------------------------+ # general configuration: timeout 5 default 1 color light-blue/black light-cyan/blue # boot sections follow # each is implicitly numbered from 1 in the order of appearance below # # TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line. # #-* # (0) Arch Linux title Arch Linux [cpio] root (hd0,0) kernel /boot/vmlinuz26 root=/dev/sda6 ro vga=773 initrd /boot/kernel26.img title Arch Linux [thinkpad] root (hd0,0) kernel /boot/vmlinuz26thinkpad root=/dev/sda6 ro video=vesafb:off acpi_sleep=s3_bios resume=swap:/dev/sda5 initrd /boot/kernel26thinkpad.img
Copy the mounts to mtab
grep -v rootfs /proc/mounts > /etc/mtab
Installing or Restoring GRUB to the Master Boot Record
GRUB may be installed from a live environment, or directly from a running Arch install.
In either case, boot the system and run the grub command as root:
Grub must be told where its files are on the system, since multiple instances of it may exist. The grub files reside under /boot, which may be its own partition. If you know where /boot is, specify it with the root command like so:
grub> root (hdx,x)
(remember that /boot is GRUB's root)
If you are unaware of the the location of /boot, use the find command to locate the GRUB files.
The following example is for systems without a separate /boot partition, wherein /boot is merely a directory under / :
grub> find /boot/grub/stage1
The following example is for systems with a separate /boot partition:
grub> find /grub/stage1
Grub will find the file, and give an output showing the location of the stage1 file, (which resides under /boot). For example:
Use the root command, (with the output from the find command) to instruct GRUB which partition contains stage1, (and therefore, /boot):
grub> root (hd1,0)
Finally, (re)install GRUB to the MBR of the drive. The following example installs GRUB to the MBR of the drive containing /boot:
grub> setup (hd1)
Use the quit command to quit GRUB:
- Alternative, installing to a partition.
You may, of course, install GRUB anywhere you need it to be.
grub> setup (hd1,0)
will install GRUB to the second harddisk, first partition.
Boot loader configuration
The grub configuration is done in this file:
- (hdn,m) is the partition m on disc n, numbers starting with 0
- splashimage (hdn,m)/grub/Name.xpm.gz is the splash-image-file
- default n is the default boot entry, that is choosen after timout for user action
- timeout m time m to wait in seconds for a user selection, before default is booted
- password -md5 str encrypted boot password 'str'
- title str title string 'str' for a boot entry
- root (hdn,m) base partition, where the kernel is stored to
- kernel /path ro root=/dev/device initrd /initrd.img use the root option, if the kernel not placed in /
chainloader +1 sets root active and gives booting procedure to its boot-loader (for Windows, f.e.)
- map (hd0) (hd1)
map (hd1) (hd0) changes primary and secondary disc for a boot, necessary to boot Windows from a secondary disc
- root (hdn,m,z)
kernel /boot/loader boots the FreeBSD-Partition x
- default saved remembers each current boot selection and makes it the new default. Place "savedefault" at the end of each boot section, for that you want this feature shall be used.
For those who like eye-candy, there is Graphical GRUB.
These are the two most common ways of configuring the menu.lst file. For more complex uses, click here.
Dual booting with Windows
Add this at the end of your /boot/grub/menu.lst. This assumes that your Windows partition is [s/h]da2.
# (2) Windows XP title Windows XP rootnoverify (hd0,1) makeactive chainloader +1
Note, that although commonly believed to be the case, Windows 2000 and later versions do not need to be on the first partition to boot. If the Windows partition changes number (i.e. if you after install add a partition before the windows partition), you will need to edit the Windows boot.ini file to reflect the change (see this article for details on how to do that).
Dual booting with Windows on another hard disk
Add this at the end of your /boot/grub/menu.lst. This assumes that your Windows partition is [s/h]db1.
# (2) Windows XP title Windows XP map (hd0) (hd1) map (hd1) (hd0) rootnoverify (hd1,0) makeactive chainloader +1
The map function tricks your Windows install into thinking that a second hard drive is the primary.
Dual booting with other linux distros
This is done exactly the same way that Arch linux is loaded. Here we assume that the other distro is on partition [s/h]da3.
title Other Linux root (hd0,2) kernel /boot/vmlinuz (add other options here as required) initrd /boot/initrd.img (if the other kernel uses/needs one)
Dual booting with other linux distro (Chainloading)
To avoid maintenance nightmare, you might want to chainload the GRUB in the MBR to another bootloader you might have installed in the bootrecord of a partition [(hd0,2) in our example] instead of the MBR. This way the auto-magic stuff of some distro will manage the menu.lst on (hd0,2) (if it is grub) for its own distro and you will boot with all the option needed (like the correct last kernel) without the need to copy/paste some part of that menu.lst into yours.
In our example , GRUB is in the MBR and some other bootloader (BL) (be it grub or lilo) is in the Boot Record of (hd0,2).
------------------------------------------------- | | | | % (hd0,2) | | M | | | B % | | B | (hd0,0) | (hd0,1) | L % Other | | R | | | % Distro | | | | | % | ------------------------------------------------- | ^ | chainloading | -----------------------------
Then, you simply use in your menu.lst:
title Other Linux distro root (hd0,2) chainloader +1
This, of course, also works the other way around, i.e. if your arch root is in (hd0,2)/sda2 and you chose to install Arch's GRUB there instead of the MBR, because you had installed another distro first, just put the above code in that distros menu.lst.
Tips and tricks
Restart with named boot choice
If you realize that you need to switch to some other non-default OS, e.g. Windows, having to reboot and wait for the GRUB menu to appear is tedious. GRUB offers a simple way to record your OS choice when restarting instead of waiting for the menu, simply by designating a temporary new default which will be reset (to the 'default default') as soon as it has been used.
Supposing a simple menu.lst setup like this:
# general configuration: timeout 10 default 0 color light-blue/black light-cyan/blue # (0) Arch title Arch Linux root (hd0,1) kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/a29113d7-2204-49e9-be69-d94699eba466 ro initrd /boot/kernel26.img # (1) Windows title Microsoft Windows XP Pro rootnoverify (hd0,0) makeactive chainloader +1
Arch is the default (0). We want to restart in to Windows. Change default to saved ("default saved") - this will record the current default in a 'default' file in the grub directory whenever the 'savedefault' grub command is used. Now add the line "savedefault 0" to the bottom of the Windows entry. Whenever Windows is booted, it will reset the default to Arch, thus making changing the default to Windows temporary.
Now all that is needed is a way to easily change the default 'manually'. This can be accomplsihed using the command 'grub-set-default [number of entry (starting with 0)]. So to reboot into Windows, enter the following command:
sudo grub-set-default 1 && sudo shutdown -r now
For ease of use, you might to wish to implement the "Allow users to shutdown fix" (including /sbin/grub-set-default amongst the commands the user is allowed to issue without supplying a password).
LiLO and GRUB interaction
If you once had used lilo Don't forget to remove it with
pacman -R lilo
as some tasks (f.e. kernel compilation using
make all) will make a lilo call, and then lilo is installed over grub.
Note that this will not remove lilo from the MBR, but it will be overwritten when you install another bootloader.
One can use the resolution given in the menu.lst of grub. But you might want to use your LCD wide-screen at its full native resolution. Here is what you can do to achieve this.
On wikipedia, there is a list of extended framebuffer resolution (i.e beyond the ones in the VBE standard). But, for example, the one i want to use is 1440x900 and the vga=867 does not work. May be because those resolution are outside of the standard and every graphic card manufacturer use the code they like.
So instead of using that table, i suggest using this method:
How to find the correct code to use for the resolution you want to use
- Install lrmi package from the [community] that has the vbetest tool (not available for 64bit arch, install hwinfo [AUR] instead and run 'hwinfo --vbe').
- Run vbetest as root and in a console already running on framebuffer. While vbetest will return results in a terminal in X, you will not be able to test using vbetest -m yournumberhere unless you are running a framebuffered console.
- Then note the number in [ ] corresponding to your desired resolution with vbetest. With hwinfo the six digits following Mode are the values you'll need.
- Press 'q' to quit vbetest interactive prompt.
- Add 512 to the discovered vbetest value for you monitor size and use the total as code to use in vga= kernel option in menu.lst. For hwinfo copy the six digit code to the vga= option.
- reboot and voilà !
For example vbetest on one computer:
 1440x900 (256 color palette)  1440x900 (8:8:8)
So here the number you want is 357. then, 357 + 512 = 869, so you will use vga=869. Add your vga value to the end of the kernel line in menu.lst as shown below.
kernel /vmlinuz26 root=/dev/sda1 ro vga=869
On another desktop with hwinfo:
Mode 0x0364: 1440x900 (+1440), 8 bits Mode 0x0365: 1440x900 (+5760), 24 bits
And the kernel line:
kernel /vmlinuz26 root=/dev/sda1 ro vga=0x0365
Now, you will have a console at the full native resolution of your screen. The next step is to use another font in console at a correct size. In my case i use terminus font named ter-120b (by setting CONSOLEFONT in /etc/rc.conf)
- (8:8:8) is for 24-bit color (or 32-bit ?)
- (5:6:5) is for 16-bit color
- (5:5:5) is for 15-bit color
Editing GRUB entries just before boot
Once you have selected some entry before booting, you can edit it using key 'e' and following on-screen instructions. Then you can boot it using key 'b'. This settings will not be saved.
If you've opened a submenu with the list of all operating system configured in grub, selected one and upon restart you still got your default OS, then you might want to check if you have line
in file /boot/grub/menu.lst.