https://wiki.archlinux.org/api.php?action=feedcontributions&user=Jimbeam&feedformat=atomArchWiki - User contributions [en]2024-03-28T11:00:27ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=GRUB_Legacy&diff=84529GRUB Legacy2009-11-20T14:46:52Z<p>Jimbeam: /* Alternative way to find the resolution code */</p>
<hr />
<div>[[Category:Boot process (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers various aspects of Arch Linux's default bootloader, GRand Unified Bootloader (GRUB).}}<br />
<br />
{{Article summary heading|Available in languages}}<br />
{{i18n_entry|English|GRUB}}<br />
{{i18n_entry|עברית|GRUB (עברית)}}<br />
{{i18n_entry|简体中文|GRUB(简体中文)}}<br />
{{i18n_entry|Русский|GRUB (Русский)}}<br />
{{i18n_entry|Español|GRUB (Español)}}<br />
{{i18n_entry|Français|GRUB (Français)}}<br />
{{i18n_entry|Italiano|GRUB (Italiano)}}<br />
{{i18n_entry|Nederlands|GRUB (Nederlands)}}<br />
{{Article summary heading|Related articles}}<br />
{{Article summary wiki|Reinstalling GRUB}}<br />
{{Article summary wiki|Grub configure examples}}<br />
{{Article summary wiki|Grub-gfx}}<br />
{{Article summary end}}<br />
<br />
<br />
<br />
<br />
<br />
== Installing Grub package ==<br />
<br />
First install grub with pacman<br />
<br />
pacman -Sy grub<br />
<br />
Edit the menu.lst with your settings<br />
<br />
nano /boot/grub/menu.lst<br />
<br />
''Note: Use hd[a-z] for ide and sd[a-z] for scsi and sata''<br />
<br />
Here is mine for example:<br />
<br />
# Config file for GRUB - The GNU GRand Unified Bootloader<br />
# /boot/grub/menu.lst<br />
<br />
# DEVICE NAME CONVERSIONS <br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/hda (hd0)<br />
# /dev/hdb2 (hd1,1)<br />
# /dev/hda3 (hd0,2)<br />
#<br />
<br />
# FRAMEBUFFER RESOLUTION SETTINGS<br />
# +-------------------------------------------------+<br />
# | 640x480 800x600 1024x768 1280x1024<br />
# ----+--------------------------------------------<br />
# 256 | 0x301=769 0x303=771 0x305=773 0x307=775<br />
# 32K | 0x310=784 0x313=787 0x316=790 0x319=793<br />
# 64K | 0x311=785 0x314=788 0x317=791 0x31A=794<br />
# 16M | 0x312=786 0x315=789 0x318=792 0x31B=795<br />
# +-------------------------------------------------+<br />
<br />
# general configuration:<br />
timeout 5<br />
default 1<br />
color light-blue/black light-cyan/blue<br />
<br />
# boot sections follow<br />
# each is implicitly numbered from 1 in the order of appearance below<br />
#<br />
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.<br />
#<br />
#-*<br />
<br />
# (0) Arch Linux<br />
title Arch Linux [cpio]<br />
root (hd0,0)<br />
kernel /boot/vmlinuz26 root=/dev/sda6 ro vga=773<br />
initrd /boot/kernel26.img<br />
<br />
title Arch Linux [thinkpad]<br />
root (hd0,0)<br />
kernel /boot/vmlinuz26thinkpad root=/dev/sda6 ro video=vesafb:off acpi_sleep=s3_bios<br />
resume=swap:/dev/sda5<br />
initrd /boot/kernel26thinkpad.img<br />
<br />
Copy the mounts to mtab<br />
<br />
grep -v rootfs /proc/mounts > /etc/mtab<br />
<br />
== Installing or Restoring GRUB to the Master Boot Record ==<br />
GRUB may be installed from a live environment, or directly from a running Arch install.<br />
<br />
In either case, boot the system and run the '''grub''' command as root:<br />
# grub<br />
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:<br />
grub> root (hdx,x)<br />
(remember that /boot is GRUB's root)<br />
<br />
If you are unaware of the the location of /boot, use the '''find''' command to locate the GRUB files. <br />
<br />
The following example is for systems ''without'' a separate /boot partition, wherein /boot is merely a directory under / :<br />
grub> find /boot/grub/stage1<br />
The following example is for systems ''with'' a separate /boot partition:<br />
grub> find /grub/stage1<br />
<br />
Grub will find the file, and give an output showing the location of the stage1 file, (which resides under /boot). For example:<br />
(hd1,0)<br />
Use the root command, (with the output from the find command) to instruct GRUB which partition contains stage1, (and therefore, /boot):<br />
grub> root (hd1,0)<br />
Finally, (re)install GRUB to the MBR of the drive. The following example installs GRUB to the MBR of the drive containing /boot:<br />
grub> setup (hd1)<br />
NOTE: The above does NOT work with XFS partitions, for them, install to a partition as shown below.<br />
<br />
Use the '''quit''' command to quit GRUB:<br />
grub> quit<br />
* Alternative, installing to a partition.<br />
You may, of course, install GRUB anywhere you need it to be.<br />
<br />
For example:<br />
<br />
grub> setup (hd1,0) <br />
will install GRUB to the second harddisk, first partition.<br />
<br />
== Boot loader configuration ==<br />
The grub configuration is done in this file:<br />
/boot/grub/menu.lst<br />
<br />
* <i>(hdn,m)</i> is the partition m on disc n, numbers starting with 0<br />
* <i>splashimage (hdn,m)/grub/Name.xpm.gz</i> is the splash-image-file<br />
* <i>default n</i> is the default boot entry, that is choosen after timout for user action<br />
* <i>timeout m</i> time m to wait in seconds for a user selection, before default is booted<br />
* <i>password -md5 str</i> encrypted boot password 'str'<br />
* <i>title str</i> title string 'str' for a boot entry<br />
* <i>root (hdn,m)</i> base partition, where the kernel is stored to<br />
* <i>kernel /path ro root=/dev/device initrd /initrd.img</i> use the root option, if the kernel not placed in /<br />
* <i>makeactive<br>chainloader +1</i> sets root active and gives booting procedure to its boot-loader (for Windows, f.e.)<br />
* <i>map (hd0) (hd1)<br>map (hd1) (hd0)</i> changes primary and secondary disc for a boot, necessary to boot Windows from a secondary disc<br />
* <i>root (hdn,m,z)<br>kernel /boot/loader</i> boots the FreeBSD-Partition x<br />
* <i>default saved</i> 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.<br />
<br />
For those who like eye-candy, there is [[Graphical GRUB]].<br />
<br />
<br />
=== Dual booting===<br />
These are the two most common ways of configuring the menu.lst file. For more complex uses, click [[Grub configure examples|here]].<br />
====Dual booting with Windows====<br />
Add this at the end of your /boot/grub/menu.lst. This assumes that your Windows partition is [s/h]da2.<br />
<br />
# (2) Windows XP<br />
title Windows XP<br />
rootnoverify (hd0,1)<br />
makeactive<br />
chainloader +1<br />
<br />
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 [http://vlaurie.com/computers2/Articles/bootini.htm this article] for details on how to do that).<br />
<br />
====Dual booting with Windows on another hard disk====<br />
Add this at the end of your /boot/grub/menu.lst. This assumes that your Windows partition is [s/h]db1.<br />
<br />
# (2) Windows XP<br />
title Windows XP<br />
map (hd0) (hd1)<br />
map (hd1) (hd0)<br />
rootnoverify (hd1,0)<br />
makeactive<br />
chainloader +1<br />
<br />
The map function tricks your Windows install into thinking that a second hard drive is the primary.<br />
<br />
====Dual booting with other linux distros====<br />
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.<br />
title Other Linux<br />
root (hd0,2)<br />
kernel /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
<br />
====Dual booting with other linux distro (Chainloading)====<br />
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.<br />
<br />
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).<br />
-------------------------------------------------<br />
| | | | % (hd0,2) |<br />
| M | | | B % |<br />
| B | (hd0,0) | (hd0,1) | L % Other |<br />
| R | | | % Distro |<br />
| | | | % |<br />
-------------------------------------------------<br />
| ^<br />
| chainloading |<br />
-----------------------------<br />
<br />
Then, you simply use in your menu.lst:<br />
title Other Linux distro<br />
root (hd0,2)<br />
chainloader +1<br />
<br />
<br />
<br />
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.<br />
<br />
<br />
If you want to boot GRUB from a second harddisk, when GRUB is placed in the MBR of this second HDD, your menu.lst has to be like this:<br />
title Second Hard Disk<br />
rootnoverify (hd1)<br />
chainloader +1<br />
<br />
===Tips and tricks===<br />
<br />
Other details you may need/want to try.<br />
<br />
====Naming by Label====<br />
<br />
If you alter (or plan to alter) partition sizes from time to time, you might want to consider defining your drive/partition by a label. When the device is not mounted you can label it by:<br />
<br />
e2label </dev/drive|partition> label<br />
<br />
For ext2|3|4 filesystems. The label name can be up to 16 characters long (to have grub to understand it though don't use spaces). And put it in your {{Filename|menu.lst}}:<br />
<br />
kernel /boot/vmlinuz26 root=/dev/disk/by-label/Arch_Linux ro<br />
<br />
====Restart with named boot choice====<br />
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.<br />
<br />
Supposing a simple menu.lst setup like this:<br />
<br />
<pre><br />
# general configuration:<br />
timeout 10<br />
default 0<br />
color light-blue/black light-cyan/blue<br />
<br />
# (0) Arch<br />
title Arch Linux<br />
root (hd0,1)<br />
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/a29113d7-2204-49e9-be69-d94699eba466 ro<br />
initrd /boot/kernel26.img<br />
<br />
# (1) Windows<br />
title Microsoft Windows XP Pro<br />
rootnoverify (hd0,0)<br />
makeactive<br />
chainloader +1<br />
</pre><br />
<br />
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. <br />
<br />
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:<br />
<br />
sudo grub-set-default 1 && sudo shutdown -r now<br />
<br />
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).<br />
<br />
== LiLO and GRUB interaction ==<br />
<br />
If you once had used [[lilo]] Don't forget to remove it with <br />
pacman -R lilo<br />
as some tasks (f.e. kernel compilation using <code>make all</code>) will make a lilo call, and then lilo is installed over grub.<br />
Note that this will not remove lilo from the MBR, but it will be overwritten when you install another bootloader.<br />
<br />
== Framebuffer Resolution ==<br />
<br />
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.<br />
<br />
On [http://en.wikipedia.org/wiki/VESA_BIOS_Extensions#Linux_video_mode_numbers 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.<br />
<br />
So instead of using that table, i suggest using this method:<br />
<br />
=== How to find the correct code to use for the resolution you want to use ===<br />
# Install ''lrmi'' package from the '''[community]''' that has the ''vbetest'' tool (not available for 64bit arch, install [http://aur.archlinux.org/packages.php?ID=14977 hwinfo] '''[AUR]''' instead and run 'hwinfo --vbe').<br />
# 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 <tt>vbetest -m yournumberhere</tt> unless you are running a framebuffered console.<br />
# 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.<br />
# Press 'q' to quit ''vbetest'' interactive prompt. <br />
# Add 512 to the discovered ''vbetest value'' for you monitor size and use the total as code to use in <tt>vga=</tt> kernel option in menu.lst. For ''hwinfo'' copy the six digit code to the <tt>vga=</tt> option.<br />
# reboot and voilà !<br />
<br />
{{Box Note |If you want to test the resolution you have just picked up, you can run <tt>vbetest -m yournumberhere</tt> to test the resolution. You will see a checked colored image on your console. It will return to black after some second. If the text of your console is not restored you will have to switch to another console and switch back to have your text restored. (minor glitch)}}<br />
<br />
For example ''vbetest'' on one computer:<br />
[356] 1440x900 (256 color palette)<br />
[357] 1440x900 (8:8:8)<br />
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.<br />
kernel /vmlinuz26 root=/dev/sda1 ro '''vga=869'''<br />
On another desktop with ''hwinfo'':<br />
Mode 0x0364: 1440x900 (+1440), 8 bits<br />
Mode 0x0365: 1440x900 (+5760), 24 bits<br />
And the kernel line:<br />
kernel /vmlinuz26 root=/dev/sda1 ro '''vga=0x0365'''<br />
<br />
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)<br />
<br />
'''Note''':<br />
* (8:8:8) is for 24-bit color (or 32-bit ?)<br />
* (5:6:5) is for 16-bit color<br />
* (5:5:5) is for 15-bit color<br />
<br />
=== Alternative way to find the resolution code ===<br />
<br />
This is an easy way to find the resolution code using only grub itself.<br />
<br />
On the kernel line, specify that the kernel should ask you which mode to use.<br />
kernel /vmlinuz26 root=/dev/sda1 ro '''vga=ask'''<br />
<br />
Now reboot. Grub will now - as desired - present a list of suitable codes to use and the option to scan for even more.<br />
You can pick the code you would like to use (don't forget it, it is needed for the next step) and boot using it.<br />
The number you have picked here is the '''hexadecimal''' number, in order to use it at the kernel line you can transform it into a '''decimal''' number.<br />
<br />
Now replace '''ask''' in the kernel line with the correct one you have picked.<br />
<br />
E.g. the kernelline for ''[369] 1680x1050x32'' would be:<br />
kernel /vmlinuz26 root=/dev/sda1 ro '''vga=873'''<br />
<br />
== Troubleshooting ==<br />
<br />
===Fixing GRUB Error 17===<br />
If your partition table gets messed up, an unpleasant "GRUB error 17" message might be the only thing that greets you on your next reboot. There are a number of reasons why the partition table could get messed up. Commonly users who manipulate their partitions with [gparted] -- particularly logical drives -- can cause the order of the partitions to change. For example, you delete /dev/sda6 and resize /dev/sda7 a little bit, then finally re-create what used to be /dev/sda6 only now it goes down to the bottom of the list, /dev/sda9 for example. Although the physical order of the partitions/logical drives hasn't changed, the order in which they're recognized is messed up.<br />
<br />
Fixing the partition table is easy. Boot from your Arch CD, login as root and fix the partition table:<br />
<br />
# fdisk /dev/sda<br />
<br />
Once you're in disk, enter e[x]tra/expert mode, [f]ix the partition order, then [w]rite the table and exit. You'll do this by three keys, <br />
{{Keypress|X}}, {{Keypress|F}}, {{Keypress|W}}. Now exit fdisk. <br />
<br />
You can verify that the partition table was indeed fixed by issuing an fdisk -l. Now you just need to fix grub. See the [[http://wiki.archlinux.org/index.php/GRUB#Installing_or_Restoring_GRUB_to_the_Master_Boot_Record Installing_or_Restoring_GRUB_to_the_Master_Boot_Record]] section above.<br />
<br />
Basically you need to tell grub the correct location of your /boot then re-write grub to the MBR on the disk.<br />
<br />
Example on my system:<br />
<br />
# grub<br />
grub> root (hd0.6)<br />
grub> setup (hd0)<br />
grub> quit<br />
<br />
See [[http://stringofthoughts.wordpress.com/2009/05/24/grub-error-17-debianubuntu this page]] for a more in depth summary of this section.<br />
<br />
<br />
===Editing GRUB entries just before boot===<br />
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'''.<br />
<br />
<br />
===Reboot pulldown menu in KDE does not have any effect===<br />
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 <br />
<pre><br />
default saved<br />
</pre><br />
in file ''/boot/grub/menu.lst''.<br />
<br />
== External Resources ==<br />
* [http://www.gnu.org/software/grub/ GRUB Website]<br />
* [http://www.troubleshooters.com/linux/grub/index.htm GRUB Grotto- an excellent GRUB resource]<br />
* [http://www.mjmwired.net/kernel/Documentation/kernel-parameters.txt List of kernel parameters that can be used at boot time ]<br />
* [http://www.kernel.org/pub/linux/kernel/people/gregkh/lkn/lkn_pdf/ch09.pdf List of kernel paramaters with further explanation and grouped by like options ('Kernel Boot Command-Line Parameter Reference', ''Linux Kernel In A Nutshell'')]</div>Jimbeamhttps://wiki.archlinux.org/index.php?title=Software_access_point&diff=57233Software access point2009-01-06T13:59:54Z<p>Jimbeam: spelling</p>
<hr />
<div>[[Category:Communication and network (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
A software access point is used when you want your computer to act as an access point for the local wireless network. It saves you the trouble of getting a separate wireless router.<br />
<br />
=Things you need=<br />
<br />
You will need: <ul><li>prism2/2.5/3 pure pci wireless card<br />
<li>hostap-driver<br />
<li>network bridge support compiled in kernel<br />
<li>wireless-tools from pacman</ul><br />
<br />
=Steps to implement=<br />
<br />
<ol><li>get hostap from pacman, http://hostap.epitest.fi/ or http://shadowzerosoftware.ath.cx/hostap-drivers-0.4.7.tar.gz<br />
<li>untar, make, make install as root<br />
<li><pre>modprobe hostap_pci</pre> as root to make sure the module will insert right.<br />
<li>add <pre>alias wlan0 hostap_pci</pre> to /etc/modprobe.conf<br />
<li>add <pre><br />
wlan_wlan0="wlan0 mode master essid $YOUR_ESSID channel $CHANNEL"<br />
WLAN_INTERFACES=(wlan0)<br />
</pre> to /etc/conf.d/wireless You can also put key $KEY in wlan_wlan0="" to enable WEP. This automates commands to iwconfig.<br />
<li>add <pre><br />
bridge_br0="eth0 wlan0"<br />
BRIDGE_INTERFACES=(br0)<br />
</pre> to /etc/conf.d/bridges, this automated commands to the bridge module and brctl, the equiv would be <pre>brctl addbr br0;brctl addif eth0;brctl addif wlan0</pre>.<br />
<li>change the network settings in /etc/rc.conf to<pre><br />
<br />
lo="lo 127.0.0.1"<br />
eth0="eth0 up"<br />
wlan0="wlan0 up"<br />
br0="br0 $IP_ADDRESS netmask 255.255.255.0 up"<br />
INTERFACES=(lo eth0 wlan0 br0) <br />
</pre><br />
<li>run <pre>/etc/rc.d/network restart</pre> as root, or just reboot.<br />
</ol><br />
<br />
<br>This setup works for me to play Mario Kart DS through Nintendo's Wi-Fi Connection. br0 should be given the same settings in /etc/rc.conf eth0 had before. This works for me on kernel 2.6.13-ARCH, hostap-driver-0.4.7, wireless-tools version 28, and a Linksys WMP11 v4 wireless card. Any 802.11b device should be able to connect to this setup, as long as it supports manual ESSID and IP configuration. dhcpd should handle IPs as if it's in charge of a wired LAN, My DS would not automatically detect the ESSID, and I am not aware of a way to activate broadcasting ESSID. It connected just fine when told the ESSID to connect to. WPA seems to be supported by hostap, source files are on the same site as it. I didn't attempt to configure that, as I didn't need it. YMMV, RTFM, have fun.<br />
<br />
*UPDATE* The hostap-driver in pacman works, too. Thanks Xentac!<br />
<br />
*ANOTHER UPDATE* Hostap-driver is in the 2.6.15 kernel. Also, DCHP requests are passed to the wired connection through wireless, so dhcpd is not needed for this.</div>Jimbeam