https://wiki.archlinux.org/api.php?action=feedcontributions&user=Martadinata&feedformat=atomArchWiki - User contributions [en]2024-03-28T11:12:17ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Openbox&diff=241310Openbox2012-12-22T21:30:17Z<p>Martadinata: /* Xfce4 */</p>
<hr />
<div>[[Category:Stacking WMs]]<br />
[[cs:Openbox]]<br />
[[de:Openbox]]<br />
[[es:Openbox]]<br />
[[fr:Openbox]]<br />
[[it:Openbox]]<br />
[[ko:Openbox]]<br />
[[lt:Openbox]]<br />
[[nl:Openbox]]<br />
[[pl:Openbox]]<br />
[[ru:Openbox]]<br />
[[sk:Openbox]]<br />
[[sr:Openbox]]<br />
[[tr:Openbox]]<br />
[[zh-CN:Openbox]]<br />
[[zh-TW:Openbox]]<br />
{{Article summary start}}<br />
{{Article summary text|A comprehensive guide on the installation and use of the Openbox window manager.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Graphical user interface overview}}}}<br />
{{Article summary end}}<br />
<br />
Openbox is a lightweight and highly configurable [[Window Manager|window manager]] with extensive standards support. Its features are documented at the [http://openbox.org/ official website]. This article pertains to installing Openbox under Arch Linux.<br />
<br />
== Installation ==<br />
<br />
Install {{Pkg|openbox}}, available in the [[Official Repositories]]. After installation, you should copy the default configuration files {{ic|rc.xml}}, {{ic|menu.xml}}, {{ic|autostart}}, and {{ic|environment}} to {{ic|~/.config/openbox}}:<br />
<br />
{{Note | Do this as a regular user, not as root.}}<br />
<br />
$ mkdir -p ~/.config/openbox<br />
$ cp /etc/xdg/openbox/{rc.xml,menu.xml,autostart,environment} ~/.config/openbox<br />
<br />
These four files form the basis of your openbox configuration. Each file addresses a unique aspect of your configuration and the role of each file is as follows:<br />
<br />
; {{ic|rc.xml}}: This is the main configuration file. It defines keyboard shortcuts, themes, virtual desktops, and more.<br />
<br />
;{{ic|menu.xml}}: This file defines the content of the right-click menu. It defines launchers for applications and other shortcuts. See the [[#Menus]] section.<br />
<br />
;{{ic|autostart}}: This file is read by openbox-session at startup. It contains the programs that are run at startup. It is typically used to set environment variables, launch panels/docks, set background image or execute other startup scripts. See the [http://openbox.org/wiki/Help:Autostart Openbox Wiki].<br />
<br />
;{{ic|environment}}: This file is sourced by openbox-session at startup. It contains environment variables to be set in Openbox's context. Any variables you set here will be visible to Openbox itself and anything you start from its menus.<br />
<br />
== Upgrading to Openbox 3.5 ==<br />
<br />
If you are upgrading to Openbox 3.5 or later from an earlier release, be aware of these changes:<br />
<br />
* There is a new config file called {{ic|environment}} that you should copy from {{ic|/etc/xdg/openbox}} to {{ic|~/.config/openbox}}.<br />
* The config file previously called {{ic|autostart.sh}} is now just called {{ic|autostart}}. You should rename yours to remove the {{ic|.sh}} from the end of the name.<br />
* Some of the configuration grammar in {{ic|rc.xml}} has changed. While Openbox appears to understand the old options, it would be wise to compare your configuration to the one in {{ic|/etc/xdg/openbox}} and look for changes that affect you.<br />
<br />
== Openbox as a stand-alone WM ==<br />
<br />
Openbox can be used as a stand-alone window manager (WM). This is usually simpler to install and configure than using Openbox with desktop environments. Running openbox alone may reduce your system's CPU and memory load.<br />
<br />
To run Openbox as a stand-alone window manager, append the following to {{ic|~/.xinitrc}}:<br />
exec openbox-session<br />
<br />
See [[xinitrc]] for details, such as preserving the logind (and/or consolekit) session.<br />
<br />
If you used another window manager previously (such as Xfwm) and now Openbox will not start after logging out of X, try moving the autostart folder:<br />
mv ~/.config/autostart ~/.config/autostart.bak<br />
<br />
{{Note | {{pkg|python2-xdg}} is required for Openbox's xdg-autostart}}<br />
<br />
== Openbox as a WM for desktop environments ==<br />
<br />
Openbox can be used as a replacement window manager for full-fledged desktop environments. The method for deploying Openbox depends on the desktop environment.<br />
<br />
=== GNOME 2.24 and 2.26 ===<br />
Create {{ic|/usr/share/applications/openbox.desktop}} with the following lines:<br />
[Desktop Entry]<br />
Type=Application<br />
Encoding=UTF-8<br />
Name=OpenBox<br />
Exec=openbox<br />
NoDisplay=true<br />
# name of loadable control center module<br />
X-GNOME-WMSettingsModule=openbox<br />
# name we put on the WM spec check window<br />
X-GNOME-WMName=OpenBox<br />
In gconf, set {{ic|/desktop/gnome/session/required_components/windowmanager}} to {{ic|openbox}}:<br />
$ gconftool-2 -s -t string /desktop/gnome/session/required_components/windowmanager openbox<br />
Finally, choose the {{ic|GNOME}} session from the GDM sessions menu.<br />
<br />
=== GNOME 2.26 redux ===<br />
'''''If the previous guide for GNOME 2.24 fails:'''''<br />
<br />
If, when attempting to log into a "Gnome/Openbox" session -- and it consistently fails to start, try the following. This is one way of achieving your goal of using Openbox as the WM anytime you open a Gnome session:<br />
<br />
#Log into your Gnome-only session (it should still be using Metacity as its window manager).<br />
#Install Openbox if you have not done so already<br />
#Navigate your menus to ''System &rarr; Preferences &rarr; Startup Applications'' (possibly named 'Session' in older Gnome versions)<br />
#Open Startup Application, select '+ Add' and enter the text shown below. Omit the text after #.<br />
#Click the 'Add' button for the data entry window. Make sure the checkbox beside your new entry is selected.<br />
#Log out from your Gnome session and log back in<br />
#You should now be running openbox as your window manager.<br />
<br />
Name: Openbox Windox Manager # Can be changed<br />
Command: openbox --replace # Text should not be removed from this line, but possibly added to it<br />
Comment: Replaces metacity with openbox # Can be changed<br />
<br />
This creates a startup list entry which is executed by Gnome each time the user's session is started.<br />
<br />
=== KDE ===<br />
# If you use KDM, select the "KDE/Openbox" login option.<br />
# Open System Settings > Default Applications (in the Workspace Appearance and Behaviour section), and change the default window manager to Openbox (this will also avoid having to log out and log back in again).<br />
# If you use startx, add {{ic|exec openbox-kde-session}} to {{ic|~/.xinitrc}}<br />
# From the shell:<br />
$ xinit /usr/bin/openbox-kde-session<br />
<br />
=== Xfce4 ===<br />
Log into a normal Xfce4 session. From your terminal, type:<br />
$ killall xfwm4 ; openbox & exit<br />
<br />
This kills xfwm4, runs Openbox, and closes the terminal. Log out, being sure to check the ''"Save session for future logins"'' box. On your next login, Xfce4 should use '''Openbox''' as its window manager.<br />
<br />
Alternatively, you can chooose ''Settings'' -> ''Session and Startup'' from menu, go to the ''Application Autostart'' tab and add {{ic|openbox --replace}} to the list of automatically started applications.<br />
<br />
To enable exiting from a session using ''xfce4-session'', edit {{ic|~/.config/openbox/menu.xml}}. If the file is not there, copy it from {{ic|/etc/xdg/openbox/}}. Look for the following entry:<br />
<item label="Exit Openbox"><br />
<action name="Exit"><br />
<prompt>yes</prompt><br />
</action><br />
</item><br />
<br />
Change it to:<br />
<item label="Exit Openbox"><br />
<action name="Execute"><br />
<prompt>yes</prompt><br />
<command>xfce4-session-logout</command><br />
</action><br />
</item><br />
<br />
Otherwise, choosing "Exit" from the root-menu causes Openbox to terminate its execution, leaving you with no window manager.<br />
<br />
If you have a problem changing virtual desktops with the mouse wheel skipping over desktops, edit {{ic|~/.config/openbox/rc.xml}}. Move the ''mouse binds with...'' actions "DesktopPrevious" and "DesktopNext" from context ''Desktop'' to the context ''Root''. Note that you may need to create a definition for the ''Root'' context as well.<br />
<br />
When using the Openbox root-menu instead of Xfce's menu, you may exit the Xfdesktop with this terminal command:<br />
$ xfdesktop --quit<br />
Xfdesktop manages the wallpaper and desktop icons, requiring you to use other utilities such as ROX for these functions.<br />
<br />
(When terminating Xfdesktop, the above issue with the virtual desktops is no longer a problem.)<br />
<br />
If you want have rc.xml separated than your default openbox session rc.xml<br />
<br />
Edit the ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml or (to make the change for all XFCE users) /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml:<br />
Replace the xfwm startup command,<br />
<property name="Client0_Command" type="array"><br />
<value type="string" value="xfwm4"/><br />
</property><br />
with the following:<br />
<property name="Client0_Command" type="array"><br />
<value type="string" value="openbox"/><br />
<value type="string" value="--config-file"/><br />
<value type="string" value="~/.config/xfce4/openbox/rc.xml"/><br />
</property><br />
<br />
and also the menu, you can set the separated menu ex: xfce4-menu.xml , change it to your custom xfce4 rc.xml , but notice that the menu must be place at ~/.config/openbox/<br />
<br />
== Openbox for multihead users ==<br />
<br />
While Openbox provides better than average multihead support on its own, the {{AUR|openbox-multihead-git}} package from the [[AUR]] provides a development branch called '''Openbox Multihead''' that gives multihead users per-monitor desktops. This model is not commonly found in floating window managers, but exists mainly in tiling window managers. It is explained well on the [http://xmonad.org/tour.html#workspace Xmonad web site]. Also, please see [https://github.com/BurntSushi/openbox-multihead/blob/multihead/README.MULTIHEAD README.MULTIHEAD] for a more comprehensive description of the new features and configuration options found in Openbox Multihead.<br />
<br />
Openbox Multihead will function like normal Openbox when only a single head is available.<br />
<br />
A downside to using Openbox Multihead is that it breaks the EWMH assumption that one and only one desktop is visible at any time. Thus, existing pagers will not work well with it. To remedy this, {{AUR|pager-multihead}} can be found in the [[AUR]] and is compatible with Openbox Multihead. [http://imgur.com/a/cnZeq#y04nk Screenshots].<br />
<br />
Finally, a new version of [[PyTyle]] that will work with Openbox Multihead can also be found in the [[AUR]]: {{AUR|pytyle3-git}}.<br />
<br />
Both ''pytyle3'' and ''pager-multihead'' will work without Openbox Multihead if only one monitor is active.<br />
<br />
== Configuration ==<br />
<br />
There are several options for configuring Openbox settings:<br />
<br />
=== Manual configuration ===<br />
To configure Openbox manually, edit the {{ic|~/.config/openbox/rc.xml}} file with a text editor. The file has explanatory comments throughout, for more details about editing it see the [http://openbox.org/wiki/Help:Configuration Openbox wiki].<br />
<br />
=== ObConf ===<br />
[http://openbox.org/wiki/ObConf:About ObConf] is an Openbox configuration tool. It is used to set most common preferences such as themes, virtual desktops, window properties, and desktop margins. It can be installed with the {{Pkg|obconf}} package, available in the [[official repositories]].<br />
<br />
ObConf cannot configure keyboard shortcuts and certain other features. For these features edit {{ic|rc.xml}} manually. Alternatively, you can try {{AUR|obkey}} from the [[AUR]].<br />
<br />
=== Application customization ===<br />
<br />
Openbox allows per-application customizations. This lets you define rules for a given program. For example:<br />
* Start your web browser on a specific virtual desktop.<br />
* Open your terminal program with no window decorations (window chrome).<br />
* Make your bit-torrent client open at a given screen position.<br />
<br />
Per-application settings are defined in {{ic|~/.config/openbox/rc.xml}}. Instructions are in the file's comments. More details are found in the [http://openbox.org/wiki/Help:Applications Openbox wiki].<br />
<br />
== Menus ==<br />
<br />
The default Openbox menu includes a variety of menu items to get you started. Many of these items launch applications you do not want, have not installed yet, or never intend to install. You will surely want to customize '''{{ic|menu.xml}}''' at some point. There are a number of ways to do so.<br />
<br />
=== Manual configuration of menus ===<br />
<br />
You can edit {{ic|~/.config/openbox/menu.xml}} with a text editor. Many of the settings are self-explanatory. The article [http://openbox.org/wiki/Help:Menus Help:Menus] in the Openbox wiki has extensive details.<br />
<br />
=== Icons in the menu ===<br />
<br />
Since version 3.5.0 you can have icons next to your menu entries. To do that :<br />
# add <showIcons>yes</showIcons> in the <menu> section of the {{ic|rc.xml}} file<br />
# edit the menu entries in {{ic|menu.xml}} and add icons="<path>" like this :<br />
<menu id="apps-menu" label="SomeApp" icon="/home/user/.icons/application.png"><br />
<br />
then {{ic|openbox --reconfigure}} or {{ic|openbox --restart}} if the menus do not update properly.<br />
<br />
=== MenuMaker ===<br />
<br />
[http://menumaker.sourceforge.net/ MenuMaker] creates XML menus for several window managers including Openbox. MenuMaker searchs your computer for executable programs and creates a menu file from the result. It can be configured to exclude certain application types (GNOME, KDE, etc) if you desire. It can be installed with the {{Pkg|menumaker}} package available in the official repositories.<br />
<br />
Once installed, generate a menu file (named {{ic|menu.xml}}) by running the program.<br />
$ mmaker -v OpenBox3 # Will not overwrite an existing menu file.<br />
$ mmaker -vf OpenBox3 # Force option permits overwriting the menu file.<br />
$ mmaker --help # See the full set of options for MenuMaker.<br />
<br />
MenuMaker creates a comprehensive {{ic|menu.xml}}. You may edit this file by hand or regenerate it after installing software.<br />
<br />
=== Obmenu ===<br />
<br />
Obmenu is a menu editor for Openbox. This GUI application is the best choice for those who dislike editing XML code. Obmenu can be installed with the package {{Pkg|obmenu}}, available in the official repositories.<br />
<br />
Once installed, run {{ic|obmenu}} then add and remove applications as desired.<br />
<br />
==== Obm-xdg ====<br />
<br />
{{ic|obm-xdg}} is a command-line tool that comes with Obmenu. It generates a categorized sub-menu of installed GTK/GNOME applications.<br />
<br />
To use obm-xdg with other menus, add the following line to {{ic|~/.config/openbox/menu.xml}}:<br />
<menu execute="obm-xdg" id="xdg-menu" label="xdg"/><br />
<br />
Then add the following line under your ''root-menu'' entry where you want to have the menu appear:<br />
<menu id="xdg-menu"/><br />
<br />
Then run {{ic|openbox --reconfigure}} to refresh the Openbox menu. You should now see a sub-menu labeled '''xdg''' in your menu.<br />
<br />
To use obm-xdg by itself, create {{ic|~/.config/openbox/menu.xml}} and add these lines:<br />
<openbox_menu><br />
<menu execute="obm-xdg" id="root-menu" label="apps"/><br />
</openbox_menu><br />
<br />
{{Note|If you do not have GNOME installed, you need to install the package {{pkg|gnome-menus}} for obm-xdg.}}<br />
<br />
=== openbox-menu ===<br />
<br />
[http://mimasgpc.free.fr/openbox-menu_en.html Openbox-menu] uses [http://sourceforge.net/projects/lxde/files/menu-cache/ menu-cache] from the LXDE Project to create dynamic menus for Openbox.<br />
<br />
If you get an error while trying to open this menu try [[#Icons_in_the_menu|adding icons]] to the Openbox menu.<br />
<br />
It can be installed with the package {{AUR|openbox-menu}}, available in the [[AUR]].<br />
<br />
=== Python-based xdg menu script ===<br />
<br />
This script is found in Fedora's Openbox package. You have only to put the script somewhere and create a menu entry. The latest version of the script can be found [http://pkgs.fedoraproject.org/cgit/openbox.git/tree/xdg-menu here].<br />
<br />
Download the script from the above repository and Place int into any directory you want.<br />
<br />
Open {{ic|menu.xml}} with your text editor and add the following entry. Of course, you can modify the label as you see fit.<br />
<menu id="apps-menu" label="xdg-menu" execute="python2 /path/to/xdg-menu"/><br />
<br />
Save the file and run {{ic|openbox --reconfigure}}.<br />
<br />
{{Note|If you do not have GNOME installed, you need to install the package {{pkg|gnome-menus}} for xdg-menu.}}<br />
<br />
=== Openbox menu generator ===<br />
<br />
The Openbox menu generator can be installed with the package {{AUR|obmenugen-bin}}, available in the AUR. creates the menu file from {{ic|.desktop}} files. Obmenugen provides a text file which filters (hides) menu items using basic regular expressions.<br />
$ obmenugen # Create a menu file<br />
$ openbox --reconfigure # To see the menu you generated<br />
<br />
=== Pipe menus ===<br />
<br />
Like other window managers, Openbox allows for scripts to dynamically build menus (menus on-the-fly). Examples are system monitors, media player controls, or weather monitors. Pipe menu script examples are found in the [http://openbox.org/wiki/Openbox:Pipemenus Openbox:Pipemenus] page at Openbox's site.<br />
<br />
Some interesting pipe menus provided by Openbox users:<br />
* {{App|obfilebrowser|A pipe menu file browser.|http://xyne.archlinux.ca/projects/obfilebrowser/|{{AUR|obfilebrowser}}}}<br />
* {{App|wifi-pipe|A pipe menu for scanning and connecting to wireless hot spots using netcfg.|https://github.com/pbrisbin/wifi-pipe|{{AUR?|wifi-pipe}}}}<br />
* {{App|obdevicemenu|A pipe menu for managing removable devices using Udisks.|https://bbs.archlinux.org/viewtopic.php?id&#61;114702|{{AUR|obdevicemenu}}}}<br />
<br />
== Startup programs ==<br />
<br />
Openbox supports running programs at startup. This is provided by command '''openbox-session'''.<br />
<br />
=== Enabling autostart ===<br />
<br />
There are two ways to enable autostart:<br />
# When using startx or xinit to begin a session, edit {{ic|~/.xinitrc}}. Change the line that executes '''''openbox''''' to '''openbox-session'''.<br />
# When using GDM or KDM, selecting an ''Openbox'' session automatically runs the autostart script.<br />
<br />
=== Autostart script ===<br />
<br />
Openbox provides a system-wide startup script which applies to all users and is located at {{ic|/etc/xdg/openbox/autostart}}. A user may also create his own startup script to be executed after the system-wide script by creating the file {{ic|~/.config/openbox/autostart}}. This file is not provided by default and must be created by the user.<br />
<br />
Further instructions are available in the [http://openbox.org/wiki/Help:Autostart Help:Autostart] article at the official Openbox site.<br />
<br />
{{Note|The autostart files used to be named autostart.sh prior to OpenBox 3.5.0. While these scripts will presently still work, users who are upgrading are advised to drop the .sh extension.}}<br />
{{Note|All the programs in the autostart file should be run as daemons or run in the background,otherwise the items in {{ic|/etc/xdg/autostart/}} won't be started!}}<br />
<br />
=== Autostart directory ===<br />
<br />
Openbox also starts any *.desktop files in {{ic|/etc/xdg/autostart}} - this happens regardless of whether a user startup script is present. {{ic|nm-applet}}, for example, installs a file at this location, and may cause it to run twice for users with the usual {{ic|(sleep 3 && /usr/bin/nm-applet --sm-disable) &}} in their startup script. There is a discussion on managing the effects of this at [https://bbs.archlinux.org/viewtopic.php?pid=993738].<br />
<br />
== Themes and appearance ==<br />
<br />
{{Box||See the main article: [[Openbox Themes and Apps#Themes and appearance]]|#E5E5FF|#FCFCFC}}<br />
<br />
=== Openbox themes ===<br />
<br />
Themes control the appearance of windows, titlebars, and buttons. They also control menu appearance and on-screen display (OSD). Some Openbox themes can be installed with the package {{Pkg|openbox-themes}}, available in the [[official repositories]].<br />
<br />
=== Cursors, icons, wallpapers ===<br />
<br />
Xcursor themes can be installed with the package {{Pkg|xcursor-themes}}, available in the official repositories, or with other packages from such as {{Pkg|xcursor-bluecurve}}, {{Pkg|xcursor-vanilla-dmz}} or {{Pkg|xcursor-pinux}}. Many other themes can be found in the official repositories or the [[AUR]].<br />
<br />
Icon themes are also available in the repositories, for example {{Pkg|lxde-icon-theme}}, {{Pkg|tangerine-icon-theme}} or {{Pkg|gnome-icon-theme}} can be found in the official repositories with many more in the [[AUR]].<br />
<br />
Wallpapers are easily set with utilities such as [[Nitrogen]], [[Feh]] or {{ic|hsetroot}}.<br />
<br />
Please see [[Openbox Themes and Apps]] for information on these GUI customizations.<br />
<br />
== Recommended programs ==<br />
<br />
{{Box||See the main article: [[Openbox Themes and Apps#Recommended programs]]|#E5E5FF|#FCFCFC}}<br />
<br />
== Tips and tricks ==<br />
<br />
===Window snap behaviour===<br />
Windows 7 and other VMs supports a window behaviour to snap windows when they are moved to the edge of the screen. This effect can also be achieved through an Openbox keybinding. More information [http://ubuntuforums.org/showthread.php?t=1796793 here].<br />
<br />
=== File associations ===<br />
Because Openbox and the applications you use with it are not well-integrated you might run into the issues with your browser. Your browser may not know which program it is supposed to use for certain types of files.<br />
<br />
A package in the AUR called {{AUR|gnome-defaults-list}} contains a list of file-types and programs specific to the Gnome desktop. The list is installed to {{ic|/etc/gnome/defaults.list}}.<br />
<br />
Open this file with your text editor. Here you can replace a given application with the name of the program of your choosing. For example, replace '''totem''' with '''vlc''' or '''eog''' with '''mirage'''. Save the file to {{ic|~/.local/share/applications/defaults.list}}.<br />
<br />
Another way of setting file associations is to install package {{Pkg|perl-file-mimeinfo}} from the official repositories and invoke '''mimeopen''' like this:<br />
mimeopen -d /path/to/file<br />
You are asked which application to use when opening {{ic|/path/to/file}}:<br />
Please choose a default application for files of type text/plain<br />
1) notepad (wine-extension-txt)<br />
2) Leafpad (leafpad)<br />
3) OpenOffice.org Writer (writer)<br />
4) gVim (gvim)<br />
5) Other...<br />
Your answer becomes the default handler for that type of file. Mimeopen is installed as {{ic|/usr/bin/perlbin/vendor/mimetype}}.<br />
<br />
=== Copy and paste ===<br />
<br />
From a terminal {{Keypress|Ctrl+Ins}} for copy and {{keypress|Shift+Ins}} for paste.<br />
<br />
Also {{keypress|Ctrl+Shift+c}} for copy and '''mouse middle-click''' for paste (in terminals).<br />
<br />
Other applications most likely use the conventional keyboard shortcuts for copy and paste.<br />
<br />
=== Window transparency ===<br />
<br />
The program {{Pkg|transset-df}} is available in the official repositories. With ''transset-df'' you can enable window transparency on-the-fly.<br />
<br />
For instance by placing the following in the ''<mouse>'' section you can have your mouse adjust window transparency by scrolling while hovering over the title bar:<br />
{{hc|~/.config/openbox/rc.xml|<nowiki><br />
<context name="Titlebar"><br />
. . .<br />
<mousebind button="Up" action="Click"><br />
<action name= "Execute" ><br />
<execute>transset-df -p .2 --inc </execute><br />
</action><br />
</mousebind><br />
<mousebind button="Down" action="Click"><br />
<action name= "Execute" ><br />
<execute>transset-df -p .2 --dec </execute><br />
</action><br />
</mousebind><br />
. . .<br />
</context><br />
</nowiki>}}<br />
{{Warning|It appears to work only when no additional actions are defined within the action group.}}<br />
<br />
=== Xprop values for applications ===<br />
Xprop can be installed with the package {{Pkg|xorg-xprop}}, available in the official repositories. <br />
<br />
If you use per-application settings frequently, you might find this bash alias handy:<br />
<br />
alias xp='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""'<br />
<br />
To use, run {{ic|xp}} and click on the running program that you would like to define with per-app settings. The result displays only the info that Openbox requires, namely the {{ic|WM_WINDOW_ROLE}} and {{ic|WM_CLASS}} (name and class) values:<br />
$ xp<br />
WM_WINDOW_ROLE(STRING) = "roster"<br />
WM_CLASS(STRING) = "gajim.py", "Gajim.py"<br />
WM_CLASS(STRING) = "NAME", "CLASS"<br />
<br />
==== Xprop for Firefox ====<br />
<br />
For whatever reason, Firefox and like-minded equivalents ignore application rules (e.g. ''<desktop>'') unless {{ic|class&#61;"Firefox*"}} is used. This applies irrespective of whatever values {{ic|xprop}} may report for the program's {{ic|WM_CLASS}}.<br />
<br />
=== Linking the menu to a button ===<br />
<br />
Some people want to link the Openbox menu (or any menu) to an object. This is useful for creating a panel button to pop up a menu. Although Openbox does not provide this, a program called {{Pkg|xdotool}} simulates a keypress. Openbox can be configured to bind that keypress to the ''ShowMenu'' action.<br />
<br />
After installing ''xdotool'', add the following to the ''<keyboard>'' section:<br />
{{hc|~/.config/openbox/rc.xml|<nowiki><br />
<keybind key="A-C-q"><br />
<action name="ShowMenu"><br />
<menu>root-menu</menu><br />
</action><br />
</keybind><br />
</nowiki>}}<br />
Then execute {{ic|openbox --reconfigure}} or {{ic|openbox --restart}} to use the new configuration. The following command summons a menu at your cursor position. The command may given as-is, linked to an object, or placed in a script.<br />
$ xdotool key ctrl+alt+q<br />
<br />
Of course, change the key shortcut to your liking. Here is a snippet from a [[Tint2]] configuration file which pops up a menu when the clock area is clicked. Each key combination is set to open a menu within Openbox's {{ic|rc.xml}} configuration file. The right‑click menu is different from the left‑click menu:<br />
clock_rclick_command = xdotool key --clearmodifiers "ctrl+XF86PowerOff"<br />
clock_lclick_command = xdotool key --clearmodifiers "alt+XF86PowerOff"<br />
<br />
=== Urxvt in the background ===<br />
<br />
With Openbox, running a terminal as desktop background is easy. You will not need [[Wikipedia:Devil's Pie (software)|devilspie]] here.<br />
<br />
First you must enable transparency, open your {{ic|~/.Xdefaults}} file (if it does not exist yet, create it).<br />
URxvt*transparent:true<br />
URxvt*scrollBar:false<br />
URxvt*geometry:124x24 #I do not use the whole screen, if you want a full screen term do not bother with this and see below.<br />
URxvt*borderLess:true<br />
URxvt*foreground:Black #Font color. My wallpaper is White, you may wish to change this to White.<br />
<br />
Then add the following to the ''<applications>'' section:<br />
{{hc|~/.config/openbox/rc.xml|<nowiki><br />
<application name="urxvt"><br />
<decor>no</decor><br />
<focus>yes</focus><br />
<position><br />
<x>center</x><br />
<y>20</y><br />
</position><br />
<layer>below</layer><br />
<desktop>all</desktop><br />
<maximized>true</maximized> #Only if you want a full size terminal.<br />
</application><br />
</nowiki>}}<br />
The ''magic'' comes from the '''<layer>below</layer>''' line, which place the application under all others. Here [[Rxvt-unicode|urxvt]] is displayed on all desktops, change it to your convenience.<br />
<br />
{{Tip|Instead of using ''<application name&#61;"urxvt">'', you can use another name ("urxvt-bg" for example), and use the {{ic|-name}} option when starting uxrvt. That way, only the urxvt terminals which you choose to name {{ic|urxvt-bg}} would be captured and modified by the application rule in {{ic|rc.xml}}. For example:<br />
$ urxvt -name urxvt-bg<br />
}}<br />
====ToggleShowDesktop exception====<br />
<br />
If you use '''ToggleShowDesktop''' to minimize all your application and show the desktop it will also minimize the urxvt window. Several methods are available to bypass this, but none works properly:<br />
* one method is explained in this [https://bbs.archlinux.org/viewtopic.php?pid=865844#p865844 forum post]. This involves editing Urxvt's source code.<br />
{{Warning|This method seems to have been broken in a recent update, now leading to a memory leak when the patched Urxvt is run.}}<br />
* the best method is outlined [https://bbs.archlinux.org/viewtopic.php?pid=929792#p929792 here]. It still has a big disadvantage: it makes ''ToggleShowDesktop'' a one-way action, not restoring the other desktop applications when ''ToggleShowDesktop'' is run for a second time. It does create the opportunity to use a different terminal emulator than Urxvt, however.<br />
<br />
=== Switching between keyboard layouts ===<br />
If you don't want to use a separate program for managing keyboard layouts, you can manually configure X to switch layouts on certain key combinations. See [[Xorg#Switching_between_keyboard_layouts]] for instructions.<br />
<br />
=== Keyboard volume control ===<br />
====ALSA====<br />
If you use [[ALSA]] for sound, you can use the {{ic|amixer}} program (part of the {{Pkg|alsa-utils}} package) to adjust the sound volume. You can use Openbox's keybindings to map different shortcuts to actions. If you want to use the multimedia keys, but do not know their names, you could look at the [[Multimedia Keys]] page to find out.<br />
<br />
For example, add the following in the ''<keyboard>'' section:<br />
{{hc|~/.config/openbox/rc.xml|<nowiki><br />
<keybind key="W-Up"><br />
<action name="Execute"><br />
<command>amixer set Master 5%+</command><br />
</action><br />
</keybind><br />
</nowiki>}}<br />
This binds {{Keypress|Super+&uarr;}} to increase your master ALSA volume by 5%. Corresponding binding for volume down:<br />
{{hc|~/.config/openbox/rc.xml|<nowiki><br />
<keybind key="W-Down"><br />
<action name="Execute"><br />
<command>amixer set Master 5%-</command><br />
</action><br />
</keybind><br />
</nowiki>}}<br />
As another example you can also use the {{ic|XF86Audio*}} keybindings:<br />
{{hc|~/.config/openbox/rc.xml|<nowiki><br />
<keybind key="XF86AudioRaiseVolume"><br />
<action name="Execute"><br />
<command>amixer set Master 5%+ unmute</command><br />
</action><br />
</keybind><br />
<keybind key="XF86AudioLowerVolume"><br />
<action name="Execute"><br />
<command>amixer set Master 5%- unmute</command><br />
</action><br />
</keybind><br />
<keybind key="XF86AudioMute"><br />
<action name="Execute"><br />
<command>amixer set Master toggle</command><br />
</action><br />
</keybind><br />
</nowiki>}}<br />
The above example should work for the majority of multimedia keyboards. It should enable to raise, lower and mute the Master control of your audio device by using the respective multimedia keyboard keys. Notice also that in this example:<br />
<br />
* The "Mute" key should unmute the Master control if it is already in mute mode.<br />
* The "Raise" and "Lower" keys should unmute the Master control if it is in mute mode.<br />
<br />
====Pulseaudio====<br />
If you are using [[PulseAudio]] with ALSA as a backend the above keybinding are slightly different as {{ic|amixer}} must be told to use PulseAudio. As always, add the following to the ''<keyboard>'' section to get the proper behaviour:<br />
{{hc|~/.config/openbox/rc.xml|<nowiki><br />
<keybind key="XF86AudioRaiseVolume"><br />
<action name="Execute"><br />
<command>amixer -D pulse set Master 5%+ unmute</command><br />
</action><br />
</keybind><br />
<keybind key="XF86AudioLowerVolume"><br />
<action name="Execute"><br />
<command>amixer -D pulse set Master 5%- unmute</command><br />
</action><br />
</keybind><br />
<keybind key="XF86AudioMute"><br />
<action name="Execute"><br />
<command>amixer set Master toggle</command><br />
</action><br />
</keybind><br />
</nowiki>}}<br />
This keybindings should work for most of the systems. Other examples can be found [http://ubuntuforums.org/showthread.php?t=987149 here].<br />
<br />
== Troubleshooting Openbox 3.5 ==<br />
=== X server crashes ===<br />
Problems have been detected after upgrade to version 3.5, that the X server might crash in attempt to start Openbox, ending with this error message:<br />
(metacity:25137): GLib-WARNING **: In call to g_spawn_sync(), exit status of a child process \<br />
was requested but SIGCHLD action was set to SIG_IGN and ECHILD was received by waitpid(), so exit \<br />
status can't be returned. This is a bug in the program calling g_spawn_sync(); either do not request \<br />
the exit status, or do not set the SIGCHLD action.<br />
xinit: connection to X server lost<br />
waiting for X server to shut down<br />
In this particular case, some problem with '''metacity''' package has been identified as the cause of the X server crash issue. To solve the problem reinstall the {{Pkg|metacity}} and {{Pkg|compiz-decorator-gtk}} packages. If that does not solve the problem, try removing them.<br />
<br />
Also, plenty of similar cases have been found on the Internet, that not only metacity package might be causing the X server to crash.<br />
Thus, whatever else instead of metacity you get in the error output message, try to reinstall it (or remove if necessary) in an attempt to get rid of this X server crash.<br />
<br />
=== Autostarting unwanted applications in 3.5 ===<br />
If unwanted applications start with your Openbox session even though they are not listed in your {{ic|~/.config/openbox/autostart}}, check the {{ic|~/.config/autostart/}} directory, it might contain the residues from your previously used desktop environment (GNOME, KDE, etc.), and remove unwanted files.<br />
<br />
=== SSH agent no longer starting ===<br />
Whereas Openbox 3.4.x allowed launching an SSH agent from {{ic|~/.config/openbox/autostart}}, with 3.5 that no longer seems to work. You need to put the following code in {{ic|~/.config/openbox/environment}}:<br />
<br />
{{bc|<nowiki><br />
SSHAGENT="/usr/bin/ssh-agent"<br />
SSHAGENTARGS="-s"<br />
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then<br />
eval `$SSHAGENT $SSHAGENTARGS`<br />
trap "kill $SSH_AGENT_PID" 0<br />
fi<br />
</nowiki>}}<br />
<br />
=== Openbox not registering with D-Bus ===<br />
Just like with SSH agent, lots of people used to have D-Bus code in {{ic|~/.config/openbox/autostart}} - which no longer works (e.g. Thunar does not see any removable devices anymore).<br />
<br />
==See also==<br />
* [http://openbox.org/ Openbox Website] &ndash; The official website<br />
* [http://planetob.openmonkey.com/ Planet Openbox] &ndash; Openbox news portal<br />
* [http://www.box-look.org/ Box-Look.org] &ndash; A good resource for themes and related artwork<br />
* [https://bbs.archlinux.org/viewtopic.php?id=93126 Openbox Hacks and Configs Thread] @ Arch Linux Forums<br />
* [https://bbs.archlinux.org/viewtopic.php?id=45692 Openbox Screenshots Thread] @ Arch Linux Forums<br />
* [http://snott.net/linux/using-gnome3-with-openbox/ Using GNOME 3 with Openbox Tutorial]</div>Martadinatahttps://wiki.archlinux.org/index.php?title=Android&diff=231388Android2012-10-25T04:02:42Z<p>Martadinata: /* Setting up Netbeans */</p>
<hr />
<div>[[Category:Development]]<br />
[[it:Android]]<br />
[[ru:Android]]<br />
[[zh-CN:Android]]<br />
== Android Development on Arch ==<br />
=== Getting SDK and IDE plugins ===<br />
<br />
(If you are running Arch64, you have to enable [[Arch64_FAQ#Multilib_Repository_-_Multilib_Project | the multilib repo]], to be able to to install the required dependencies using [[pacman]].)<br />
<br />
Install core SDK components from [[Arch User Repository|AUR]]:<br />
<br />
# {{AUR|android-sdk}}<br />
# {{AUR|android-sdk-platform-tools}}<br />
<br />
Typical installation location is {{Ic|/opt/android-sdk}}.<br />
<br />
When using [[Eclipse]] as an IDE you need to install the ADT plugin and related packages. If you get a message about unresolvable dependencies, install [[Java]] manually and try again. Alternatively you can use [[Netbeans]] for development after installing living and usually up to date plugin according to [http://www.nbandroid.org/p/installation.html this instructions].<br />
<br />
==== Setting up Eclipse ====<br />
Most stuff required for Android development in Eclipse is already packaged in AUR:<br />
<br />
Official plugin by Google &ndash; [http://developer.android.com/sdk/eclipse-adt.html Eclipse ADT]:<br />
# {{AUR|eclipse-android}}<br />
<br />
Dependencies:<br />
# {{AUR|eclipse-emf}}<br />
# {{AUR|eclipse-gef}}<br />
# {{AUR|eclipse-wtp}}<br />
<br />
Enter the path to the Android SDK Location in<br />
<br />
Windows -> Preferences -> Android<br />
<br />
==== Setting up Netbeans ====<br />
If you prefer using Netbeans as your IDE and want to develop Android applications, download the [http://www.nbandroid.org nbandroid] by going to:<br />
<br />
Tools -> Plugins -> Settings<br />
<br />
Add the following URL: http://kenai.com/projects/nbandroid/downloads/download/updatecenter/updates.xml<br />
<br />
<br />
Then go to '''Available Plugins''' and install the '''Android''' and '''Android Test Runner''' plugins for your IDE version. Once you have installed go to:<br />
<br />
if you have problem with netbeans 7.2 "org.netbeans.modules.gsf.testrunner was needed and not found." Please remove the the '''Android''' and '''Android Test Runner''' , then change the url of nbandroid to: http://nbandroid.org/release72/updates/updates.xml , update the sources and you just need to install the '''Android''' only.<br />
<br />
Tools -> Options -> Miscellaneous -> Android<br />
<br />
and select the path where the SDK is installed. That's it, now you can create a new Android project and start developing using Netbeans.<br />
<br />
=== Android platforms ===<br />
Before developing android applications, you need to install at least one Android platform, which can be done either automatically or manually.<br />
<br />
==== Automatic installation ====<br />
Automatic installation is done via the Android SDK and device manager, which is accessible by invoking (assuming that the {{Ic|$PATH}} [[Environment Variables|variable]] contains the path to the Android SDK {{ic|tools}} directory):<br />
android<br />
<br />
or alternatively:<br />
./<path_to_android-sdk>/tools/android<br />
<br />
If the automatic installation errors out, then you must either run the android tool with heightened privileges or set your user account as the owner of the directory. To change the owner ID for all SDK directories, run the following command as root:<br />
chown -R USER /opt/android-sdk<br />
<br />
To change the group ID instead (recommended for multiple users), first create the group, perhaps called ''android'', and add your user account to it:<br />
groupadd android<br />
gpasswd -a USER android<br />
Next, change the directory permissions:<br />
chgrp -R android /opt/android-sdk<br />
chmod -R g+w /opt/android-sdk<br />
find /opt/android-sdk -type d -exec chmod g+s {} \;<br />
The final command sets the ''setgid'' bit on all subdirectories so that any new files created within them will inherit the proper group ID.<br />
<br />
For step-by-step automatic installation, see: [http://developer.android.com/sdk/adding-components.html Installing SDK Components].<br />
<br />
==== Getting from AUR ====<br />
AUR currently contains multiple packages with Android platforms sometimes duplicating each other and/or having incorrect file permissions set. All are listed at <br />
{{AUR|android-sdk}} page (see dependent packages list).<br />
<br />
==== Manual installation ====<br />
For manual installation:<br />
# Download the platform you want to develop on. [http://qdevarena.blogspot.com/2010/05/download-android-sdk-standalone-for.html This site] provides online links to several Android SDK components.<br />
# Extract the tarball to {{ic|/<path_to_android-sdk>/platforms}}.<br />
<br />
Now, you should see the platform of your choice installed in the Installed Packages window of the Android SDK and device manager.<br />
<br />
=== Android Debug Bridge (ADB) - Connecting to a real device ===<br />
To get ADB to connect to a real device or phone under Arch, you must install the [[udev]] rules to connect the device to the proper {{Ic|/dev/}} entries.<br />
<br />
==== Using existing rules ====<br />
Install the AUR package {{AUR|android-udev}} to get a common list of vendor IDs. If [[#Does It Work?|ADB recognizes your device]] (it is visible and accessible in IDE), you are done. Otherwise see instructions below.<br />
<br />
==== Figure Out Your Device Ids ====<br />
Each Android device has a USB vendor/product ID. An example for HTC Evo is:<br />
vendor id: 0bb4<br />
product id: 0c8d<br />
<br />
Plug in your device and execute:<br />
# lsusb<br />
<br />
It should come up something like this:<br />
Bus 002 Device 006: ID 0bb4:0c8d High Tech Computer Corp.<br />
<br />
==== Adding udev Rules ====<br />
Use the rules from [http://source.android.com/source/initializing.html#configuring-usb-access Android developer] or you can use the following template for your udev rules, just replace [VENDOR ID] and [PRODUCT ID] with yours. Copy these rules into {{ic|/etc/udev/rules.d/51-android.rules}}:<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|2=<nowiki>SUBSYSTEM=="usb", ATTR{idVendor}=="[VENDOR ID]", MODE="0666"<br />
SUBSYSTEM=="usb",ATTR{idVendor}=="[VENDOR ID]",ATTR{idProduct}=="[PRODUCT ID]",SYMLINK+="android_adb"<br />
SUBSYSTEM=="usb",ATTR{idVendor}=="[VENDOR ID]",ATTR{idProduct}=="[PRODUCT ID]",SYMLINK+="android_fastboot"</nowiki>}}<br />
<br />
Then, to reload your new udev rules, execute:<br />
# udevadm control --reload-rules<br />
<br />
==== Does It Work? ====<br />
<br />
After you have setup the udev rules, unplug your device and replug it.<br />
<br />
After running:<br />
$ adb devices<br />
<br />
you should see something like:<br />
List of devices attached <br />
HT07VHL00676 device<br />
<br />
If you do not have the '''adb''' program (usually available in {{Ic|/opt/android-sdk/platform-tools/}}), it means you have not installed the platform tools.<br />
<br />
If you are getting an empty list (your device isn't there), it may be because you have not enabled USB debugging on your device. You can do that by going to Settings => Applications => Development and enabling USB debugging.<br />
<br />
{{Tip|Make sure that your user is added to the group:<br />
# gpasswd -a ''username'' adbusers<br />
}}<br />
<br />
=== Tools specific to NVIDIA Tegra platform ===<br />
<br />
If you target your application at NVIDIA Tegra platform, you might also want to install tools, samples and documentation provided by NVIDIA. In [http://developer.nvidia.com/category/zone/mobile-development NVIDIA Developer Zone for Mobile] there are two packages - [http://developer.nvidia.com/tegra-resources Tegra Android Development Pack], available from AUR as {{AUR|tegra-devpack}} and [http://developer.nvidia.com/tegra-resources Tegra Toolkit], available from AUR as {{AUR|tegra-toolkit}}.<br />
<br />
The {{AUR|tegra-toolkit}} package provides tools (mostly CPU and GPU optimization related), samples and documentation, while the {{AUR|tegra-devpack}} provides tools (NVIDIA Debug Manager) related to [http://developer.android.com/sdk/eclipse-adt.html Eclipse ADT] and their documentation.<br />
<br />
== Tethering ==<br />
See [[Android_Tethering]]<br />
<br />
== Building Android ==<br />
<br />
To build android, you need to install these packages.<br />
<br />
For 32 bits or 64 bits systems<br />
<br />
git gnupg flex bison gperf sdl wxgtk squashfs-tools curl ncurses zlib schedtool openjdk6 perl-switch zip unzip<br />
<br />
Only for 64 bits systems<br />
<br />
lib32-zlib lib32-ncurses lib32-readline gcc-libs-multilib gcc-multilib lib32-gcc-libs<br />
<br />
And you need to change the default python from version 3 to version 2<br />
<br />
$ sudo rm /usr/bin/python<br />
$ sudo ln -s /usr/bin/python2 /usr/bin/python<br />
<br />
Download the '''repo''' utility.<br />
<br />
$ mkdir ~/bin<br />
$ export PATH=~/bin:$PATH<br />
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo<br />
$ chmod a+x ~/bin/repo<br />
<br />
Create a directory to build.<br />
<br />
$ mkdir ~/android<br />
$ cd ~/android<br />
<br />
Synchronize the repositories.<br />
<br />
$ repo init -u https://android.googlesource.com/platform/manifest (checkout the master)<br />
$ repo sync<br />
<br />
Wait a lot. <br />
<br />
When finished, start building.<br />
<br />
$ source build/envsetup.sh<br />
$ lunch full-eng<br />
$ make -j4<br />
<br />
If you run '''lunch''' without arguments, it will ask what build you want to create. Use -j with a number between the number of cores and 2 * number of cores.<br />
<br />
The build takes a lot of time.<br />
<br />
When finished, run the final image.<br />
<br />
$ emulator<br />
<br />
== Tips & Tricks ==<br />
=== During Debugging "Source not found" ===<br />
Most probably the debugger wants to step into the Java code. As the source code of Android does not come with the Android SDK, this leads to an error. The best solution is to use step filters to not jump into the Java source code. Step filters are not activated by default. To activate them: <br />
Window -> Preferences -> Java -> Debug -> Step Filtering<br />
Consider to select them all. If appropriate you can add the android.* package. See the forum post for more information: http://www.eclipsezone.com/eclipse/forums/t83338.rhtml<br />
<br />
=== Linux distribution on the sdcard ===<br />
You can install Debian like in this [http://forum.xda-developers.com/showthread.php?t=631389 thread]. Excellent guide to installing Arch in chroot (in parallel with Android) can be found on [http://archlinuxarm.org/forum/viewtopic.php?f=27&t=1361&start=40 archlinuxarm.org forum].<br />
<br />
=== Android SDK on Arch 64 ===<br />
When using the Android SDK and the Eclipse plugin on a 64 bit system, and the 'emulator' always crashes with a segfault, do the following:<br />
Provide a localtime file in /usr/share/zoneinfo/localtime e.g.: <br />
sudo cp /usr/share/zoneinfo/Europe/Berlin /usr/share/zoneinfo/localtime<br />
<br />
=== Better MTPFS Support ===<br />
If you have an Android device that doesn't support UMS and you find mtpfs to be extremely slow you can install {{AUR|jmtpfs}} from the AUR.</div>Martadinatahttps://wiki.archlinux.org/index.php?title=Android&diff=231345Android2012-10-25T00:14:51Z<p>Martadinata: /* Setting up Netbeans */</p>
<hr />
<div>[[Category:Development]]<br />
[[it:Android]]<br />
[[ru:Android]]<br />
[[zh-CN:Android]]<br />
== Android Development on Arch ==<br />
=== Getting SDK and IDE plugins ===<br />
<br />
(If you are running Arch64, you have to enable [[Arch64_FAQ#Multilib_Repository_-_Multilib_Project | the multilib repo]], to be able to to install the required dependencies using [[pacman]].)<br />
<br />
Install core SDK components from [[Arch User Repository|AUR]]:<br />
<br />
# {{AUR|android-sdk}}<br />
# {{AUR|android-sdk-platform-tools}}<br />
<br />
Typical installation location is {{Ic|/opt/android-sdk}}.<br />
<br />
When using [[Eclipse]] as an IDE you need to install the ADT plugin and related packages. If you get a message about unresolvable dependencies, install [[Java]] manually and try again. Alternatively you can use [[Netbeans]] for development after installing living and usually up to date plugin according to [http://www.nbandroid.org/p/installation.html this instructions].<br />
<br />
==== Setting up Eclipse ====<br />
Most stuff required for Android development in Eclipse is already packaged in AUR:<br />
<br />
Official plugin by Google &ndash; [http://developer.android.com/sdk/eclipse-adt.html Eclipse ADT]:<br />
# {{AUR|eclipse-android}}<br />
<br />
Dependencies:<br />
# {{AUR|eclipse-emf}}<br />
# {{AUR|eclipse-gef}}<br />
# {{AUR|eclipse-wtp}}<br />
<br />
Enter the path to the Android SDK Location in<br />
<br />
Windows -> Preferences -> Android<br />
<br />
==== Setting up Netbeans ====<br />
If you prefer using Netbeans as your IDE and want to develop Android applications, download the [http://www.nbandroid.org nbandroid] by going to:<br />
<br />
Tools -> Plugins -> Settings<br />
<br />
Add the following URL: http://kenai.com/projects/nbandroid/downloads/download/updatecenter/updates.xml<br />
<br />
<br />
Then go to '''Available Plugins''' and install the '''Android''' and '''Android Test Runner''' plugins for your IDE version. Once you have installed go to:<br />
<br />
if you have problem with netbeans 7.2 "org.netbeans.modules.gsf.testrunner was needed and not found."<br />
change the url of nbandroid to: http://nbandroid.org/release72/updates/updates.xml <br />
<br />
Tools -> Options -> Miscellaneous -> Android<br />
<br />
and select the path where the SDK is installed. That's it, now you can create a new Android project and start developing using Netbeans.<br />
<br />
=== Android platforms ===<br />
Before developing android applications, you need to install at least one Android platform, which can be done either automatically or manually.<br />
<br />
==== Automatic installation ====<br />
Automatic installation is done via the Android SDK and device manager, which is accessible by invoking (assuming that the {{Ic|$PATH}} [[Environment Variables|variable]] contains the path to the Android SDK {{ic|tools}} directory):<br />
android<br />
<br />
or alternatively:<br />
./<path_to_android-sdk>/tools/android<br />
<br />
If the automatic installation errors out, then you must either run the android tool with heightened privileges or set your user account as the owner of the directory. To change the owner ID for all SDK directories, run the following command as root:<br />
chown -R USER /opt/android-sdk<br />
<br />
To change the group ID instead (recommended for multiple users), first create the group, perhaps called ''android'', and add your user account to it:<br />
groupadd android<br />
gpasswd -a USER android<br />
Next, change the directory permissions:<br />
chgrp -R android /opt/android-sdk<br />
chmod -R g+w /opt/android-sdk<br />
find /opt/android-sdk -type d -exec chmod g+s {} \;<br />
The final command sets the ''setgid'' bit on all subdirectories so that any new files created within them will inherit the proper group ID.<br />
<br />
For step-by-step automatic installation, see: [http://developer.android.com/sdk/adding-components.html Installing SDK Components].<br />
<br />
==== Getting from AUR ====<br />
AUR currently contains multiple packages with Android platforms sometimes duplicating each other and/or having incorrect file permissions set. All are listed at <br />
{{AUR|android-sdk}} page (see dependent packages list).<br />
<br />
==== Manual installation ====<br />
For manual installation:<br />
# Download the platform you want to develop on. [http://qdevarena.blogspot.com/2010/05/download-android-sdk-standalone-for.html This site] provides online links to several Android SDK components.<br />
# Extract the tarball to {{ic|/<path_to_android-sdk>/platforms}}.<br />
<br />
Now, you should see the platform of your choice installed in the Installed Packages window of the Android SDK and device manager.<br />
<br />
=== Android Debug Bridge (ADB) - Connecting to a real device ===<br />
To get ADB to connect to a real device or phone under Arch, you must install the [[udev]] rules to connect the device to the proper {{Ic|/dev/}} entries.<br />
<br />
==== Using existing rules ====<br />
Install the AUR package {{AUR|android-udev}} to get a common list of vendor IDs. If [[#Does It Work?|ADB recognizes your device]] (it is visible and accessible in IDE), you are done. Otherwise see instructions below.<br />
<br />
==== Figure Out Your Device Ids ====<br />
Each Android device has a USB vendor/product ID. An example for HTC Evo is:<br />
vendor id: 0bb4<br />
product id: 0c8d<br />
<br />
Plug in your device and execute:<br />
# lsusb<br />
<br />
It should come up something like this:<br />
Bus 002 Device 006: ID 0bb4:0c8d High Tech Computer Corp.<br />
<br />
==== Adding udev Rules ====<br />
Use the rules from [http://source.android.com/source/initializing.html#configuring-usb-access Android developer] or you can use the following template for your udev rules, just replace [VENDOR ID] and [PRODUCT ID] with yours. Copy these rules into {{ic|/etc/udev/rules.d/51-android.rules}}:<br />
<br />
{{hc|/etc/udev/rules.d/51-android.rules|2=<nowiki>SUBSYSTEM=="usb", ATTR{idVendor}=="[VENDOR ID]", MODE="0666"<br />
SUBSYSTEM=="usb",ATTR{idVendor}=="[VENDOR ID]",ATTR{idProduct}=="[PRODUCT ID]",SYMLINK+="android_adb"<br />
SUBSYSTEM=="usb",ATTR{idVendor}=="[VENDOR ID]",ATTR{idProduct}=="[PRODUCT ID]",SYMLINK+="android_fastboot"</nowiki>}}<br />
<br />
Then, to reload your new udev rules, execute:<br />
# udevadm control --reload-rules<br />
<br />
==== Does It Work? ====<br />
<br />
After you have setup the udev rules, unplug your device and replug it.<br />
<br />
After running:<br />
$ adb devices<br />
<br />
you should see something like:<br />
List of devices attached <br />
HT07VHL00676 device<br />
<br />
If you do not have the '''adb''' program (usually available in {{Ic|/opt/android-sdk/platform-tools/}}), it means you have not installed the platform tools.<br />
<br />
If you are getting an empty list (your device isn't there), it may be because you have not enabled USB debugging on your device. You can do that by going to Settings => Applications => Development and enabling USB debugging.<br />
<br />
{{Tip|Make sure that your user is added to the group:<br />
# gpasswd -a ''username'' adbusers<br />
}}<br />
<br />
=== Tools specific to NVIDIA Tegra platform ===<br />
<br />
If you target your application at NVIDIA Tegra platform, you might also want to install tools, samples and documentation provided by NVIDIA. In [http://developer.nvidia.com/category/zone/mobile-development NVIDIA Developer Zone for Mobile] there are two packages - [http://developer.nvidia.com/tegra-resources Tegra Android Development Pack], available from AUR as {{AUR|tegra-devpack}} and [http://developer.nvidia.com/tegra-resources Tegra Toolkit], available from AUR as {{AUR|tegra-toolkit}}.<br />
<br />
The {{AUR|tegra-toolkit}} package provides tools (mostly CPU and GPU optimization related), samples and documentation, while the {{AUR|tegra-devpack}} provides tools (NVIDIA Debug Manager) related to [http://developer.android.com/sdk/eclipse-adt.html Eclipse ADT] and their documentation.<br />
<br />
== Tethering ==<br />
See [[Android_Tethering]]<br />
<br />
== Building Android ==<br />
<br />
To build android, you need to install these packages.<br />
<br />
For 32 bits or 64 bits systems<br />
<br />
git gnupg flex bison gperf sdl wxgtk squashfs-tools curl ncurses zlib schedtool openjdk6 perl-switch zip unzip<br />
<br />
Only for 64 bits systems<br />
<br />
lib32-zlib lib32-ncurses lib32-readline gcc-libs-multilib gcc-multilib lib32-gcc-libs<br />
<br />
And you need to change the default python from version 3 to version 2<br />
<br />
$ sudo rm /usr/bin/python<br />
$ sudo ln -s /usr/bin/python2 /usr/bin/python<br />
<br />
Download the '''repo''' utility.<br />
<br />
$ mkdir ~/bin<br />
$ export PATH=~/bin:$PATH<br />
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo<br />
$ chmod a+x ~/bin/repo<br />
<br />
Create a directory to build.<br />
<br />
$ mkdir ~/android<br />
$ cd ~/android<br />
<br />
Synchronize the repositories.<br />
<br />
$ repo init -u https://android.googlesource.com/platform/manifest (checkout the master)<br />
$ repo sync<br />
<br />
Wait a lot. <br />
<br />
When finished, start building.<br />
<br />
$ source build/envsetup.sh<br />
$ lunch full-eng<br />
$ make -j4<br />
<br />
If you run '''lunch''' without arguments, it will ask what build you want to create. Use -j with a number between the number of cores and 2 * number of cores.<br />
<br />
The build takes a lot of time.<br />
<br />
When finished, run the final image.<br />
<br />
$ emulator<br />
<br />
== Tips & Tricks ==<br />
=== During Debugging "Source not found" ===<br />
Most probably the debugger wants to step into the Java code. As the source code of Android does not come with the Android SDK, this leads to an error. The best solution is to use step filters to not jump into the Java source code. Step filters are not activated by default. To activate them: <br />
Window -> Preferences -> Java -> Debug -> Step Filtering<br />
Consider to select them all. If appropriate you can add the android.* package. See the forum post for more information: http://www.eclipsezone.com/eclipse/forums/t83338.rhtml<br />
<br />
=== Linux distribution on the sdcard ===<br />
You can install Debian like in this [http://forum.xda-developers.com/showthread.php?t=631389 thread]. Excellent guide to installing Arch in chroot (in parallel with Android) can be found on [http://archlinuxarm.org/forum/viewtopic.php?f=27&t=1361&start=40 archlinuxarm.org forum].<br />
<br />
=== Android SDK on Arch 64 ===<br />
When using the Android SDK and the Eclipse plugin on a 64 bit system, and the 'emulator' always crashes with a segfault, do the following:<br />
Provide a localtime file in /usr/share/zoneinfo/localtime e.g.: <br />
sudo cp /usr/share/zoneinfo/Europe/Berlin /usr/share/zoneinfo/localtime<br />
<br />
=== Better MTPFS Support ===<br />
If you have an Android device that doesn't support UMS and you find mtpfs to be extremely slow you can install {{AUR|jmtpfs}} from the AUR.</div>Martadinatahttps://wiki.archlinux.org/index.php?title=GRUB_(Bahasa_Indonesia)&diff=189425GRUB (Bahasa Indonesia)2012-03-14T01:06:32Z<p>Martadinata: /* During Arch Linux installation */</p>
<hr />
<div>[[Category:Boot loaders (English)]]<br />
{{i18n|GRUB2}}<br />
[[fr:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|GRUB2 adalah generasi terbaru dari grub.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Burg}} - Burg adalah boot loader baru yang berdasar atas GRUB2. Yang menggunakan format object dimana hal ini membuat BURG dapat di gunakan di berbagai Operating System termasuk Linux/Windows/OSX/Solaris/FreeBSD, dll. Juga mempunyai tampilan untuk di konfigurasi yang unik baik melalui text mode atau GUI mode.<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/ GRUB2] generasi berikutnya dari GRUB. GRUB2 adalah derivasi dari [http://www.nongnu.org/pupa/ PUPA] yang merupakan proyek pengembangand dari GRUB. GRUB 2 telah di tulis ulang untuk membersihkan segalanya dan memberikan modularitas dan portabilitas. [http://www.gnu.org/software/grub/grub-faq.en.html#q1].<br />
<br />
Secara singkat, ''bootloader'' adalah program software pertama yang berjalan ketika komputer pertama dinyalakan. ''Bootloader'' bertanggung jawab sebagai pemicu dan pengirim kontrol ke Kernel Linux. Kernel, selanjutnya, menginisialisasi seluruh sistem operasi.<br />
<br />
{{Note|grub2 dari 1.99 dan selanjutnya telah mendukung btrfs sebagai root (tanpa /boot filesistem yang terpisah), tetapi tingkat kompresinya terbatas pada zlib, tidak LZO. Dukungan kompresi LZO hanya terdapat pada repo bzr upstream.}}<br />
<br />
{{Note|Penginstall standar AIF (Arch Installation Framework) berdasar pada [[Archiso]] tidak mendukung penginstallan grub2-bios atau grub2-uefi. Akan tetapi [[Archboot]] iso mendukung penginstallan grub2-bios dan grub2-uefi.}}<br />
<br />
== Prefasi ==<br />
<br />
Walaupun, [[GRUB]] (versi 0.9x) adalah bootloader standar Arch Linux, GRUB dapat diganti menjadi 'grub legacy' by upstream. Dimana telah menjadi GRUB2 dan [[Syslinux]] di beberapa distribusi. Versi lanjutan merekomendasikan GRUB2 >=1.99 di atas versi grub-legacy.<br />
<br />
=== Catatan untuk pengguna GRUB Legacy ===<br />
<br />
* Ada perbedaan perinta dari GRUB dan GRUB2. Perlu di lihat terlebih dahulu [http://www.gnu.org/software/grub/manual/grub.html#Commands GRUB2 commands] sebelum melanjutkan (contoh : "find" telah di ganti dengan "search").<br />
<br />
* GRUB2 sekarang ''modular'' dan tidak lagi memerlukan "stage 1.5". Sebagai hasilnya, bootloader itu sendiri menjadi terbatas -- modul-modul diambil dari hard disk sebagai kebutuhan untuk meluaskan fungsionalitas. (contoh : dukungan untuk [[LVM]] atau RAID).<br />
<br />
* Penamaan perangkat telah berubah antara GRUB dan GRUB2. Partisi diurut dari nomor 1 dari pada 0 ketika disk masih bernomor 0. Sebagai contoh, {{ic|/dev/sda1}} akan menjadi {{ic|(hd0,msdos1)}} (untuk MBR) atau {{ic|(hd0,gpt1)}} (for GPT) ketika GRUB2 dipakai.<br />
<br />
=== Kebutuhan GRUB2 ===<br />
<br />
==== System BIOS ====<br />
<br />
===== Instruksi spesifik untuk [[GPT]] =====<br />
<br />
GRUB2 di konfigurasi BIOS-GPT membutuhkan sebuah Partisi BIOS Boot yang terembed pada core.img di kehilangannya post-MBR di sistem yang terpartisi secara GPT (yang menyebabkan MBR diambil alih oleh GPT Primary Header dan Primary Partition table). Partisi ini digunakan oleh GRUB2 hanya pada pengaturan BIOS-GPT. Tidak ada partisi jenis ini dalam kasus partisi MBR (setidaknya tidak untuk GRUB2). Partisi ini juga tidak diperlukan jika sistem berbasiskan UEFI, kerana tidak ada bootsectors yang mengambil tempat dalam kasus ini. Syslinux tidak memerlukan partisi ini.<br />
<br />
Untuk konfigurasi BIOS-GPT, buat sebuah partisi sebesar 2 MiB menggunaka cgdisk atau GNU Parted tanpa jenis filesistem. Lokasi partisi ini tidak menjadi masalah tetapi partisi ini haruslah berada diantara yang pertama dari area 2 TiB. Sangat disarankan untuk menempatkannya di awal disk sebelum partisi /boot. Atur jenis partisi menjadi "EF02" di cgdisk atau {{ic|set <BOOT_PART_NUM> bios_grub on}} di GNU Parted.<br />
<br />
{{Note|Partisi ini harus di buat sebelum grub_bios-install atau grub-setup dijalankan atau sebelum langka '''Install Bootloader''' dari penginstallan Archlinux (jika GRUB2 BIOS terpilih sebagai bootloader).}}<br />
<br />
===== Instruksi spesifik [[MBR]] dikenal sebagai pemartisian msdos =====<br />
<br />
Biasa post-MBR (setelah 512 byte area MBR dan sebelum dimulainya partisi pertama) di banyak sistem pemartisian MBR (atau msdos disklabel) adalah 32 KiB ketika kompabilitas DOS telah terpenuhi. Akan tetapi sebuah post-MBR sejumlah 1 atau 2 MiB direkomendasikan untuk memberikan ruang yang cukup untuk core.img yang terembed ( https://bugs.archlinux.org/task/24103 ). Disarankan untuk menggunakan pemartisi yang mendukung alokasi partisi 1 MiB untuk mendapat ruang dalam memenuhi sektor non-512 byte. (yang tidak berelasi untuk embed core.img).<br />
<br />
Jika anda tidak melakukan dual-boot dengan MS Windows (semua versi) di sistem BIOS, disarankan untuk menggunakan partisi GPT - [[GUID_Partition_Table#Convert_from_MBR_to_GPT_without_data_loss]]<br />
<br />
{{Catatan|Membuat partisi 2MiB telah disebut diatas SEBELUM anda mengkonversi ke GPT. Jika tidak, gparted tidak akan merubah ukuran partisi boot untuk mengizinkan pembuatannya dan ketika anda reboot grub2 tidak tahu dimana untuk memulai.}}<br />
<br />
==== UEFI systems ====<br />
<br />
===== Membuat dan the UEFI SYSTEM PARTITION =====<br />
<br />
Ikuti instruksi [[Unified_Extensible_Firmware_Interface#Create_an_UEFI_SYSTEM_PARTITION_in_Linux]] dalam membuat sebuah UEFI SYSTEM PARTITION. Lalu mount UEFI SYSTEM PARTITION di {{ic|/boot/efi}}. harus mempunya format FAT32 dan lebih besar dari >=200 MiB ukurannya. jika kamu telah mount partisi UEFISYS di mountpoint yang lain, ganti {{ic|/boot/efi}} dengan command di bawah ini:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFISYS_PART_DEVICE> /boot/efi<br />
<br />
Buat direktori <UEFI_SYSTEM_PARTITION>/efi jika tidak ada:<br />
<br />
# mkdir -p /boot/efi/efi<br />
<br />
== Installation ==<br />
<br />
=== During Arch Linux installation ===<br />
<br />
* lEwati langkah '''Install Bootloader''' dan keluar dari penginstall.<br />
* Mengatur jaringan:<br />
# aif -p partial-configure-network<br />
Command ini memunculkan dialog; masukkan jenis perangkat yang digunakan, (contoh : eth0) dan gunakan DHCP untuk pengaturan yang lebih mudah.<br />
* Jika anda tidak mengkonfigurasi sistem {{ic|/etc/resolv.conf}} dalam instalasi (anda merencanakan membiarkan DHCP mengatur otomatis), anda perlu mengkopi konfigurasi yang di buat oleh AIF ketika jaringan di konfigurasi otomatis:<br />
# cp /etc/resolv.conf /mnt/etc/resolv.conf<br />
* Jika anda mengalami kegagalan jaringan saat update paket pacman, anda mungkin harus menginstall paket net-tools.<br />
* Cek dan liat apa modul dm_mod digunakan. Jika tidak load secara manual. (anda mungkin butuh grub2-bios; pasang jika diperlukan):<br />
# lsmod | grep dm_mod<br />
# modprobe dm-mod<br />
{{Note|This is necessary at this point, and cannot be postponed after the chroot. If you try to use modprobe in a chroot environment that has a later kernel version from that of the installing device (at the time of writing, 2.6.33), modprobe will fail. This happens routinely using the Arch "net" installations.}}<br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# mount -t proc /proc /mnt/proc/<br />
# mount -t sysfs /sys /mnt/sys/<br />
# chroot /mnt bash<br />
* Update database pacman :<br />
# pacman-db-upgrade<br />
* Refresh daftar paket (dengan tambahan -y):<br />
# pacman -Syy<br />
* Pasang paket GRUB2 sperti telah disebutkan di bagian [[#From a running Arch Linux]]. dm-mod module sudah di load tidak perlu di load lagi.<br />
<br />
=== From a running Arch Linux ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== Backup Important Data =====<br />
<br />
In general, a grub installation should run smoothly. Sometimes it could mess up your system. You're strongly advised to make a backup before installing grub2-bios.<br />
<br />
* copy grub modules and configuration<br />
<br />
# cp -a /boot/grub /path/to/backup/<br />
<br />
* backup the MBR and GRUB-Legacy stage 1.5<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/first-sectors bs=512 count=63<br />
<br />
Replace /dev/sdaX with you disk path (mostly /dev/sda).<br />
<br />
{{Note|This command backs up the partition table too. Be careful while restoring if you've changed your partition setup in the meantime}}<br />
<br />
To backup only the MBR boot code use:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1<br />
<br />
You could now lightly remove {{ic|/boot/grub}} with:<br />
<br />
# rm -rf /boot/grub<br />
<br />
and follow the instructions below. You know that if things get nasty, you could reboot your system thanks to an installation media and:<br />
<br />
* move old grub-legacy or grub2 files out of the way<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* copy grub back to /boot<br />
<br />
# cp -a /path/to/backup/grub /boot/<br />
<br />
* replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=63<br />
<br />
{{Note|This command also restores the partition table. Be careful.}}<br />
<br />
To restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1<br />
<br />
===== Install grub2-bios package =====<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Pkg|grub}}, if it is installed). Simply installing the package won't update the {{ic|/boot/grub/core.img}} file and the grub2 modules in {{ic|/boot/grub}}. You need to update them manually using grub_bios-install as explained below.<br />
<br />
# pacman -S grub2-bios<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions:<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-bios boot files =====<br />
<br />
There are 3 ways to install grub2 boot files in BIOS booting:<br />
*[[#Install_to_440-byte_MBR_boot_code_region]] (recommended) , <br />
*[[#Install_to_Partition_or_Partitionless_Disk]] (not recommended),<br />
*[[#Generate_core.img_alone]] (safest method, but requires another BIOS bootloader like [[grub-legacy]] or [[syslinux]] to be installed to chainload {{ic|/boot/grub/core.img}} ). <br />
<br />
====== Install to 440-byte MBR boot code region ======<br />
<br />
To setup grub2-bios in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/core.img}} file, and embed it in the 32 KiB (minimum size - varies depending on partition alignment) post-MBR gap (MBR disks) or in BIOS Boot Partition (GPT disks), run:<br />
<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB2 on multiple physical disks. <br />
<br />
The {{ic|--no-floppy}} tells grub2-bios utilities not to search for any floppy devices which reduces the overall execution time of grub_bios-install on many systems (it will also prevent the issue below from occurring). Otherwise you get an error that looks like this:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
{{Warning|Make sure that you check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic| boot-directory}} parameter creates another {{ic|/boot}} folder inside of boot. A wrong install would look like this {{ic|/boot/boot/grub}} !}}.<br />
<br />
====== Install to Partition or Partitionless Disk ======<br />
<br />
{{Note|grub2-bios (any version - including upstream bzr repo) does not encourage installation to a partition boot sector or a partitionless disk like grub-legacy or syslinux does. Neither do the Arch devs.}}<br />
<br />
To setup grub2-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example /dev/sda1 as the /boot partition)<br />
<br />
# chattr -i /boot/grub/core.img<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --force --debug /dev/sda1<br />
# chattr +i /boot/grub/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating core.img).<br />
<br />
grub_bios-install will give out warnings like which should give you the idea of what might go wrong with this approach.<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and grub-setup will not setup its boot code in the partition boot sector.<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why grub-setup does not by default allow this is because in case of partition or a partitionless disk is that grub2-bios relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/core.img}} needs to be set only if grub2-bios is installed to a partition boot sector or a partitionless disk, not in case of installtion to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
====== Generate core.img alone ======<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/core.img}} file WITHOUT embedding any grub2-bios bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to grub_bios-install:<br />
<br />
# grub_bios-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
You can then chainload grub2's core.img from grub-legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
===== Generate GRUB2 BIOS Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2 complains about "no suitable mode found" while booting, go to [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB2 {{ic|/boot/grub/grub.cfg}} configfile and simply rebooted into GRUB2 Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB2 {{ic|/boot/grub/grub.cfg}} configfile.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
===== Multiboot in BIOS =====<br />
<br />
====== Boot Microsoft Windows installed in BIOS-MBR mode ======<br />
<br />
{{Note|GRUB2 supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
Find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the bootmgr and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/Windows/bootmgr}}:<br />
<br />
# grub-probe --target=fs_uuid /media/Windows/bootmgr<br />
69B235F6749E84CE<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} and regenerate grub.cfg with grub-mkconfig as explained above to chainload Windows (Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
menuentry "Microsoft Windows 7 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/bootmgr<br />
}<br />
<br />
For Windows XP<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/ntldr<br />
}<br />
<br />
==== [[UEFI]] systems ====<br />
<br />
===== Install grub2-uefi package =====<br />
<br />
{{Note|Unless specified as EFI 1.x , EFI and UEFI terms are used interchangeably to denote UEFI 2.x firmware. Also unless stated explicitely, the instructions are general and not Mac specific. Some of them may not work or may be different in Macs. Apple's EFI implementation is neither a EFI 1.x version nor UEFI 2.x version but mixes up both. This kind of firmware does not fall under any one UEFI Specification version and is therefore not a standard UEFI firmware.}}<br />
<br />
GRUB2 UEFI bootloader is available in Arch Linux only from version 1.99~rc1. To install, first [https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Detecting_UEFI_Firmware_Arch Detect which UEFI firmware arch] you have (either x86_64 or i386).<br />
<br />
Depending on that, install the appropriate package<br />
<br />
For 64-bit aka x86_64 UEFI firmware:<br />
# pacman -S grub2-efi-x86_64<br />
<br />
For 32-bit aka i386 UEFI firmware:<br />
# pacman -S grub2-efi-i386<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
{{Note|Simply installing the package won't update the grub.efi file and the grub2 modules in the UEFI System Partition. You need to update the grub.efi file and the grub2 modules in the UEFI System Partition manually using grub_efi_${UEFI_ARCH}-install as explained below.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-uefi boot files =====<br />
<br />
====== Install to UEFI SYSTEM PARTITION ======<br />
<br />
{{Note|The below commands assume you are using {{ic|grub2-efi-x86_64}} (for {{ic|grub2-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands).}}<br />
<br />
The UEFI system partition will need to be mounted at /boot/efi for the GRUB2 install script to detect it.<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application and its modules to {{ic|/boot/efi/efi/arch_grub}} using <br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
If you want to install grub2 modules and grub.cfg at the directory {{ic|/boot/grub}} and only the grubx64.efi application at {{ic|/boot/efi/efi/arch_grub}} use<br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
In this case grub2-efi-x86_64 will be installed into /boot/grub, making the behavior consistent with the BIOS verion of GRUB2, but this is not recommended if you use both grub2-bios and grub2-efi-x86_64 in your system, as this will overwrite grub2-bios modules in /boot/grub .<br />
<br />
The {{ic|--root-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the grubx64.efi file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which grub.cfg should be created).<br />
<br />
The actual paths are<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
Note the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to <boot-directory>/grub .<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == <boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/core.efi</nowiki>}} .<br />
<br />
{{Note| This behavior of --root-directory , --boot-directory , and --bootloader-id options are specific to UEFI systems and does not occur is BIOS mode. In grub_bios-install, --root-directory is deprecated and --bootloader-id option does not exist.}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for grub_efi_x86_64-install to install grubx64.efi in it, which will be launched by the firmware (using th efibootmgr created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub_efi_x86_64-install}} command unlike the case of setting up grub2 for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a grub.cfg file by following [[#Generate_GRUB2_UEFI_Config_file]] and [[#Create_GRUB2_entry_in_the_Firmware_Boot_Manager]].<br />
<br />
===== Create GRUB2 entry in the Firmware Boot Manager =====<br />
<br />
====== Non-Mac UEFI systems ======<br />
<br />
grub_efi_${UEFI_ARCH}-install will ensure that {{ic|/boot/efi/efi/arch_grub/grubx64.efi}} is launched by default if it detects {{ic|efibootmgr}} and if it is able to access UEFI Runtime Services. Follow [[Unified_Extensible_Firmware_Interface#efibootmgr]] for more info.<br />
<br />
If you have problems running GRUB2 in UEFI mode you can try the following (worked on an ASUS Z68 mainboard):<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shell/shellx64.efi<br />
<br />
After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The grub2 menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry (see above).<br />
<br />
====== Apple Mac EFI systems ======<br />
<br />
{{Note| TODO: Grub upstream bzr mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes}}<br />
{{Note| TODO: Fedora's mactel-boot ( https://bugzilla.redhat.com/show_bug.cgi?id&#61;755093 )}}<br />
<br />
Use bless command from within Mac OS X to set {{ic|grubx64.efi}} as the default boot option. You can also boot from the Mac OS X install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI System Partition:<br />
<br />
# cd /Volumes<br />
# mkdir efi<br />
# mount -t msdos /dev/disk0s1 /Volumes/efi<br />
<br />
Then run bless on {{ic|grub.efi}} and on the EFI partition to set them as the default boot options.<br />
<br />
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
<br />
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.<br />
<br />
===== Generate GRUB2 UEFI Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="<boot-directory>/grub" grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/efi</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/efi/efi/grub" grub-mkconfig -o /boot/efi/efi/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
This is independent of the value of --bootloader-id option. The {{ic|GRUB_PREFIX}} env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2-uefi complains about "no suitable mode found" while booting, try [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
===== Create GRUB2 Standalone UEFI Application =====<br />
<br />
It is possible to create a grubx64_standalone.efi application which has all the modules embeddded in a memdisk within the uefi application, thus removing the need for having a separate directory populated with all the grub2 uefi modules and other related files. This is done using the grub-mkstandalone command which is included in extra/grub2-common >= 1:1.99-6 package.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The grubx64_standalone.efi file expects grub.cfg to be within its $prefix which is (memdisk)/boot/grub. The memdisk is embedded within the efi app. The grub-mkstandlone script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the grub.cfg at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the grub-mkstandalone script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}} . That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to includ the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what grub.efi expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/efi/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB2 entry in the Firmware Boot Manager]].<br />
<br />
===== Multiboot in UEFI =====<br />
<br />
====== Chainload Microsoft Windows x86_64 UEFI-GPT ======<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/efi/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/boot/grub/grub.cfg}} OR {{ic|/boot/efi/efi/grub/grub.cfg}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|If GRUB2 was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in the BIOS version of GRUB2.}}<br />
<br />
=== Automatically generating using grub-mkconfig (Recommended) ===<br />
<br />
The GRUB2 {{ic|menu.1st}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. grub-mkconfig uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually by editing {{ic|/etc/grub.d/40_custom}}<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc<br />
|/boot/grub/grub.cfg<br />
|<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
''NOTE: If you want GRUB2 to automatically search for other systems, for example as in Ubuntu. Then you may need to install {{Pkg|os-prober}}.''<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}}. The entries in this file will be automatically added when running '''grub-mkconfig'''.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader (hd0,3)+1<br />
}<br />
<br />
If the windows bootloader is on an entirely different harddrive than grub, it may be necessary to trick Windows into believing that it is in fact the first harddrive. This was possible in the old grub with {{ic|map}} and is now done with {{ic|drivemap}}. Assume grub is on {{ic|hd0}} and windows on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, grub2 graphical terminal, gfxterm, with proper video mode, gfxmode, in grub2. This can be seen in the section [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]]. This video mode is passed by grub2 to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
====Setting the framebuffer resolution ====<br />
<br />
Grub2 can set the framebuffer for both grub2 itself and the kernel. The old ''vga='' way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen.}}<br />
{{Note|To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at grub2 prompt you can use the {{ic|1=vbeinfo}} command.}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}<br />
<br />
====915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
In the following I will proceed with the example for my system. Please adjust the recipe for your needs. First you need to find a video mode which will be modified later. For that, run {{ic|915resolution}} in GRUB2 command shell.<br />
915resolution -l<br />
The output will be something like:<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
...<br />
Mode 30 : 640x480, 8 bits/pixel<br />
...<br />
Next, our purpose is to overwrite mode 30. (You can choose what ever mode you want.) In the file {{ic|/etc/grub.d/00_header}} just before the {{ic|set gfxmode&#61;${GRUB_GFXMODE} }} line insert<br />
915resolution 30 1440 900<br />
Here we are overwriting the mode {{ic| 30}} with {{ic|1440x900}} resolution. Lastly we need to set {{ic | GRUB_GFXMODE}} as described earlier, regenerate grub configuration file and reboot to test changes.<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
sudo reboot<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{ic|unicode.pf2}}, or, as only ascii characters under the name {{ic|ascii.pf2}}. <br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [https://wiki.archlinux.org/index.php/GRUB2#Setting_the_framebuffer_resolution framebuffer resolution].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/archlinux.tga"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
<br />
(archlinux.tga is a placeholder; put your file name there)<br />
<br />
{{Note|If you have installed Grub on a separate partition, {{ic|/boot/grub/archlinux.tga}} becomes {{ic|/grub/archlinux.tga}}.}}<br />
<br />
To generate the changes and add the information into grub.cfg, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see "Found background image..." in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the grub.cfg file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in /etc/default/grub are correct.<br />
* The image is of the proper size and format (tga, png, 8-bit jpg).<br />
* The image was saved in the RGB mode, and is not indexed.<br />
* The console mode is not enabled in /etc/default/grub.<br />
* The command grub-mkconfig must be executed to place the background image information into the /boot/grub/grub.cfg file.<br />
<br />
====Menu colors====<br />
<br />
As in Grub (0.9x), you can change the menu colors in Grub2. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html#Theme-file-format.<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
====Hidden menu====<br />
<br />
One of the unique features of Grub2 is hiding/skipping the menu and showing it by holding "Shift" when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== Raid ====<br />
<br />
Grub2 provides convenient handling of raid-volumes. You need to add:<br />
insmod raid<br />
<br />
which allows you to address the volume natively. E.g. {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned raid-volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
You can use UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}} and {{ic|/dev/hd*}} scheming. It has the advantage of detecting partitions by their unique UUIDs, which is needed by some people booting with complicated partition setups.<br />
<br />
UUIDs are used by default in the recent versions of grub2 - there is no downside in it anyway except that you need to re-generate the {{ic|grub.cfg}} file every time you resize or reformat your partitions. Remember this when modifying partitions with Live-CD.<br />
<br />
The recent versions of grub2 use UUIDs by default. You can re-enable the use of UUIDS by simply commenting the UUID line (this is also what it looks like by default):<br />
#GRUB_DISABLE_LINUX_UUID=true<br />
you can also just set the value as {{ic|false}} as shown here:<br />
GRUB_DISABLE_LINUX_UUID=false<br />
<br />
Either way, do not forget to generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --no-floppy --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
Grub2 can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the setting of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that grub will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
Note that manually added menu items, eg Windows in {{ic|/etc/grub.d/40_custom}}, will need {{ic|savedefault}} added. Remember to regenerate your configuration file.<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB2 so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB2's configuration files. To do this, run the command {{ic|grub-mkpasswd_pbkdf2}}. Enter a password and confirm it. The output will look like this:<br />
<br />
{{bc|<nowiki><br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A</nowiki>}}Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{bc|<nowiki>cat << EOF<br />
<br />
set superusers="username"<br />
password_pbkdf2 username <password><br />
<br />
EOF</nowiki>}}<br />
where <password> is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB2 command line and boot parameters are now protected.<br />
<br />
==== Root Encryption ====<br />
<br />
To let GRUB2 automatically add the kernel parameters for root encryption,<br />
add "cryptdevice=/dev/yourdevice:label" to GRUB_CMDLINE_LINUX in /etc/defaults/grub .<br />
<br />
Example with root mapped to /dev/mapper/root :<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
=== Booting an ISO Directly From Grub2 ===<br />
Edit {{ic|/etc/grub.d/40_custom}} to add an entry for the target ISO. When finished, update the grub menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. Also adjust the img_dev line to match this same location.}}<br />
<br />
menuentry "Archlinux-2011.08.19-netinstall-x86_64.iso" {<br />
set isofile="/archives/archlinux-2011.08.19-netinstall-x86_64.iso"<br />
loopback loop (hd0,7)$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201108 img_dev=/dev/sda7 img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. }}<br />
<br />
menuentry "ubuntu-11.04-desktop-amd64.iso" {<br />
set isofile="/path/to/ubuntu-11.04-desktop-amd64.iso"<br />
loopback loop (hdX,Y)$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB2 supports pager for reading commands that provide long output (like the help command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB2 command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed from [[AUR]]<br />
* [https://aur.archlinux.org/packages.php?ID=44020 grub-customizer] (requires gettext gksu gtkmm hicolor-icon-theme openssl)<br />
*:Customize the bootloader (GRUB2 or BURG)<br />
* [http://kde-apps.org/content/show.php?content=139643 grub2-editor] (requires kdelibs)<br />
*:A KDE4 control module for configuring the GRUB2 bootloader<br />
* [http://kde-apps.org/content/show.php?content=137886 kcm-grub2] (requires kdelibs python2-qt kdebindings-python)<br />
*:This Kcm module manages the most common settings of Grub2.<br />
* [http://sourceforge.net/projects/startup-manager/ startupmanager] (requires gnome-python imagemagick yelp python2 xorg-xrandr)<br />
*:GUI app for changing the settings of GRUB, GRUB2, Usplash and Splashy<br />
<br />
== parttool or legacy hide/unhide ==<br />
<br />
If you have a win9x paradigm with hidden C disks GRUB legacy had the hide/unhide feature. In GRUB2 this has been replaced by parttool. For example, to boot the third C disk of three win9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then run:<br />
# grub-install /dev/sda --no-floppy<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUID's and basic scripting ==<br />
<br />
If you like the idea of using UUID's to avoid unreliable BIOS mappings or are struggling with Grub's syntax, here is an example boot menu item that uses UUID's and a small script to direct Grub to the proper disk partitions for your system. All you need to do is replace the UUID's in the sample with the correct UUID's for your system. (The example applies to a system with a boot and root partition. You will obviously need to modify the Grub configuration if you have additional partitions.)<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 <br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables <br />
search --fs-uuid --no-floppy --set=root $the_root_uuid <br />
search --fs-uuid --no-floppy --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== Enable GRUB2 debug messages ===<br />
<br />
Add<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== Correct GRUB2 No Suitable Mode Found Error ===<br />
<br />
If you get this error when booting any menuentry<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize grub2 graphical terminal (gfxterm) with proper video mode (gfxmode) in grub2. This video mode is passed by grub2 to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the grub2 video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in)<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB2_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems. If GRUB2 UEFI was installed with {{ic|1=--boot-directory=/boot/efi/efi}} set, then the directory is {{ic|/boot/efi/efi/grub/}}. <br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB2_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the unifont.pf2 file and then copy it to ${GRUB2_PREFIX_DIR}.<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable grub2 to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang:<br />
<br />
BIOS systems<br />
<br />
insmod vbe<br />
<br />
UEFI systems<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI)<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in ${GRUB2_PREFIX_DIR}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#MBR_aka_msdos_partitioning_specific_instructions]]<br />
<br />
=== UEFI GRUB2 drops to shell ===<br />
<br />
If grub loads but drop you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB2 UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== UEFI GRUB2 not loaded ===<br />
In some cases the EFI may fail to load grub correctly. Provided everything is set up correctly, the output of<br />
efibootmgr -v<br />
might look something like this:<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
If everything works correctly, the EFI would now automatically load grub.<br><br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving grub to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for grub should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
If trying to boot windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move grub's device configuration and let it reconfigure.<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
Grub-mkconfig should now mention all found boot options including windows. If it works, remove /boot/grub/device.map-old.<br />
<br />
== References ==<br />
<br />
# Official GRUB2 Manual - http://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for Grub2 - https://help.ubuntu.com/community/Grub2<br />
# GRUB2 wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]<br />
<br />
== External Links ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_bios.sh A Linux Bash Shell script to compile and install GRUB2 for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_uefi.sh A Linux Bash Shell script to compile and install GRUB2 for UEFI from BZR Source]</div>Martadinatahttps://wiki.archlinux.org/index.php?title=GRUB_(Bahasa_Indonesia)&diff=189366GRUB (Bahasa Indonesia)2012-03-13T15:02:00Z<p>Martadinata: /* Create and Mount the UEFI SYSTEM PARTITION */</p>
<hr />
<div>[[Category:Boot loaders (English)]]<br />
{{i18n|GRUB2}}<br />
[[fr:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|GRUB2 adalah generasi terbaru dari grub.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Burg}} - Burg adalah boot loader baru yang berdasar atas GRUB2. Yang menggunakan format object dimana hal ini membuat BURG dapat di gunakan di berbagai Operating System termasuk Linux/Windows/OSX/Solaris/FreeBSD, dll. Juga mempunyai tampilan untuk di konfigurasi yang unik baik melalui text mode atau GUI mode.<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/ GRUB2] generasi berikutnya dari GRUB. GRUB2 adalah derivasi dari [http://www.nongnu.org/pupa/ PUPA] yang merupakan proyek pengembangand dari GRUB. GRUB 2 telah di tulis ulang untuk membersihkan segalanya dan memberikan modularitas dan portabilitas. [http://www.gnu.org/software/grub/grub-faq.en.html#q1].<br />
<br />
Secara singkat, ''bootloader'' adalah program software pertama yang berjalan ketika komputer pertama dinyalakan. ''Bootloader'' bertanggung jawab sebagai pemicu dan pengirim kontrol ke Kernel Linux. Kernel, selanjutnya, menginisialisasi seluruh sistem operasi.<br />
<br />
{{Note|grub2 dari 1.99 dan selanjutnya telah mendukung btrfs sebagai root (tanpa /boot filesistem yang terpisah), tetapi tingkat kompresinya terbatas pada zlib, tidak LZO. Dukungan kompresi LZO hanya terdapat pada repo bzr upstream.}}<br />
<br />
{{Note|Penginstall standar AIF (Arch Installation Framework) berdasar pada [[Archiso]] tidak mendukung penginstallan grub2-bios atau grub2-uefi. Akan tetapi [[Archboot]] iso mendukung penginstallan grub2-bios dan grub2-uefi.}}<br />
<br />
== Prefasi ==<br />
<br />
Walaupun, [[GRUB]] (versi 0.9x) adalah bootloader standar Arch Linux, GRUB dapat diganti menjadi 'grub legacy' by upstream. Dimana telah menjadi GRUB2 dan [[Syslinux]] di beberapa distribusi. Versi lanjutan merekomendasikan GRUB2 >=1.99 di atas versi grub-legacy.<br />
<br />
=== Catatan untuk pengguna GRUB Legacy ===<br />
<br />
* Ada perbedaan perinta dari GRUB dan GRUB2. Perlu di lihat terlebih dahulu [http://www.gnu.org/software/grub/manual/grub.html#Commands GRUB2 commands] sebelum melanjutkan (contoh : "find" telah di ganti dengan "search").<br />
<br />
* GRUB2 sekarang ''modular'' dan tidak lagi memerlukan "stage 1.5". Sebagai hasilnya, bootloader itu sendiri menjadi terbatas -- modul-modul diambil dari hard disk sebagai kebutuhan untuk meluaskan fungsionalitas. (contoh : dukungan untuk [[LVM]] atau RAID).<br />
<br />
* Penamaan perangkat telah berubah antara GRUB dan GRUB2. Partisi diurut dari nomor 1 dari pada 0 ketika disk masih bernomor 0. Sebagai contoh, {{ic|/dev/sda1}} akan menjadi {{ic|(hd0,msdos1)}} (untuk MBR) atau {{ic|(hd0,gpt1)}} (for GPT) ketika GRUB2 dipakai.<br />
<br />
=== Kebutuhan GRUB2 ===<br />
<br />
==== System BIOS ====<br />
<br />
===== Instruksi spesifik untuk [[GPT]] =====<br />
<br />
GRUB2 di konfigurasi BIOS-GPT membutuhkan sebuah Partisi BIOS Boot yang terembed pada core.img di kehilangannya post-MBR di sistem yang terpartisi secara GPT (yang menyebabkan MBR diambil alih oleh GPT Primary Header dan Primary Partition table). Partisi ini digunakan oleh GRUB2 hanya pada pengaturan BIOS-GPT. Tidak ada partisi jenis ini dalam kasus partisi MBR (setidaknya tidak untuk GRUB2). Partisi ini juga tidak diperlukan jika sistem berbasiskan UEFI, kerana tidak ada bootsectors yang mengambil tempat dalam kasus ini. Syslinux tidak memerlukan partisi ini.<br />
<br />
Untuk konfigurasi BIOS-GPT, buat sebuah partisi sebesar 2 MiB menggunaka cgdisk atau GNU Parted tanpa jenis filesistem. Lokasi partisi ini tidak menjadi masalah tetapi partisi ini haruslah berada diantara yang pertama dari area 2 TiB. Sangat disarankan untuk menempatkannya di awal disk sebelum partisi /boot. Atur jenis partisi menjadi "EF02" di cgdisk atau {{ic|set <BOOT_PART_NUM> bios_grub on}} di GNU Parted.<br />
<br />
{{Note|Partisi ini harus di buat sebelum grub_bios-install atau grub-setup dijalankan atau sebelum langka '''Install Bootloader''' dari penginstallan Archlinux (jika GRUB2 BIOS terpilih sebagai bootloader).}}<br />
<br />
===== Instruksi spesifik [[MBR]] dikenal sebagai pemartisian msdos =====<br />
<br />
Biasa post-MBR (setelah 512 byte area MBR dan sebelum dimulainya partisi pertama) di banyak sistem pemartisian MBR (atau msdos disklabel) adalah 32 KiB ketika kompabilitas DOS telah terpenuhi. Akan tetapi sebuah post-MBR sejumlah 1 atau 2 MiB direkomendasikan untuk memberikan ruang yang cukup untuk core.img yang terembed ( https://bugs.archlinux.org/task/24103 ). Disarankan untuk menggunakan pemartisi yang mendukung alokasi partisi 1 MiB untuk mendapat ruang dalam memenuhi sektor non-512 byte. (yang tidak berelasi untuk embed core.img).<br />
<br />
Jika anda tidak melakukan dual-boot dengan MS Windows (semua versi) di sistem BIOS, disarankan untuk menggunakan partisi GPT - [[GUID_Partition_Table#Convert_from_MBR_to_GPT_without_data_loss]]<br />
<br />
{{Catatan|Membuat partisi 2MiB telah disebut diatas SEBELUM anda mengkonversi ke GPT. Jika tidak, gparted tidak akan merubah ukuran partisi boot untuk mengizinkan pembuatannya dan ketika anda reboot grub2 tidak tahu dimana untuk memulai.}}<br />
<br />
==== UEFI systems ====<br />
<br />
===== Membuat dan the UEFI SYSTEM PARTITION =====<br />
<br />
Ikuti instruksi [[Unified_Extensible_Firmware_Interface#Create_an_UEFI_SYSTEM_PARTITION_in_Linux]] dalam membuat sebuah UEFI SYSTEM PARTITION. Lalu mount UEFI SYSTEM PARTITION di {{ic|/boot/efi}}. harus mempunya format FAT32 dan lebih besar dari >=200 MiB ukurannya. jika kamu telah mount partisi UEFISYS di mountpoint yang lain, ganti {{ic|/boot/efi}} dengan command di bawah ini:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFISYS_PART_DEVICE> /boot/efi<br />
<br />
Buat direktori <UEFI_SYSTEM_PARTITION>/efi jika tidak ada:<br />
<br />
# mkdir -p /boot/efi/efi<br />
<br />
== Installation ==<br />
<br />
=== During Arch Linux installation ===<br />
<br />
* Skip the '''Install Bootloader''' step and exit the installer.<br />
* Configure the network:<br />
# aif -p partial-configure-network<br />
This will bring up a prompt; put in the network interface to use, (e.g., eth0) and use DHCP for easy configuration.<br />
* If you did not configure the installed system's {{ic|/etc/resolv.conf}} file during installation (for instance, if you plan to let DHCP generate it later), you will need to copy the one generated by AIF when it configured the network:<br />
# cp /etc/resolv.conf /mnt/etc/resolv.conf<br />
* If you run into network issues in the pacman update step below, you may have needed to install the net-tools package.<br />
* Check and see if the dm_mod module is loaded. If it is not, load it manually. (you might need grub2-bios; install the package if needed):<br />
# lsmod | grep dm_mod<br />
# modprobe dm-mod<br />
{{Note|This is necessary at this point, and cannot be postponed after the chroot. If you try to use modprobe in a chroot environment that has a later kernel version from that of the installing device (at the time of writing, 2.6.33), modprobe will fail. This happens routinely using the Arch "net" installations.}}<br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# mount -t proc /proc /mnt/proc/<br />
# mount -t sysfs /sys /mnt/sys/<br />
# chroot /mnt bash<br />
* Update pacman's database:<br />
# pacman-db-upgrade<br />
* Refresh the package list (with an extra -y flag to force a refresh of all package lists even if they appear to be up to date):<br />
# pacman -Syy<br />
* Install the GRUB2 package as mentioned in the section [[#From a running Arch Linux]]. Note that the dm-mod module has already been loaded, no need to do that again.<br />
<br />
=== From a running Arch Linux ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== Backup Important Data =====<br />
<br />
In general, a grub installation should run smoothly. Sometimes it could mess up your system. You're strongly advised to make a backup before installing grub2-bios.<br />
<br />
* copy grub modules and configuration<br />
<br />
# cp -a /boot/grub /path/to/backup/<br />
<br />
* backup the MBR and GRUB-Legacy stage 1.5<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/first-sectors bs=512 count=63<br />
<br />
Replace /dev/sdaX with you disk path (mostly /dev/sda).<br />
<br />
{{Note|This command backs up the partition table too. Be careful while restoring if you've changed your partition setup in the meantime}}<br />
<br />
To backup only the MBR boot code use:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1<br />
<br />
You could now lightly remove {{ic|/boot/grub}} with:<br />
<br />
# rm -rf /boot/grub<br />
<br />
and follow the instructions below. You know that if things get nasty, you could reboot your system thanks to an installation media and:<br />
<br />
* move old grub-legacy or grub2 files out of the way<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* copy grub back to /boot<br />
<br />
# cp -a /path/to/backup/grub /boot/<br />
<br />
* replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=63<br />
<br />
{{Note|This command also restores the partition table. Be careful.}}<br />
<br />
To restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1<br />
<br />
===== Install grub2-bios package =====<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Pkg|grub}}, if it is installed). Simply installing the package won't update the {{ic|/boot/grub/core.img}} file and the grub2 modules in {{ic|/boot/grub}}. You need to update them manually using grub_bios-install as explained below.<br />
<br />
# pacman -S grub2-bios<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions:<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-bios boot files =====<br />
<br />
There are 3 ways to install grub2 boot files in BIOS booting:<br />
*[[#Install_to_440-byte_MBR_boot_code_region]] (recommended) , <br />
*[[#Install_to_Partition_or_Partitionless_Disk]] (not recommended),<br />
*[[#Generate_core.img_alone]] (safest method, but requires another BIOS bootloader like [[grub-legacy]] or [[syslinux]] to be installed to chainload {{ic|/boot/grub/core.img}} ). <br />
<br />
====== Install to 440-byte MBR boot code region ======<br />
<br />
To setup grub2-bios in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/core.img}} file, and embed it in the 32 KiB (minimum size - varies depending on partition alignment) post-MBR gap (MBR disks) or in BIOS Boot Partition (GPT disks), run:<br />
<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB2 on multiple physical disks. <br />
<br />
The {{ic|--no-floppy}} tells grub2-bios utilities not to search for any floppy devices which reduces the overall execution time of grub_bios-install on many systems (it will also prevent the issue below from occurring). Otherwise you get an error that looks like this:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
{{Warning|Make sure that you check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic| boot-directory}} parameter creates another {{ic|/boot}} folder inside of boot. A wrong install would look like this {{ic|/boot/boot/grub}} !}}.<br />
<br />
====== Install to Partition or Partitionless Disk ======<br />
<br />
{{Note|grub2-bios (any version - including upstream bzr repo) does not encourage installation to a partition boot sector or a partitionless disk like grub-legacy or syslinux does. Neither do the Arch devs.}}<br />
<br />
To setup grub2-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example /dev/sda1 as the /boot partition)<br />
<br />
# chattr -i /boot/grub/core.img<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --force --debug /dev/sda1<br />
# chattr +i /boot/grub/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating core.img).<br />
<br />
grub_bios-install will give out warnings like which should give you the idea of what might go wrong with this approach.<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and grub-setup will not setup its boot code in the partition boot sector.<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why grub-setup does not by default allow this is because in case of partition or a partitionless disk is that grub2-bios relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/core.img}} needs to be set only if grub2-bios is installed to a partition boot sector or a partitionless disk, not in case of installtion to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
====== Generate core.img alone ======<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/core.img}} file WITHOUT embedding any grub2-bios bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to grub_bios-install:<br />
<br />
# grub_bios-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
You can then chainload grub2's core.img from grub-legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
===== Generate GRUB2 BIOS Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2 complains about "no suitable mode found" while booting, go to [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB2 {{ic|/boot/grub/grub.cfg}} configfile and simply rebooted into GRUB2 Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB2 {{ic|/boot/grub/grub.cfg}} configfile.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
===== Multiboot in BIOS =====<br />
<br />
====== Boot Microsoft Windows installed in BIOS-MBR mode ======<br />
<br />
{{Note|GRUB2 supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
Find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the bootmgr and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/Windows/bootmgr}}:<br />
<br />
# grub-probe --target=fs_uuid /media/Windows/bootmgr<br />
69B235F6749E84CE<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} and regenerate grub.cfg with grub-mkconfig as explained above to chainload Windows (Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
menuentry "Microsoft Windows 7 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/bootmgr<br />
}<br />
<br />
For Windows XP<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/ntldr<br />
}<br />
<br />
==== [[UEFI]] systems ====<br />
<br />
===== Install grub2-uefi package =====<br />
<br />
{{Note|Unless specified as EFI 1.x , EFI and UEFI terms are used interchangeably to denote UEFI 2.x firmware. Also unless stated explicitely, the instructions are general and not Mac specific. Some of them may not work or may be different in Macs. Apple's EFI implementation is neither a EFI 1.x version nor UEFI 2.x version but mixes up both. This kind of firmware does not fall under any one UEFI Specification version and is therefore not a standard UEFI firmware.}}<br />
<br />
GRUB2 UEFI bootloader is available in Arch Linux only from version 1.99~rc1. To install, first [https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Detecting_UEFI_Firmware_Arch Detect which UEFI firmware arch] you have (either x86_64 or i386).<br />
<br />
Depending on that, install the appropriate package<br />
<br />
For 64-bit aka x86_64 UEFI firmware:<br />
# pacman -S grub2-efi-x86_64<br />
<br />
For 32-bit aka i386 UEFI firmware:<br />
# pacman -S grub2-efi-i386<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
{{Note|Simply installing the package won't update the grub.efi file and the grub2 modules in the UEFI System Partition. You need to update the grub.efi file and the grub2 modules in the UEFI System Partition manually using grub_efi_${UEFI_ARCH}-install as explained below.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-uefi boot files =====<br />
<br />
====== Install to UEFI SYSTEM PARTITION ======<br />
<br />
{{Note|The below commands assume you are using {{ic|grub2-efi-x86_64}} (for {{ic|grub2-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands).}}<br />
<br />
The UEFI system partition will need to be mounted at /boot/efi for the GRUB2 install script to detect it.<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application and its modules to {{ic|/boot/efi/efi/arch_grub}} using <br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
If you want to install grub2 modules and grub.cfg at the directory {{ic|/boot/grub}} and only the grubx64.efi application at {{ic|/boot/efi/efi/arch_grub}} use<br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
In this case grub2-efi-x86_64 will be installed into /boot/grub, making the behavior consistent with the BIOS verion of GRUB2, but this is not recommended if you use both grub2-bios and grub2-efi-x86_64 in your system, as this will overwrite grub2-bios modules in /boot/grub .<br />
<br />
The {{ic|--root-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the grubx64.efi file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which grub.cfg should be created).<br />
<br />
The actual paths are<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
Note the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to <boot-directory>/grub .<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == <boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/core.efi</nowiki>}} .<br />
<br />
{{Note| This behavior of --root-directory , --boot-directory , and --bootloader-id options are specific to UEFI systems and does not occur is BIOS mode. In grub_bios-install, --root-directory is deprecated and --bootloader-id option does not exist.}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for grub_efi_x86_64-install to install grubx64.efi in it, which will be launched by the firmware (using th efibootmgr created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub_efi_x86_64-install}} command unlike the case of setting up grub2 for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a grub.cfg file by following [[#Generate_GRUB2_UEFI_Config_file]] and [[#Create_GRUB2_entry_in_the_Firmware_Boot_Manager]].<br />
<br />
===== Create GRUB2 entry in the Firmware Boot Manager =====<br />
<br />
====== Non-Mac UEFI systems ======<br />
<br />
grub_efi_${UEFI_ARCH}-install will ensure that {{ic|/boot/efi/efi/arch_grub/grubx64.efi}} is launched by default if it detects {{ic|efibootmgr}} and if it is able to access UEFI Runtime Services. Follow [[Unified_Extensible_Firmware_Interface#efibootmgr]] for more info.<br />
<br />
If you have problems running GRUB2 in UEFI mode you can try the following (worked on an ASUS Z68 mainboard):<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shell/shellx64.efi<br />
<br />
After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The grub2 menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry (see above).<br />
<br />
====== Apple Mac EFI systems ======<br />
<br />
{{Note| TODO: Grub upstream bzr mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes}}<br />
{{Note| TODO: Fedora's mactel-boot ( https://bugzilla.redhat.com/show_bug.cgi?id&#61;755093 )}}<br />
<br />
Use bless command from within Mac OS X to set {{ic|grubx64.efi}} as the default boot option. You can also boot from the Mac OS X install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI System Partition:<br />
<br />
# cd /Volumes<br />
# mkdir efi<br />
# mount -t msdos /dev/disk0s1 /Volumes/efi<br />
<br />
Then run bless on {{ic|grub.efi}} and on the EFI partition to set them as the default boot options.<br />
<br />
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
<br />
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.<br />
<br />
===== Generate GRUB2 UEFI Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="<boot-directory>/grub" grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/efi</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/efi/efi/grub" grub-mkconfig -o /boot/efi/efi/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
This is independent of the value of --bootloader-id option. The {{ic|GRUB_PREFIX}} env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2-uefi complains about "no suitable mode found" while booting, try [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
===== Create GRUB2 Standalone UEFI Application =====<br />
<br />
It is possible to create a grubx64_standalone.efi application which has all the modules embeddded in a memdisk within the uefi application, thus removing the need for having a separate directory populated with all the grub2 uefi modules and other related files. This is done using the grub-mkstandalone command which is included in extra/grub2-common >= 1:1.99-6 package.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The grubx64_standalone.efi file expects grub.cfg to be within its $prefix which is (memdisk)/boot/grub. The memdisk is embedded within the efi app. The grub-mkstandlone script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the grub.cfg at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the grub-mkstandalone script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}} . That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to includ the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what grub.efi expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/efi/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB2 entry in the Firmware Boot Manager]].<br />
<br />
===== Multiboot in UEFI =====<br />
<br />
====== Chainload Microsoft Windows x86_64 UEFI-GPT ======<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/efi/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/boot/grub/grub.cfg}} OR {{ic|/boot/efi/efi/grub/grub.cfg}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|If GRUB2 was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in the BIOS version of GRUB2.}}<br />
<br />
=== Automatically generating using grub-mkconfig (Recommended) ===<br />
<br />
The GRUB2 {{ic|menu.1st}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. grub-mkconfig uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually by editing {{ic|/etc/grub.d/40_custom}}<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc<br />
|/boot/grub/grub.cfg<br />
|<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
''NOTE: If you want GRUB2 to automatically search for other systems, for example as in Ubuntu. Then you may need to install {{Pkg|os-prober}}.''<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}}. The entries in this file will be automatically added when running '''grub-mkconfig'''.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader (hd0,3)+1<br />
}<br />
<br />
If the windows bootloader is on an entirely different harddrive than grub, it may be necessary to trick Windows into believing that it is in fact the first harddrive. This was possible in the old grub with {{ic|map}} and is now done with {{ic|drivemap}}. Assume grub is on {{ic|hd0}} and windows on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, grub2 graphical terminal, gfxterm, with proper video mode, gfxmode, in grub2. This can be seen in the section [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]]. This video mode is passed by grub2 to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
====Setting the framebuffer resolution ====<br />
<br />
Grub2 can set the framebuffer for both grub2 itself and the kernel. The old ''vga='' way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen.}}<br />
{{Note|To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at grub2 prompt you can use the {{ic|1=vbeinfo}} command.}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}<br />
<br />
====915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
In the following I will proceed with the example for my system. Please adjust the recipe for your needs. First you need to find a video mode which will be modified later. For that, run {{ic|915resolution}} in GRUB2 command shell.<br />
915resolution -l<br />
The output will be something like:<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
...<br />
Mode 30 : 640x480, 8 bits/pixel<br />
...<br />
Next, our purpose is to overwrite mode 30. (You can choose what ever mode you want.) In the file {{ic|/etc/grub.d/00_header}} just before the {{ic|set gfxmode&#61;${GRUB_GFXMODE} }} line insert<br />
915resolution 30 1440 900<br />
Here we are overwriting the mode {{ic| 30}} with {{ic|1440x900}} resolution. Lastly we need to set {{ic | GRUB_GFXMODE}} as described earlier, regenerate grub configuration file and reboot to test changes.<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
sudo reboot<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{ic|unicode.pf2}}, or, as only ascii characters under the name {{ic|ascii.pf2}}. <br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [https://wiki.archlinux.org/index.php/GRUB2#Setting_the_framebuffer_resolution framebuffer resolution].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/archlinux.tga"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
<br />
(archlinux.tga is a placeholder; put your file name there)<br />
<br />
{{Note|If you have installed Grub on a separate partition, {{ic|/boot/grub/archlinux.tga}} becomes {{ic|/grub/archlinux.tga}}.}}<br />
<br />
To generate the changes and add the information into grub.cfg, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see "Found background image..." in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the grub.cfg file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in /etc/default/grub are correct.<br />
* The image is of the proper size and format (tga, png, 8-bit jpg).<br />
* The image was saved in the RGB mode, and is not indexed.<br />
* The console mode is not enabled in /etc/default/grub.<br />
* The command grub-mkconfig must be executed to place the background image information into the /boot/grub/grub.cfg file.<br />
<br />
====Menu colors====<br />
<br />
As in Grub (0.9x), you can change the menu colors in Grub2. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html#Theme-file-format.<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
====Hidden menu====<br />
<br />
One of the unique features of Grub2 is hiding/skipping the menu and showing it by holding "Shift" when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== Raid ====<br />
<br />
Grub2 provides convenient handling of raid-volumes. You need to add:<br />
insmod raid<br />
<br />
which allows you to address the volume natively. E.g. {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned raid-volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
You can use UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}} and {{ic|/dev/hd*}} scheming. It has the advantage of detecting partitions by their unique UUIDs, which is needed by some people booting with complicated partition setups.<br />
<br />
UUIDs are used by default in the recent versions of grub2 - there is no downside in it anyway except that you need to re-generate the {{ic|grub.cfg}} file every time you resize or reformat your partitions. Remember this when modifying partitions with Live-CD.<br />
<br />
The recent versions of grub2 use UUIDs by default. You can re-enable the use of UUIDS by simply commenting the UUID line (this is also what it looks like by default):<br />
#GRUB_DISABLE_LINUX_UUID=true<br />
you can also just set the value as {{ic|false}} as shown here:<br />
GRUB_DISABLE_LINUX_UUID=false<br />
<br />
Either way, do not forget to generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --no-floppy --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
Grub2 can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the setting of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that grub will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
Note that manually added menu items, eg Windows in {{ic|/etc/grub.d/40_custom}}, will need {{ic|savedefault}} added. Remember to regenerate your configuration file.<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB2 so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB2's configuration files. To do this, run the command {{ic|grub-mkpasswd_pbkdf2}}. Enter a password and confirm it. The output will look like this:<br />
<br />
{{bc|<nowiki><br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A</nowiki>}}Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{bc|<nowiki>cat << EOF<br />
<br />
set superusers="username"<br />
password_pbkdf2 username <password><br />
<br />
EOF</nowiki>}}<br />
where <password> is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB2 command line and boot parameters are now protected.<br />
<br />
==== Root Encryption ====<br />
<br />
To let GRUB2 automatically add the kernel parameters for root encryption,<br />
add "cryptdevice=/dev/yourdevice:label" to GRUB_CMDLINE_LINUX in /etc/defaults/grub .<br />
<br />
Example with root mapped to /dev/mapper/root :<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
=== Booting an ISO Directly From Grub2 ===<br />
Edit {{ic|/etc/grub.d/40_custom}} to add an entry for the target ISO. When finished, update the grub menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. Also adjust the img_dev line to match this same location.}}<br />
<br />
menuentry "Archlinux-2011.08.19-netinstall-x86_64.iso" {<br />
set isofile="/archives/archlinux-2011.08.19-netinstall-x86_64.iso"<br />
loopback loop (hd0,7)$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201108 img_dev=/dev/sda7 img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. }}<br />
<br />
menuentry "ubuntu-11.04-desktop-amd64.iso" {<br />
set isofile="/path/to/ubuntu-11.04-desktop-amd64.iso"<br />
loopback loop (hdX,Y)$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB2 supports pager for reading commands that provide long output (like the help command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB2 command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed from [[AUR]]<br />
* [https://aur.archlinux.org/packages.php?ID=44020 grub-customizer] (requires gettext gksu gtkmm hicolor-icon-theme openssl)<br />
*:Customize the bootloader (GRUB2 or BURG)<br />
* [http://kde-apps.org/content/show.php?content=139643 grub2-editor] (requires kdelibs)<br />
*:A KDE4 control module for configuring the GRUB2 bootloader<br />
* [http://kde-apps.org/content/show.php?content=137886 kcm-grub2] (requires kdelibs python2-qt kdebindings-python)<br />
*:This Kcm module manages the most common settings of Grub2.<br />
* [http://sourceforge.net/projects/startup-manager/ startupmanager] (requires gnome-python imagemagick yelp python2 xorg-xrandr)<br />
*:GUI app for changing the settings of GRUB, GRUB2, Usplash and Splashy<br />
<br />
== parttool or legacy hide/unhide ==<br />
<br />
If you have a win9x paradigm with hidden C disks GRUB legacy had the hide/unhide feature. In GRUB2 this has been replaced by parttool. For example, to boot the third C disk of three win9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then run:<br />
# grub-install /dev/sda --no-floppy<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUID's and basic scripting ==<br />
<br />
If you like the idea of using UUID's to avoid unreliable BIOS mappings or are struggling with Grub's syntax, here is an example boot menu item that uses UUID's and a small script to direct Grub to the proper disk partitions for your system. All you need to do is replace the UUID's in the sample with the correct UUID's for your system. (The example applies to a system with a boot and root partition. You will obviously need to modify the Grub configuration if you have additional partitions.)<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 <br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables <br />
search --fs-uuid --no-floppy --set=root $the_root_uuid <br />
search --fs-uuid --no-floppy --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== Enable GRUB2 debug messages ===<br />
<br />
Add<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== Correct GRUB2 No Suitable Mode Found Error ===<br />
<br />
If you get this error when booting any menuentry<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize grub2 graphical terminal (gfxterm) with proper video mode (gfxmode) in grub2. This video mode is passed by grub2 to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the grub2 video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in)<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB2_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems. If GRUB2 UEFI was installed with {{ic|1=--boot-directory=/boot/efi/efi}} set, then the directory is {{ic|/boot/efi/efi/grub/}}. <br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB2_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the unifont.pf2 file and then copy it to ${GRUB2_PREFIX_DIR}.<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable grub2 to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang:<br />
<br />
BIOS systems<br />
<br />
insmod vbe<br />
<br />
UEFI systems<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI)<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in ${GRUB2_PREFIX_DIR}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#MBR_aka_msdos_partitioning_specific_instructions]]<br />
<br />
=== UEFI GRUB2 drops to shell ===<br />
<br />
If grub loads but drop you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB2 UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== UEFI GRUB2 not loaded ===<br />
In some cases the EFI may fail to load grub correctly. Provided everything is set up correctly, the output of<br />
efibootmgr -v<br />
might look something like this:<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
If everything works correctly, the EFI would now automatically load grub.<br><br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving grub to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for grub should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
If trying to boot windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move grub's device configuration and let it reconfigure.<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
Grub-mkconfig should now mention all found boot options including windows. If it works, remove /boot/grub/device.map-old.<br />
<br />
== References ==<br />
<br />
# Official GRUB2 Manual - http://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for Grub2 - https://help.ubuntu.com/community/Grub2<br />
# GRUB2 wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]<br />
<br />
== External Links ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_bios.sh A Linux Bash Shell script to compile and install GRUB2 for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_uefi.sh A Linux Bash Shell script to compile and install GRUB2 for UEFI from BZR Source]</div>Martadinatahttps://wiki.archlinux.org/index.php?title=GRUB_(Bahasa_Indonesia)&diff=189349GRUB (Bahasa Indonesia)2012-03-13T11:41:05Z<p>Martadinata: /* MBR aka msdos partitioning specific instructions */</p>
<hr />
<div>[[Category:Boot loaders (English)]]<br />
{{i18n|GRUB2}}<br />
[[fr:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|GRUB2 adalah generasi terbaru dari grub.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Burg}} - Burg adalah boot loader baru yang berdasar atas GRUB2. Yang menggunakan format object dimana hal ini membuat BURG dapat di gunakan di berbagai Operating System termasuk Linux/Windows/OSX/Solaris/FreeBSD, dll. Juga mempunyai tampilan untuk di konfigurasi yang unik baik melalui text mode atau GUI mode.<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/ GRUB2] generasi berikutnya dari GRUB. GRUB2 adalah derivasi dari [http://www.nongnu.org/pupa/ PUPA] yang merupakan proyek pengembangand dari GRUB. GRUB 2 telah di tulis ulang untuk membersihkan segalanya dan memberikan modularitas dan portabilitas. [http://www.gnu.org/software/grub/grub-faq.en.html#q1].<br />
<br />
Secara singkat, ''bootloader'' adalah program software pertama yang berjalan ketika komputer pertama dinyalakan. ''Bootloader'' bertanggung jawab sebagai pemicu dan pengirim kontrol ke Kernel Linux. Kernel, selanjutnya, menginisialisasi seluruh sistem operasi.<br />
<br />
{{Note|grub2 dari 1.99 dan selanjutnya telah mendukung btrfs sebagai root (tanpa /boot filesistem yang terpisah), tetapi tingkat kompresinya terbatas pada zlib, tidak LZO. Dukungan kompresi LZO hanya terdapat pada repo bzr upstream.}}<br />
<br />
{{Note|Penginstall standar AIF (Arch Installation Framework) berdasar pada [[Archiso]] tidak mendukung penginstallan grub2-bios atau grub2-uefi. Akan tetapi [[Archboot]] iso mendukung penginstallan grub2-bios dan grub2-uefi.}}<br />
<br />
== Prefasi ==<br />
<br />
Walaupun, [[GRUB]] (versi 0.9x) adalah bootloader standar Arch Linux, GRUB dapat diganti menjadi 'grub legacy' by upstream. Dimana telah menjadi GRUB2 dan [[Syslinux]] di beberapa distribusi. Versi lanjutan merekomendasikan GRUB2 >=1.99 di atas versi grub-legacy.<br />
<br />
=== Catatan untuk pengguna GRUB Legacy ===<br />
<br />
* Ada perbedaan perinta dari GRUB dan GRUB2. Perlu di lihat terlebih dahulu [http://www.gnu.org/software/grub/manual/grub.html#Commands GRUB2 commands] sebelum melanjutkan (contoh : "find" telah di ganti dengan "search").<br />
<br />
* GRUB2 sekarang ''modular'' dan tidak lagi memerlukan "stage 1.5". Sebagai hasilnya, bootloader itu sendiri menjadi terbatas -- modul-modul diambil dari hard disk sebagai kebutuhan untuk meluaskan fungsionalitas. (contoh : dukungan untuk [[LVM]] atau RAID).<br />
<br />
* Penamaan perangkat telah berubah antara GRUB dan GRUB2. Partisi diurut dari nomor 1 dari pada 0 ketika disk masih bernomor 0. Sebagai contoh, {{ic|/dev/sda1}} akan menjadi {{ic|(hd0,msdos1)}} (untuk MBR) atau {{ic|(hd0,gpt1)}} (for GPT) ketika GRUB2 dipakai.<br />
<br />
=== Kebutuhan GRUB2 ===<br />
<br />
==== System BIOS ====<br />
<br />
===== Instruksi spesifik untuk [[GPT]] =====<br />
<br />
GRUB2 di konfigurasi BIOS-GPT membutuhkan sebuah Partisi BIOS Boot yang terembed pada core.img di kehilangannya post-MBR di sistem yang terpartisi secara GPT (yang menyebabkan MBR diambil alih oleh GPT Primary Header dan Primary Partition table). Partisi ini digunakan oleh GRUB2 hanya pada pengaturan BIOS-GPT. Tidak ada partisi jenis ini dalam kasus partisi MBR (setidaknya tidak untuk GRUB2). Partisi ini juga tidak diperlukan jika sistem berbasiskan UEFI, kerana tidak ada bootsectors yang mengambil tempat dalam kasus ini. Syslinux tidak memerlukan partisi ini.<br />
<br />
Untuk konfigurasi BIOS-GPT, buat sebuah partisi sebesar 2 MiB menggunaka cgdisk atau GNU Parted tanpa jenis filesistem. Lokasi partisi ini tidak menjadi masalah tetapi partisi ini haruslah berada diantara yang pertama dari area 2 TiB. Sangat disarankan untuk menempatkannya di awal disk sebelum partisi /boot. Atur jenis partisi menjadi "EF02" di cgdisk atau {{ic|set <BOOT_PART_NUM> bios_grub on}} di GNU Parted.<br />
<br />
{{Note|Partisi ini harus di buat sebelum grub_bios-install atau grub-setup dijalankan atau sebelum langka '''Install Bootloader''' dari penginstallan Archlinux (jika GRUB2 BIOS terpilih sebagai bootloader).}}<br />
<br />
===== Instruksi spesifik [[MBR]] dikenal sebagai pemartisian msdos =====<br />
<br />
Biasa post-MBR (setelah 512 byte area MBR dan sebelum dimulainya partisi pertama) di banyak sistem pemartisian MBR (atau msdos disklabel) adalah 32 KiB ketika kompabilitas DOS telah terpenuhi. Akan tetapi sebuah post-MBR sejumlah 1 atau 2 MiB direkomendasikan untuk memberikan ruang yang cukup untuk core.img yang terembed ( https://bugs.archlinux.org/task/24103 ). Disarankan untuk menggunakan pemartisi yang mendukung alokasi partisi 1 MiB untuk mendapat ruang dalam memenuhi sektor non-512 byte. (yang tidak berelasi untuk embed core.img).<br />
<br />
Jika anda tidak melakukan dual-boot dengan MS Windows (semua versi) di sistem BIOS, disarankan untuk menggunakan partisi GPT - [[GUID_Partition_Table#Convert_from_MBR_to_GPT_without_data_loss]]<br />
<br />
{{Catatan|Membuat partisi 2MiB telah disebut diatas SEBELUM anda mengkonversi ke GPT. Jika tidak, gparted tidak akan merubah ukuran partisi boot untuk mengizinkan pembuatannya dan ketika anda reboot grub2 tidak tahu dimana untuk memulai.}}<br />
<br />
==== UEFI systems ====<br />
<br />
===== Create and Mount the UEFI SYSTEM PARTITION =====<br />
<br />
Follow [[Unified_Extensible_Firmware_Interface#Create_an_UEFI_SYSTEM_PARTITION_in_Linux]] for instructions on creating a UEFI SYSTEM PARTITION. Then mount the UEFI SYSTEM PARTITION at {{ic|/boot/efi}}. It should be FAT32 formatted and should be >=200 MiB in size. If you have mounted the UEFISYS partition in some other mountpoint, replace {{ic|/boot/efi}} in the below instructions with that mountpoint:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFISYS_PART_DEVICE> /boot/efi<br />
<br />
Create a <UEFI_SYSTEM_PARTITION>/efi directory if it does not exist:<br />
<br />
# mkdir -p /boot/efi/efi<br />
<br />
== Installation ==<br />
<br />
=== During Arch Linux installation ===<br />
<br />
* Skip the '''Install Bootloader''' step and exit the installer.<br />
* Configure the network:<br />
# aif -p partial-configure-network<br />
This will bring up a prompt; put in the network interface to use, (e.g., eth0) and use DHCP for easy configuration.<br />
* If you did not configure the installed system's {{ic|/etc/resolv.conf}} file during installation (for instance, if you plan to let DHCP generate it later), you will need to copy the one generated by AIF when it configured the network:<br />
# cp /etc/resolv.conf /mnt/etc/resolv.conf<br />
* If you run into network issues in the pacman update step below, you may have needed to install the net-tools package.<br />
* Check and see if the dm_mod module is loaded. If it is not, load it manually. (you might need grub2-bios; install the package if needed):<br />
# lsmod | grep dm_mod<br />
# modprobe dm-mod<br />
{{Note|This is necessary at this point, and cannot be postponed after the chroot. If you try to use modprobe in a chroot environment that has a later kernel version from that of the installing device (at the time of writing, 2.6.33), modprobe will fail. This happens routinely using the Arch "net" installations.}}<br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# mount -t proc /proc /mnt/proc/<br />
# mount -t sysfs /sys /mnt/sys/<br />
# chroot /mnt bash<br />
* Update pacman's database:<br />
# pacman-db-upgrade<br />
* Refresh the package list (with an extra -y flag to force a refresh of all package lists even if they appear to be up to date):<br />
# pacman -Syy<br />
* Install the GRUB2 package as mentioned in the section [[#From a running Arch Linux]]. Note that the dm-mod module has already been loaded, no need to do that again.<br />
<br />
=== From a running Arch Linux ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== Backup Important Data =====<br />
<br />
In general, a grub installation should run smoothly. Sometimes it could mess up your system. You're strongly advised to make a backup before installing grub2-bios.<br />
<br />
* copy grub modules and configuration<br />
<br />
# cp -a /boot/grub /path/to/backup/<br />
<br />
* backup the MBR and GRUB-Legacy stage 1.5<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/first-sectors bs=512 count=63<br />
<br />
Replace /dev/sdaX with you disk path (mostly /dev/sda).<br />
<br />
{{Note|This command backs up the partition table too. Be careful while restoring if you've changed your partition setup in the meantime}}<br />
<br />
To backup only the MBR boot code use:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1<br />
<br />
You could now lightly remove {{ic|/boot/grub}} with:<br />
<br />
# rm -rf /boot/grub<br />
<br />
and follow the instructions below. You know that if things get nasty, you could reboot your system thanks to an installation media and:<br />
<br />
* move old grub-legacy or grub2 files out of the way<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* copy grub back to /boot<br />
<br />
# cp -a /path/to/backup/grub /boot/<br />
<br />
* replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=63<br />
<br />
{{Note|This command also restores the partition table. Be careful.}}<br />
<br />
To restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1<br />
<br />
===== Install grub2-bios package =====<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Pkg|grub}}, if it is installed). Simply installing the package won't update the {{ic|/boot/grub/core.img}} file and the grub2 modules in {{ic|/boot/grub}}. You need to update them manually using grub_bios-install as explained below.<br />
<br />
# pacman -S grub2-bios<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions:<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-bios boot files =====<br />
<br />
There are 3 ways to install grub2 boot files in BIOS booting:<br />
*[[#Install_to_440-byte_MBR_boot_code_region]] (recommended) , <br />
*[[#Install_to_Partition_or_Partitionless_Disk]] (not recommended),<br />
*[[#Generate_core.img_alone]] (safest method, but requires another BIOS bootloader like [[grub-legacy]] or [[syslinux]] to be installed to chainload {{ic|/boot/grub/core.img}} ). <br />
<br />
====== Install to 440-byte MBR boot code region ======<br />
<br />
To setup grub2-bios in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/core.img}} file, and embed it in the 32 KiB (minimum size - varies depending on partition alignment) post-MBR gap (MBR disks) or in BIOS Boot Partition (GPT disks), run:<br />
<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB2 on multiple physical disks. <br />
<br />
The {{ic|--no-floppy}} tells grub2-bios utilities not to search for any floppy devices which reduces the overall execution time of grub_bios-install on many systems (it will also prevent the issue below from occurring). Otherwise you get an error that looks like this:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
{{Warning|Make sure that you check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic| boot-directory}} parameter creates another {{ic|/boot}} folder inside of boot. A wrong install would look like this {{ic|/boot/boot/grub}} !}}.<br />
<br />
====== Install to Partition or Partitionless Disk ======<br />
<br />
{{Note|grub2-bios (any version - including upstream bzr repo) does not encourage installation to a partition boot sector or a partitionless disk like grub-legacy or syslinux does. Neither do the Arch devs.}}<br />
<br />
To setup grub2-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example /dev/sda1 as the /boot partition)<br />
<br />
# chattr -i /boot/grub/core.img<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --force --debug /dev/sda1<br />
# chattr +i /boot/grub/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating core.img).<br />
<br />
grub_bios-install will give out warnings like which should give you the idea of what might go wrong with this approach.<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and grub-setup will not setup its boot code in the partition boot sector.<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why grub-setup does not by default allow this is because in case of partition or a partitionless disk is that grub2-bios relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/core.img}} needs to be set only if grub2-bios is installed to a partition boot sector or a partitionless disk, not in case of installtion to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
====== Generate core.img alone ======<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/core.img}} file WITHOUT embedding any grub2-bios bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to grub_bios-install:<br />
<br />
# grub_bios-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
You can then chainload grub2's core.img from grub-legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
===== Generate GRUB2 BIOS Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2 complains about "no suitable mode found" while booting, go to [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB2 {{ic|/boot/grub/grub.cfg}} configfile and simply rebooted into GRUB2 Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB2 {{ic|/boot/grub/grub.cfg}} configfile.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
===== Multiboot in BIOS =====<br />
<br />
====== Boot Microsoft Windows installed in BIOS-MBR mode ======<br />
<br />
{{Note|GRUB2 supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
Find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the bootmgr and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/Windows/bootmgr}}:<br />
<br />
# grub-probe --target=fs_uuid /media/Windows/bootmgr<br />
69B235F6749E84CE<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} and regenerate grub.cfg with grub-mkconfig as explained above to chainload Windows (Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
menuentry "Microsoft Windows 7 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/bootmgr<br />
}<br />
<br />
For Windows XP<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/ntldr<br />
}<br />
<br />
==== [[UEFI]] systems ====<br />
<br />
===== Install grub2-uefi package =====<br />
<br />
{{Note|Unless specified as EFI 1.x , EFI and UEFI terms are used interchangeably to denote UEFI 2.x firmware. Also unless stated explicitely, the instructions are general and not Mac specific. Some of them may not work or may be different in Macs. Apple's EFI implementation is neither a EFI 1.x version nor UEFI 2.x version but mixes up both. This kind of firmware does not fall under any one UEFI Specification version and is therefore not a standard UEFI firmware.}}<br />
<br />
GRUB2 UEFI bootloader is available in Arch Linux only from version 1.99~rc1. To install, first [https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Detecting_UEFI_Firmware_Arch Detect which UEFI firmware arch] you have (either x86_64 or i386).<br />
<br />
Depending on that, install the appropriate package<br />
<br />
For 64-bit aka x86_64 UEFI firmware:<br />
# pacman -S grub2-efi-x86_64<br />
<br />
For 32-bit aka i386 UEFI firmware:<br />
# pacman -S grub2-efi-i386<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
{{Note|Simply installing the package won't update the grub.efi file and the grub2 modules in the UEFI System Partition. You need to update the grub.efi file and the grub2 modules in the UEFI System Partition manually using grub_efi_${UEFI_ARCH}-install as explained below.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-uefi boot files =====<br />
<br />
====== Install to UEFI SYSTEM PARTITION ======<br />
<br />
{{Note|The below commands assume you are using {{ic|grub2-efi-x86_64}} (for {{ic|grub2-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands).}}<br />
<br />
The UEFI system partition will need to be mounted at /boot/efi for the GRUB2 install script to detect it.<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application and its modules to {{ic|/boot/efi/efi/arch_grub}} using <br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
If you want to install grub2 modules and grub.cfg at the directory {{ic|/boot/grub}} and only the grubx64.efi application at {{ic|/boot/efi/efi/arch_grub}} use<br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
In this case grub2-efi-x86_64 will be installed into /boot/grub, making the behavior consistent with the BIOS verion of GRUB2, but this is not recommended if you use both grub2-bios and grub2-efi-x86_64 in your system, as this will overwrite grub2-bios modules in /boot/grub .<br />
<br />
The {{ic|--root-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the grubx64.efi file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which grub.cfg should be created).<br />
<br />
The actual paths are<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
Note the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to <boot-directory>/grub .<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == <boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/core.efi</nowiki>}} .<br />
<br />
{{Note| This behavior of --root-directory , --boot-directory , and --bootloader-id options are specific to UEFI systems and does not occur is BIOS mode. In grub_bios-install, --root-directory is deprecated and --bootloader-id option does not exist.}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for grub_efi_x86_64-install to install grubx64.efi in it, which will be launched by the firmware (using th efibootmgr created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub_efi_x86_64-install}} command unlike the case of setting up grub2 for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a grub.cfg file by following [[#Generate_GRUB2_UEFI_Config_file]] and [[#Create_GRUB2_entry_in_the_Firmware_Boot_Manager]].<br />
<br />
===== Create GRUB2 entry in the Firmware Boot Manager =====<br />
<br />
====== Non-Mac UEFI systems ======<br />
<br />
grub_efi_${UEFI_ARCH}-install will ensure that {{ic|/boot/efi/efi/arch_grub/grubx64.efi}} is launched by default if it detects {{ic|efibootmgr}} and if it is able to access UEFI Runtime Services. Follow [[Unified_Extensible_Firmware_Interface#efibootmgr]] for more info.<br />
<br />
If you have problems running GRUB2 in UEFI mode you can try the following (worked on an ASUS Z68 mainboard):<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shell/shellx64.efi<br />
<br />
After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The grub2 menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry (see above).<br />
<br />
====== Apple Mac EFI systems ======<br />
<br />
{{Note| TODO: Grub upstream bzr mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes}}<br />
{{Note| TODO: Fedora's mactel-boot ( https://bugzilla.redhat.com/show_bug.cgi?id&#61;755093 )}}<br />
<br />
Use bless command from within Mac OS X to set {{ic|grubx64.efi}} as the default boot option. You can also boot from the Mac OS X install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI System Partition:<br />
<br />
# cd /Volumes<br />
# mkdir efi<br />
# mount -t msdos /dev/disk0s1 /Volumes/efi<br />
<br />
Then run bless on {{ic|grub.efi}} and on the EFI partition to set them as the default boot options.<br />
<br />
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
<br />
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.<br />
<br />
===== Generate GRUB2 UEFI Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="<boot-directory>/grub" grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/efi</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/efi/efi/grub" grub-mkconfig -o /boot/efi/efi/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
This is independent of the value of --bootloader-id option. The {{ic|GRUB_PREFIX}} env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2-uefi complains about "no suitable mode found" while booting, try [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
===== Create GRUB2 Standalone UEFI Application =====<br />
<br />
It is possible to create a grubx64_standalone.efi application which has all the modules embeddded in a memdisk within the uefi application, thus removing the need for having a separate directory populated with all the grub2 uefi modules and other related files. This is done using the grub-mkstandalone command which is included in extra/grub2-common >= 1:1.99-6 package.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The grubx64_standalone.efi file expects grub.cfg to be within its $prefix which is (memdisk)/boot/grub. The memdisk is embedded within the efi app. The grub-mkstandlone script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the grub.cfg at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the grub-mkstandalone script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}} . That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to includ the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what grub.efi expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/efi/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB2 entry in the Firmware Boot Manager]].<br />
<br />
===== Multiboot in UEFI =====<br />
<br />
====== Chainload Microsoft Windows x86_64 UEFI-GPT ======<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/efi/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/boot/grub/grub.cfg}} OR {{ic|/boot/efi/efi/grub/grub.cfg}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|If GRUB2 was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in the BIOS version of GRUB2.}}<br />
<br />
=== Automatically generating using grub-mkconfig (Recommended) ===<br />
<br />
The GRUB2 {{ic|menu.1st}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. grub-mkconfig uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually by editing {{ic|/etc/grub.d/40_custom}}<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc<br />
|/boot/grub/grub.cfg<br />
|<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
''NOTE: If you want GRUB2 to automatically search for other systems, for example as in Ubuntu. Then you may need to install {{Pkg|os-prober}}.''<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}}. The entries in this file will be automatically added when running '''grub-mkconfig'''.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader (hd0,3)+1<br />
}<br />
<br />
If the windows bootloader is on an entirely different harddrive than grub, it may be necessary to trick Windows into believing that it is in fact the first harddrive. This was possible in the old grub with {{ic|map}} and is now done with {{ic|drivemap}}. Assume grub is on {{ic|hd0}} and windows on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, grub2 graphical terminal, gfxterm, with proper video mode, gfxmode, in grub2. This can be seen in the section [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]]. This video mode is passed by grub2 to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
====Setting the framebuffer resolution ====<br />
<br />
Grub2 can set the framebuffer for both grub2 itself and the kernel. The old ''vga='' way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen.}}<br />
{{Note|To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at grub2 prompt you can use the {{ic|1=vbeinfo}} command.}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}<br />
<br />
====915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
In the following I will proceed with the example for my system. Please adjust the recipe for your needs. First you need to find a video mode which will be modified later. For that, run {{ic|915resolution}} in GRUB2 command shell.<br />
915resolution -l<br />
The output will be something like:<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
...<br />
Mode 30 : 640x480, 8 bits/pixel<br />
...<br />
Next, our purpose is to overwrite mode 30. (You can choose what ever mode you want.) In the file {{ic|/etc/grub.d/00_header}} just before the {{ic|set gfxmode&#61;${GRUB_GFXMODE} }} line insert<br />
915resolution 30 1440 900<br />
Here we are overwriting the mode {{ic| 30}} with {{ic|1440x900}} resolution. Lastly we need to set {{ic | GRUB_GFXMODE}} as described earlier, regenerate grub configuration file and reboot to test changes.<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
sudo reboot<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{ic|unicode.pf2}}, or, as only ascii characters under the name {{ic|ascii.pf2}}. <br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [https://wiki.archlinux.org/index.php/GRUB2#Setting_the_framebuffer_resolution framebuffer resolution].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/archlinux.tga"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
<br />
(archlinux.tga is a placeholder; put your file name there)<br />
<br />
{{Note|If you have installed Grub on a separate partition, {{ic|/boot/grub/archlinux.tga}} becomes {{ic|/grub/archlinux.tga}}.}}<br />
<br />
To generate the changes and add the information into grub.cfg, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see "Found background image..." in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the grub.cfg file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in /etc/default/grub are correct.<br />
* The image is of the proper size and format (tga, png, 8-bit jpg).<br />
* The image was saved in the RGB mode, and is not indexed.<br />
* The console mode is not enabled in /etc/default/grub.<br />
* The command grub-mkconfig must be executed to place the background image information into the /boot/grub/grub.cfg file.<br />
<br />
====Menu colors====<br />
<br />
As in Grub (0.9x), you can change the menu colors in Grub2. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html#Theme-file-format.<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
====Hidden menu====<br />
<br />
One of the unique features of Grub2 is hiding/skipping the menu and showing it by holding "Shift" when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== Raid ====<br />
<br />
Grub2 provides convenient handling of raid-volumes. You need to add:<br />
insmod raid<br />
<br />
which allows you to address the volume natively. E.g. {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned raid-volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
You can use UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}} and {{ic|/dev/hd*}} scheming. It has the advantage of detecting partitions by their unique UUIDs, which is needed by some people booting with complicated partition setups.<br />
<br />
UUIDs are used by default in the recent versions of grub2 - there is no downside in it anyway except that you need to re-generate the {{ic|grub.cfg}} file every time you resize or reformat your partitions. Remember this when modifying partitions with Live-CD.<br />
<br />
The recent versions of grub2 use UUIDs by default. You can re-enable the use of UUIDS by simply commenting the UUID line (this is also what it looks like by default):<br />
#GRUB_DISABLE_LINUX_UUID=true<br />
you can also just set the value as {{ic|false}} as shown here:<br />
GRUB_DISABLE_LINUX_UUID=false<br />
<br />
Either way, do not forget to generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --no-floppy --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
Grub2 can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the setting of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that grub will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
Note that manually added menu items, eg Windows in {{ic|/etc/grub.d/40_custom}}, will need {{ic|savedefault}} added. Remember to regenerate your configuration file.<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB2 so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB2's configuration files. To do this, run the command {{ic|grub-mkpasswd_pbkdf2}}. Enter a password and confirm it. The output will look like this:<br />
<br />
{{bc|<nowiki><br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A</nowiki>}}Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{bc|<nowiki>cat << EOF<br />
<br />
set superusers="username"<br />
password_pbkdf2 username <password><br />
<br />
EOF</nowiki>}}<br />
where <password> is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB2 command line and boot parameters are now protected.<br />
<br />
==== Root Encryption ====<br />
<br />
To let GRUB2 automatically add the kernel parameters for root encryption,<br />
add "cryptdevice=/dev/yourdevice:label" to GRUB_CMDLINE_LINUX in /etc/defaults/grub .<br />
<br />
Example with root mapped to /dev/mapper/root :<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
=== Booting an ISO Directly From Grub2 ===<br />
Edit {{ic|/etc/grub.d/40_custom}} to add an entry for the target ISO. When finished, update the grub menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. Also adjust the img_dev line to match this same location.}}<br />
<br />
menuentry "Archlinux-2011.08.19-netinstall-x86_64.iso" {<br />
set isofile="/archives/archlinux-2011.08.19-netinstall-x86_64.iso"<br />
loopback loop (hd0,7)$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201108 img_dev=/dev/sda7 img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. }}<br />
<br />
menuentry "ubuntu-11.04-desktop-amd64.iso" {<br />
set isofile="/path/to/ubuntu-11.04-desktop-amd64.iso"<br />
loopback loop (hdX,Y)$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB2 supports pager for reading commands that provide long output (like the help command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB2 command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed from [[AUR]]<br />
* [https://aur.archlinux.org/packages.php?ID=44020 grub-customizer] (requires gettext gksu gtkmm hicolor-icon-theme openssl)<br />
*:Customize the bootloader (GRUB2 or BURG)<br />
* [http://kde-apps.org/content/show.php?content=139643 grub2-editor] (requires kdelibs)<br />
*:A KDE4 control module for configuring the GRUB2 bootloader<br />
* [http://kde-apps.org/content/show.php?content=137886 kcm-grub2] (requires kdelibs python2-qt kdebindings-python)<br />
*:This Kcm module manages the most common settings of Grub2.<br />
* [http://sourceforge.net/projects/startup-manager/ startupmanager] (requires gnome-python imagemagick yelp python2 xorg-xrandr)<br />
*:GUI app for changing the settings of GRUB, GRUB2, Usplash and Splashy<br />
<br />
== parttool or legacy hide/unhide ==<br />
<br />
If you have a win9x paradigm with hidden C disks GRUB legacy had the hide/unhide feature. In GRUB2 this has been replaced by parttool. For example, to boot the third C disk of three win9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then run:<br />
# grub-install /dev/sda --no-floppy<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUID's and basic scripting ==<br />
<br />
If you like the idea of using UUID's to avoid unreliable BIOS mappings or are struggling with Grub's syntax, here is an example boot menu item that uses UUID's and a small script to direct Grub to the proper disk partitions for your system. All you need to do is replace the UUID's in the sample with the correct UUID's for your system. (The example applies to a system with a boot and root partition. You will obviously need to modify the Grub configuration if you have additional partitions.)<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 <br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables <br />
search --fs-uuid --no-floppy --set=root $the_root_uuid <br />
search --fs-uuid --no-floppy --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== Enable GRUB2 debug messages ===<br />
<br />
Add<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== Correct GRUB2 No Suitable Mode Found Error ===<br />
<br />
If you get this error when booting any menuentry<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize grub2 graphical terminal (gfxterm) with proper video mode (gfxmode) in grub2. This video mode is passed by grub2 to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the grub2 video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in)<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB2_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems. If GRUB2 UEFI was installed with {{ic|1=--boot-directory=/boot/efi/efi}} set, then the directory is {{ic|/boot/efi/efi/grub/}}. <br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB2_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the unifont.pf2 file and then copy it to ${GRUB2_PREFIX_DIR}.<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable grub2 to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang:<br />
<br />
BIOS systems<br />
<br />
insmod vbe<br />
<br />
UEFI systems<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI)<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in ${GRUB2_PREFIX_DIR}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#MBR_aka_msdos_partitioning_specific_instructions]]<br />
<br />
=== UEFI GRUB2 drops to shell ===<br />
<br />
If grub loads but drop you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB2 UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== UEFI GRUB2 not loaded ===<br />
In some cases the EFI may fail to load grub correctly. Provided everything is set up correctly, the output of<br />
efibootmgr -v<br />
might look something like this:<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
If everything works correctly, the EFI would now automatically load grub.<br><br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving grub to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for grub should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
If trying to boot windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move grub's device configuration and let it reconfigure.<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
Grub-mkconfig should now mention all found boot options including windows. If it works, remove /boot/grub/device.map-old.<br />
<br />
== References ==<br />
<br />
# Official GRUB2 Manual - http://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for Grub2 - https://help.ubuntu.com/community/Grub2<br />
# GRUB2 wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]<br />
<br />
== External Links ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_bios.sh A Linux Bash Shell script to compile and install GRUB2 for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_uefi.sh A Linux Bash Shell script to compile and install GRUB2 for UEFI from BZR Source]</div>Martadinatahttps://wiki.archlinux.org/index.php?title=GRUB_(Bahasa_Indonesia)&diff=189338GRUB (Bahasa Indonesia)2012-03-13T11:13:03Z<p>Martadinata: /* Instruksi spesifik untuk GPT */</p>
<hr />
<div>[[Category:Boot loaders (English)]]<br />
{{i18n|GRUB2}}<br />
[[fr:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|GRUB2 adalah generasi terbaru dari grub.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Burg}} - Burg adalah boot loader baru yang berdasar atas GRUB2. Yang menggunakan format object dimana hal ini membuat BURG dapat di gunakan di berbagai Operating System termasuk Linux/Windows/OSX/Solaris/FreeBSD, dll. Juga mempunyai tampilan untuk di konfigurasi yang unik baik melalui text mode atau GUI mode.<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/ GRUB2] generasi berikutnya dari GRUB. GRUB2 adalah derivasi dari [http://www.nongnu.org/pupa/ PUPA] yang merupakan proyek pengembangand dari GRUB. GRUB 2 telah di tulis ulang untuk membersihkan segalanya dan memberikan modularitas dan portabilitas. [http://www.gnu.org/software/grub/grub-faq.en.html#q1].<br />
<br />
Secara singkat, ''bootloader'' adalah program software pertama yang berjalan ketika komputer pertama dinyalakan. ''Bootloader'' bertanggung jawab sebagai pemicu dan pengirim kontrol ke Kernel Linux. Kernel, selanjutnya, menginisialisasi seluruh sistem operasi.<br />
<br />
{{Note|grub2 dari 1.99 dan selanjutnya telah mendukung btrfs sebagai root (tanpa /boot filesistem yang terpisah), tetapi tingkat kompresinya terbatas pada zlib, tidak LZO. Dukungan kompresi LZO hanya terdapat pada repo bzr upstream.}}<br />
<br />
{{Note|Penginstall standar AIF (Arch Installation Framework) berdasar pada [[Archiso]] tidak mendukung penginstallan grub2-bios atau grub2-uefi. Akan tetapi [[Archboot]] iso mendukung penginstallan grub2-bios dan grub2-uefi.}}<br />
<br />
== Prefasi ==<br />
<br />
Walaupun, [[GRUB]] (versi 0.9x) adalah bootloader standar Arch Linux, GRUB dapat diganti menjadi 'grub legacy' by upstream. Dimana telah menjadi GRUB2 dan [[Syslinux]] di beberapa distribusi. Versi lanjutan merekomendasikan GRUB2 >=1.99 di atas versi grub-legacy.<br />
<br />
=== Catatan untuk pengguna GRUB Legacy ===<br />
<br />
* Ada perbedaan perinta dari GRUB dan GRUB2. Perlu di lihat terlebih dahulu [http://www.gnu.org/software/grub/manual/grub.html#Commands GRUB2 commands] sebelum melanjutkan (contoh : "find" telah di ganti dengan "search").<br />
<br />
* GRUB2 sekarang ''modular'' dan tidak lagi memerlukan "stage 1.5". Sebagai hasilnya, bootloader itu sendiri menjadi terbatas -- modul-modul diambil dari hard disk sebagai kebutuhan untuk meluaskan fungsionalitas. (contoh : dukungan untuk [[LVM]] atau RAID).<br />
<br />
* Penamaan perangkat telah berubah antara GRUB dan GRUB2. Partisi diurut dari nomor 1 dari pada 0 ketika disk masih bernomor 0. Sebagai contoh, {{ic|/dev/sda1}} akan menjadi {{ic|(hd0,msdos1)}} (untuk MBR) atau {{ic|(hd0,gpt1)}} (for GPT) ketika GRUB2 dipakai.<br />
<br />
=== Kebutuhan GRUB2 ===<br />
<br />
==== System BIOS ====<br />
<br />
===== Instruksi spesifik untuk [[GPT]] =====<br />
<br />
GRUB2 di konfigurasi BIOS-GPT membutuhkan sebuah Partisi BIOS Boot yang terembed pada core.img di kehilangannya post-MBR di sistem yang terpartisi secara GPT (yang menyebabkan MBR diambil alih oleh GPT Primary Header dan Primary Partition table). Partisi ini digunakan oleh GRUB2 hanya pada pengaturan BIOS-GPT. Tidak ada partisi jenis ini dalam kasus partisi MBR (setidaknya tidak untuk GRUB2). Partisi ini juga tidak diperlukan jika sistem berbasiskan UEFI, kerana tidak ada bootsectors yang mengambil tempat dalam kasus ini. Syslinux tidak memerlukan partisi ini.<br />
<br />
Untuk konfigurasi BIOS-GPT, buat sebuah partisi sebesar 2 MiB menggunaka cgdisk atau GNU Parted tanpa jenis filesistem. Lokasi partisi ini tidak menjadi masalah tetapi partisi ini haruslah berada diantara yang pertama dari area 2 TiB. Sangat disarankan untuk menempatkannya di awal disk sebelum partisi /boot. Atur jenis partisi menjadi "EF02" di cgdisk atau {{ic|set <BOOT_PART_NUM> bios_grub on}} di GNU Parted.<br />
<br />
{{Note|Partisi ini harus di buat sebelum grub_bios-install atau grub-setup dijalankan atau sebelum langka '''Install Bootloader''' dari penginstallan Archlinux (jika GRUB2 BIOS terpilih sebagai bootloader).}}<br />
<br />
===== [[MBR]] aka msdos partitioning specific instructions =====<br />
<br />
Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 32 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding grub2's core.img ( https://bugs.archlinux.org/task/24103 ). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of core.img).<br />
<br />
If you do not dual-boot with MS Windows (any version) in BIOS systems, it is advisable to switch to GPT partitioning - [[GUID_Partition_Table#Convert_from_MBR_to_GPT_without_data_loss]]<br />
<br />
{{Note|Create the 2MiB partition mentioned above BEFORE you convert to GPT. If you do not, gparted will not resize your boot partition to allow its creation, and when you reboot grub2 will not know where to look.}}<br />
<br />
==== UEFI systems ====<br />
<br />
===== Create and Mount the UEFI SYSTEM PARTITION =====<br />
<br />
Follow [[Unified_Extensible_Firmware_Interface#Create_an_UEFI_SYSTEM_PARTITION_in_Linux]] for instructions on creating a UEFI SYSTEM PARTITION. Then mount the UEFI SYSTEM PARTITION at {{ic|/boot/efi}}. It should be FAT32 formatted and should be >=200 MiB in size. If you have mounted the UEFISYS partition in some other mountpoint, replace {{ic|/boot/efi}} in the below instructions with that mountpoint:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFISYS_PART_DEVICE> /boot/efi<br />
<br />
Create a <UEFI_SYSTEM_PARTITION>/efi directory if it does not exist:<br />
<br />
# mkdir -p /boot/efi/efi<br />
<br />
== Installation ==<br />
<br />
=== During Arch Linux installation ===<br />
<br />
* Skip the '''Install Bootloader''' step and exit the installer.<br />
* Configure the network:<br />
# aif -p partial-configure-network<br />
This will bring up a prompt; put in the network interface to use, (e.g., eth0) and use DHCP for easy configuration.<br />
* If you did not configure the installed system's {{ic|/etc/resolv.conf}} file during installation (for instance, if you plan to let DHCP generate it later), you will need to copy the one generated by AIF when it configured the network:<br />
# cp /etc/resolv.conf /mnt/etc/resolv.conf<br />
* If you run into network issues in the pacman update step below, you may have needed to install the net-tools package.<br />
* Check and see if the dm_mod module is loaded. If it is not, load it manually. (you might need grub2-bios; install the package if needed):<br />
# lsmod | grep dm_mod<br />
# modprobe dm-mod<br />
{{Note|This is necessary at this point, and cannot be postponed after the chroot. If you try to use modprobe in a chroot environment that has a later kernel version from that of the installing device (at the time of writing, 2.6.33), modprobe will fail. This happens routinely using the Arch "net" installations.}}<br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# mount -t proc /proc /mnt/proc/<br />
# mount -t sysfs /sys /mnt/sys/<br />
# chroot /mnt bash<br />
* Update pacman's database:<br />
# pacman-db-upgrade<br />
* Refresh the package list (with an extra -y flag to force a refresh of all package lists even if they appear to be up to date):<br />
# pacman -Syy<br />
* Install the GRUB2 package as mentioned in the section [[#From a running Arch Linux]]. Note that the dm-mod module has already been loaded, no need to do that again.<br />
<br />
=== From a running Arch Linux ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== Backup Important Data =====<br />
<br />
In general, a grub installation should run smoothly. Sometimes it could mess up your system. You're strongly advised to make a backup before installing grub2-bios.<br />
<br />
* copy grub modules and configuration<br />
<br />
# cp -a /boot/grub /path/to/backup/<br />
<br />
* backup the MBR and GRUB-Legacy stage 1.5<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/first-sectors bs=512 count=63<br />
<br />
Replace /dev/sdaX with you disk path (mostly /dev/sda).<br />
<br />
{{Note|This command backs up the partition table too. Be careful while restoring if you've changed your partition setup in the meantime}}<br />
<br />
To backup only the MBR boot code use:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1<br />
<br />
You could now lightly remove {{ic|/boot/grub}} with:<br />
<br />
# rm -rf /boot/grub<br />
<br />
and follow the instructions below. You know that if things get nasty, you could reboot your system thanks to an installation media and:<br />
<br />
* move old grub-legacy or grub2 files out of the way<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* copy grub back to /boot<br />
<br />
# cp -a /path/to/backup/grub /boot/<br />
<br />
* replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=63<br />
<br />
{{Note|This command also restores the partition table. Be careful.}}<br />
<br />
To restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1<br />
<br />
===== Install grub2-bios package =====<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Pkg|grub}}, if it is installed). Simply installing the package won't update the {{ic|/boot/grub/core.img}} file and the grub2 modules in {{ic|/boot/grub}}. You need to update them manually using grub_bios-install as explained below.<br />
<br />
# pacman -S grub2-bios<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions:<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-bios boot files =====<br />
<br />
There are 3 ways to install grub2 boot files in BIOS booting:<br />
*[[#Install_to_440-byte_MBR_boot_code_region]] (recommended) , <br />
*[[#Install_to_Partition_or_Partitionless_Disk]] (not recommended),<br />
*[[#Generate_core.img_alone]] (safest method, but requires another BIOS bootloader like [[grub-legacy]] or [[syslinux]] to be installed to chainload {{ic|/boot/grub/core.img}} ). <br />
<br />
====== Install to 440-byte MBR boot code region ======<br />
<br />
To setup grub2-bios in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/core.img}} file, and embed it in the 32 KiB (minimum size - varies depending on partition alignment) post-MBR gap (MBR disks) or in BIOS Boot Partition (GPT disks), run:<br />
<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB2 on multiple physical disks. <br />
<br />
The {{ic|--no-floppy}} tells grub2-bios utilities not to search for any floppy devices which reduces the overall execution time of grub_bios-install on many systems (it will also prevent the issue below from occurring). Otherwise you get an error that looks like this:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
{{Warning|Make sure that you check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic| boot-directory}} parameter creates another {{ic|/boot}} folder inside of boot. A wrong install would look like this {{ic|/boot/boot/grub}} !}}.<br />
<br />
====== Install to Partition or Partitionless Disk ======<br />
<br />
{{Note|grub2-bios (any version - including upstream bzr repo) does not encourage installation to a partition boot sector or a partitionless disk like grub-legacy or syslinux does. Neither do the Arch devs.}}<br />
<br />
To setup grub2-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example /dev/sda1 as the /boot partition)<br />
<br />
# chattr -i /boot/grub/core.img<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --force --debug /dev/sda1<br />
# chattr +i /boot/grub/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating core.img).<br />
<br />
grub_bios-install will give out warnings like which should give you the idea of what might go wrong with this approach.<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and grub-setup will not setup its boot code in the partition boot sector.<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why grub-setup does not by default allow this is because in case of partition or a partitionless disk is that grub2-bios relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/core.img}} needs to be set only if grub2-bios is installed to a partition boot sector or a partitionless disk, not in case of installtion to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
====== Generate core.img alone ======<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/core.img}} file WITHOUT embedding any grub2-bios bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to grub_bios-install:<br />
<br />
# grub_bios-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
You can then chainload grub2's core.img from grub-legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
===== Generate GRUB2 BIOS Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2 complains about "no suitable mode found" while booting, go to [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB2 {{ic|/boot/grub/grub.cfg}} configfile and simply rebooted into GRUB2 Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB2 {{ic|/boot/grub/grub.cfg}} configfile.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
===== Multiboot in BIOS =====<br />
<br />
====== Boot Microsoft Windows installed in BIOS-MBR mode ======<br />
<br />
{{Note|GRUB2 supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
Find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the bootmgr and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/Windows/bootmgr}}:<br />
<br />
# grub-probe --target=fs_uuid /media/Windows/bootmgr<br />
69B235F6749E84CE<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} and regenerate grub.cfg with grub-mkconfig as explained above to chainload Windows (Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
menuentry "Microsoft Windows 7 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/bootmgr<br />
}<br />
<br />
For Windows XP<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/ntldr<br />
}<br />
<br />
==== [[UEFI]] systems ====<br />
<br />
===== Install grub2-uefi package =====<br />
<br />
{{Note|Unless specified as EFI 1.x , EFI and UEFI terms are used interchangeably to denote UEFI 2.x firmware. Also unless stated explicitely, the instructions are general and not Mac specific. Some of them may not work or may be different in Macs. Apple's EFI implementation is neither a EFI 1.x version nor UEFI 2.x version but mixes up both. This kind of firmware does not fall under any one UEFI Specification version and is therefore not a standard UEFI firmware.}}<br />
<br />
GRUB2 UEFI bootloader is available in Arch Linux only from version 1.99~rc1. To install, first [https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Detecting_UEFI_Firmware_Arch Detect which UEFI firmware arch] you have (either x86_64 or i386).<br />
<br />
Depending on that, install the appropriate package<br />
<br />
For 64-bit aka x86_64 UEFI firmware:<br />
# pacman -S grub2-efi-x86_64<br />
<br />
For 32-bit aka i386 UEFI firmware:<br />
# pacman -S grub2-efi-i386<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
{{Note|Simply installing the package won't update the grub.efi file and the grub2 modules in the UEFI System Partition. You need to update the grub.efi file and the grub2 modules in the UEFI System Partition manually using grub_efi_${UEFI_ARCH}-install as explained below.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-uefi boot files =====<br />
<br />
====== Install to UEFI SYSTEM PARTITION ======<br />
<br />
{{Note|The below commands assume you are using {{ic|grub2-efi-x86_64}} (for {{ic|grub2-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands).}}<br />
<br />
The UEFI system partition will need to be mounted at /boot/efi for the GRUB2 install script to detect it.<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application and its modules to {{ic|/boot/efi/efi/arch_grub}} using <br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
If you want to install grub2 modules and grub.cfg at the directory {{ic|/boot/grub}} and only the grubx64.efi application at {{ic|/boot/efi/efi/arch_grub}} use<br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
In this case grub2-efi-x86_64 will be installed into /boot/grub, making the behavior consistent with the BIOS verion of GRUB2, but this is not recommended if you use both grub2-bios and grub2-efi-x86_64 in your system, as this will overwrite grub2-bios modules in /boot/grub .<br />
<br />
The {{ic|--root-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the grubx64.efi file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which grub.cfg should be created).<br />
<br />
The actual paths are<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
Note the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to <boot-directory>/grub .<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == <boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/core.efi</nowiki>}} .<br />
<br />
{{Note| This behavior of --root-directory , --boot-directory , and --bootloader-id options are specific to UEFI systems and does not occur is BIOS mode. In grub_bios-install, --root-directory is deprecated and --bootloader-id option does not exist.}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for grub_efi_x86_64-install to install grubx64.efi in it, which will be launched by the firmware (using th efibootmgr created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub_efi_x86_64-install}} command unlike the case of setting up grub2 for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a grub.cfg file by following [[#Generate_GRUB2_UEFI_Config_file]] and [[#Create_GRUB2_entry_in_the_Firmware_Boot_Manager]].<br />
<br />
===== Create GRUB2 entry in the Firmware Boot Manager =====<br />
<br />
====== Non-Mac UEFI systems ======<br />
<br />
grub_efi_${UEFI_ARCH}-install will ensure that {{ic|/boot/efi/efi/arch_grub/grubx64.efi}} is launched by default if it detects {{ic|efibootmgr}} and if it is able to access UEFI Runtime Services. Follow [[Unified_Extensible_Firmware_Interface#efibootmgr]] for more info.<br />
<br />
If you have problems running GRUB2 in UEFI mode you can try the following (worked on an ASUS Z68 mainboard):<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shell/shellx64.efi<br />
<br />
After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The grub2 menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry (see above).<br />
<br />
====== Apple Mac EFI systems ======<br />
<br />
{{Note| TODO: Grub upstream bzr mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes}}<br />
{{Note| TODO: Fedora's mactel-boot ( https://bugzilla.redhat.com/show_bug.cgi?id&#61;755093 )}}<br />
<br />
Use bless command from within Mac OS X to set {{ic|grubx64.efi}} as the default boot option. You can also boot from the Mac OS X install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI System Partition:<br />
<br />
# cd /Volumes<br />
# mkdir efi<br />
# mount -t msdos /dev/disk0s1 /Volumes/efi<br />
<br />
Then run bless on {{ic|grub.efi}} and on the EFI partition to set them as the default boot options.<br />
<br />
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
<br />
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.<br />
<br />
===== Generate GRUB2 UEFI Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="<boot-directory>/grub" grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/efi</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/efi/efi/grub" grub-mkconfig -o /boot/efi/efi/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
This is independent of the value of --bootloader-id option. The {{ic|GRUB_PREFIX}} env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2-uefi complains about "no suitable mode found" while booting, try [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
===== Create GRUB2 Standalone UEFI Application =====<br />
<br />
It is possible to create a grubx64_standalone.efi application which has all the modules embeddded in a memdisk within the uefi application, thus removing the need for having a separate directory populated with all the grub2 uefi modules and other related files. This is done using the grub-mkstandalone command which is included in extra/grub2-common >= 1:1.99-6 package.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The grubx64_standalone.efi file expects grub.cfg to be within its $prefix which is (memdisk)/boot/grub. The memdisk is embedded within the efi app. The grub-mkstandlone script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the grub.cfg at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the grub-mkstandalone script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}} . That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to includ the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what grub.efi expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/efi/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB2 entry in the Firmware Boot Manager]].<br />
<br />
===== Multiboot in UEFI =====<br />
<br />
====== Chainload Microsoft Windows x86_64 UEFI-GPT ======<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/efi/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/boot/grub/grub.cfg}} OR {{ic|/boot/efi/efi/grub/grub.cfg}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|If GRUB2 was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in the BIOS version of GRUB2.}}<br />
<br />
=== Automatically generating using grub-mkconfig (Recommended) ===<br />
<br />
The GRUB2 {{ic|menu.1st}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. grub-mkconfig uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually by editing {{ic|/etc/grub.d/40_custom}}<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc<br />
|/boot/grub/grub.cfg<br />
|<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
''NOTE: If you want GRUB2 to automatically search for other systems, for example as in Ubuntu. Then you may need to install {{Pkg|os-prober}}.''<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}}. The entries in this file will be automatically added when running '''grub-mkconfig'''.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader (hd0,3)+1<br />
}<br />
<br />
If the windows bootloader is on an entirely different harddrive than grub, it may be necessary to trick Windows into believing that it is in fact the first harddrive. This was possible in the old grub with {{ic|map}} and is now done with {{ic|drivemap}}. Assume grub is on {{ic|hd0}} and windows on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, grub2 graphical terminal, gfxterm, with proper video mode, gfxmode, in grub2. This can be seen in the section [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]]. This video mode is passed by grub2 to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
====Setting the framebuffer resolution ====<br />
<br />
Grub2 can set the framebuffer for both grub2 itself and the kernel. The old ''vga='' way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen.}}<br />
{{Note|To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at grub2 prompt you can use the {{ic|1=vbeinfo}} command.}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}<br />
<br />
====915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
In the following I will proceed with the example for my system. Please adjust the recipe for your needs. First you need to find a video mode which will be modified later. For that, run {{ic|915resolution}} in GRUB2 command shell.<br />
915resolution -l<br />
The output will be something like:<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
...<br />
Mode 30 : 640x480, 8 bits/pixel<br />
...<br />
Next, our purpose is to overwrite mode 30. (You can choose what ever mode you want.) In the file {{ic|/etc/grub.d/00_header}} just before the {{ic|set gfxmode&#61;${GRUB_GFXMODE} }} line insert<br />
915resolution 30 1440 900<br />
Here we are overwriting the mode {{ic| 30}} with {{ic|1440x900}} resolution. Lastly we need to set {{ic | GRUB_GFXMODE}} as described earlier, regenerate grub configuration file and reboot to test changes.<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
sudo reboot<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{ic|unicode.pf2}}, or, as only ascii characters under the name {{ic|ascii.pf2}}. <br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [https://wiki.archlinux.org/index.php/GRUB2#Setting_the_framebuffer_resolution framebuffer resolution].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/archlinux.tga"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
<br />
(archlinux.tga is a placeholder; put your file name there)<br />
<br />
{{Note|If you have installed Grub on a separate partition, {{ic|/boot/grub/archlinux.tga}} becomes {{ic|/grub/archlinux.tga}}.}}<br />
<br />
To generate the changes and add the information into grub.cfg, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see "Found background image..." in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the grub.cfg file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in /etc/default/grub are correct.<br />
* The image is of the proper size and format (tga, png, 8-bit jpg).<br />
* The image was saved in the RGB mode, and is not indexed.<br />
* The console mode is not enabled in /etc/default/grub.<br />
* The command grub-mkconfig must be executed to place the background image information into the /boot/grub/grub.cfg file.<br />
<br />
====Menu colors====<br />
<br />
As in Grub (0.9x), you can change the menu colors in Grub2. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html#Theme-file-format.<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
====Hidden menu====<br />
<br />
One of the unique features of Grub2 is hiding/skipping the menu and showing it by holding "Shift" when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== Raid ====<br />
<br />
Grub2 provides convenient handling of raid-volumes. You need to add:<br />
insmod raid<br />
<br />
which allows you to address the volume natively. E.g. {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned raid-volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
You can use UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}} and {{ic|/dev/hd*}} scheming. It has the advantage of detecting partitions by their unique UUIDs, which is needed by some people booting with complicated partition setups.<br />
<br />
UUIDs are used by default in the recent versions of grub2 - there is no downside in it anyway except that you need to re-generate the {{ic|grub.cfg}} file every time you resize or reformat your partitions. Remember this when modifying partitions with Live-CD.<br />
<br />
The recent versions of grub2 use UUIDs by default. You can re-enable the use of UUIDS by simply commenting the UUID line (this is also what it looks like by default):<br />
#GRUB_DISABLE_LINUX_UUID=true<br />
you can also just set the value as {{ic|false}} as shown here:<br />
GRUB_DISABLE_LINUX_UUID=false<br />
<br />
Either way, do not forget to generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --no-floppy --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
Grub2 can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the setting of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that grub will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
Note that manually added menu items, eg Windows in {{ic|/etc/grub.d/40_custom}}, will need {{ic|savedefault}} added. Remember to regenerate your configuration file.<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB2 so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB2's configuration files. To do this, run the command {{ic|grub-mkpasswd_pbkdf2}}. Enter a password and confirm it. The output will look like this:<br />
<br />
{{bc|<nowiki><br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A</nowiki>}}Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{bc|<nowiki>cat << EOF<br />
<br />
set superusers="username"<br />
password_pbkdf2 username <password><br />
<br />
EOF</nowiki>}}<br />
where <password> is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB2 command line and boot parameters are now protected.<br />
<br />
==== Root Encryption ====<br />
<br />
To let GRUB2 automatically add the kernel parameters for root encryption,<br />
add "cryptdevice=/dev/yourdevice:label" to GRUB_CMDLINE_LINUX in /etc/defaults/grub .<br />
<br />
Example with root mapped to /dev/mapper/root :<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
=== Booting an ISO Directly From Grub2 ===<br />
Edit {{ic|/etc/grub.d/40_custom}} to add an entry for the target ISO. When finished, update the grub menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. Also adjust the img_dev line to match this same location.}}<br />
<br />
menuentry "Archlinux-2011.08.19-netinstall-x86_64.iso" {<br />
set isofile="/archives/archlinux-2011.08.19-netinstall-x86_64.iso"<br />
loopback loop (hd0,7)$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201108 img_dev=/dev/sda7 img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. }}<br />
<br />
menuentry "ubuntu-11.04-desktop-amd64.iso" {<br />
set isofile="/path/to/ubuntu-11.04-desktop-amd64.iso"<br />
loopback loop (hdX,Y)$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB2 supports pager for reading commands that provide long output (like the help command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB2 command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed from [[AUR]]<br />
* [https://aur.archlinux.org/packages.php?ID=44020 grub-customizer] (requires gettext gksu gtkmm hicolor-icon-theme openssl)<br />
*:Customize the bootloader (GRUB2 or BURG)<br />
* [http://kde-apps.org/content/show.php?content=139643 grub2-editor] (requires kdelibs)<br />
*:A KDE4 control module for configuring the GRUB2 bootloader<br />
* [http://kde-apps.org/content/show.php?content=137886 kcm-grub2] (requires kdelibs python2-qt kdebindings-python)<br />
*:This Kcm module manages the most common settings of Grub2.<br />
* [http://sourceforge.net/projects/startup-manager/ startupmanager] (requires gnome-python imagemagick yelp python2 xorg-xrandr)<br />
*:GUI app for changing the settings of GRUB, GRUB2, Usplash and Splashy<br />
<br />
== parttool or legacy hide/unhide ==<br />
<br />
If you have a win9x paradigm with hidden C disks GRUB legacy had the hide/unhide feature. In GRUB2 this has been replaced by parttool. For example, to boot the third C disk of three win9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then run:<br />
# grub-install /dev/sda --no-floppy<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUID's and basic scripting ==<br />
<br />
If you like the idea of using UUID's to avoid unreliable BIOS mappings or are struggling with Grub's syntax, here is an example boot menu item that uses UUID's and a small script to direct Grub to the proper disk partitions for your system. All you need to do is replace the UUID's in the sample with the correct UUID's for your system. (The example applies to a system with a boot and root partition. You will obviously need to modify the Grub configuration if you have additional partitions.)<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 <br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables <br />
search --fs-uuid --no-floppy --set=root $the_root_uuid <br />
search --fs-uuid --no-floppy --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== Enable GRUB2 debug messages ===<br />
<br />
Add<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== Correct GRUB2 No Suitable Mode Found Error ===<br />
<br />
If you get this error when booting any menuentry<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize grub2 graphical terminal (gfxterm) with proper video mode (gfxmode) in grub2. This video mode is passed by grub2 to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the grub2 video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in)<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB2_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems. If GRUB2 UEFI was installed with {{ic|1=--boot-directory=/boot/efi/efi}} set, then the directory is {{ic|/boot/efi/efi/grub/}}. <br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB2_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the unifont.pf2 file and then copy it to ${GRUB2_PREFIX_DIR}.<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable grub2 to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang:<br />
<br />
BIOS systems<br />
<br />
insmod vbe<br />
<br />
UEFI systems<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI)<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in ${GRUB2_PREFIX_DIR}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#MBR_aka_msdos_partitioning_specific_instructions]]<br />
<br />
=== UEFI GRUB2 drops to shell ===<br />
<br />
If grub loads but drop you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB2 UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== UEFI GRUB2 not loaded ===<br />
In some cases the EFI may fail to load grub correctly. Provided everything is set up correctly, the output of<br />
efibootmgr -v<br />
might look something like this:<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
If everything works correctly, the EFI would now automatically load grub.<br><br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving grub to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for grub should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
If trying to boot windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move grub's device configuration and let it reconfigure.<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
Grub-mkconfig should now mention all found boot options including windows. If it works, remove /boot/grub/device.map-old.<br />
<br />
== References ==<br />
<br />
# Official GRUB2 Manual - http://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for Grub2 - https://help.ubuntu.com/community/Grub2<br />
# GRUB2 wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]<br />
<br />
== External Links ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_bios.sh A Linux Bash Shell script to compile and install GRUB2 for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_uefi.sh A Linux Bash Shell script to compile and install GRUB2 for UEFI from BZR Source]</div>Martadinatahttps://wiki.archlinux.org/index.php?title=GRUB_(Bahasa_Indonesia)&diff=189333GRUB (Bahasa Indonesia)2012-03-13T10:59:57Z<p>Martadinata: </p>
<hr />
<div>[[Category:Boot loaders (English)]]<br />
{{i18n|GRUB2}}<br />
[[fr:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|GRUB2 adalah generasi terbaru dari grub.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Burg}} - Burg adalah boot loader baru yang berdasar atas GRUB2. Yang menggunakan format object dimana hal ini membuat BURG dapat di gunakan di berbagai Operating System termasuk Linux/Windows/OSX/Solaris/FreeBSD, dll. Juga mempunyai tampilan untuk di konfigurasi yang unik baik melalui text mode atau GUI mode.<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/ GRUB2] generasi berikutnya dari GRUB. GRUB2 adalah derivasi dari [http://www.nongnu.org/pupa/ PUPA] yang merupakan proyek pengembangand dari GRUB. GRUB 2 telah di tulis ulang untuk membersihkan segalanya dan memberikan modularitas dan portabilitas. [http://www.gnu.org/software/grub/grub-faq.en.html#q1].<br />
<br />
Secara singkat, ''bootloader'' adalah program software pertama yang berjalan ketika komputer pertama dinyalakan. ''Bootloader'' bertanggung jawab sebagai pemicu dan pengirim kontrol ke Kernel Linux. Kernel, selanjutnya, menginisialisasi seluruh sistem operasi.<br />
<br />
{{Note|grub2 dari 1.99 dan selanjutnya telah mendukung btrfs sebagai root (tanpa /boot filesistem yang terpisah), tetapi tingkat kompresinya terbatas pada zlib, tidak LZO. Dukungan kompresi LZO hanya terdapat pada repo bzr upstream.}}<br />
<br />
{{Note|Penginstall standar AIF (Arch Installation Framework) berdasar pada [[Archiso]] tidak mendukung penginstallan grub2-bios atau grub2-uefi. Akan tetapi [[Archboot]] iso mendukung penginstallan grub2-bios dan grub2-uefi.}}<br />
<br />
== Prefasi ==<br />
<br />
Walaupun, [[GRUB]] (versi 0.9x) adalah bootloader standar Arch Linux, GRUB dapat diganti menjadi 'grub legacy' by upstream. Dimana telah menjadi GRUB2 dan [[Syslinux]] di beberapa distribusi. Versi lanjutan merekomendasikan GRUB2 >=1.99 di atas versi grub-legacy.<br />
<br />
=== Catatan untuk pengguna GRUB Legacy ===<br />
<br />
* Ada perbedaan perinta dari GRUB dan GRUB2. Perlu di lihat terlebih dahulu [http://www.gnu.org/software/grub/manual/grub.html#Commands GRUB2 commands] sebelum melanjutkan (contoh : "find" telah di ganti dengan "search").<br />
<br />
* GRUB2 sekarang ''modular'' dan tidak lagi memerlukan "stage 1.5". Sebagai hasilnya, bootloader itu sendiri menjadi terbatas -- modul-modul diambil dari hard disk sebagai kebutuhan untuk meluaskan fungsionalitas. (contoh : dukungan untuk [[LVM]] atau RAID).<br />
<br />
* Penamaan perangkat telah berubah antara GRUB dan GRUB2. Partisi diurut dari nomor 1 dari pada 0 ketika disk masih bernomor 0. Sebagai contoh, {{ic|/dev/sda1}} akan menjadi {{ic|(hd0,msdos1)}} (untuk MBR) atau {{ic|(hd0,gpt1)}} (for GPT) ketika GRUB2 dipakai.<br />
<br />
=== Kebutuhan GRUB2 ===<br />
<br />
==== System BIOS ====<br />
<br />
===== Instruksi spesifik untuk [[GPT]] =====<br />
<br />
GRUB2 in BIOS-GPT configuration requires a BIOS Boot Partition to embed its core.img in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB2 only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB2). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case. Syslinux does not require this partition.<br />
<br />
For a BIOS-GPT configuration, create a 2 MiB partition using cgdisk or GNU Parted with no filesystem. The location of the partition in the partition table does not matter but it should be within the first 2 TiB region of the disk. It is advisable to put it somewhere in the beginning of the disk before the /boot partition. Set the partition type to "EF02" in cgdisk or {{ic|set <BOOT_PART_NUM> bios_grub on}} in GNU Parted.<br />
<br />
{{Note|This partition should be created before grub_bios-install or grub-setup is run or before the '''Install Bootloader''' step of the Archlinux installer (if GRUB2 BIOS is selected as bootloader).}}<br />
<br />
===== [[MBR]] aka msdos partitioning specific instructions =====<br />
<br />
Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 32 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding grub2's core.img ( https://bugs.archlinux.org/task/24103 ). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of core.img).<br />
<br />
If you do not dual-boot with MS Windows (any version) in BIOS systems, it is advisable to switch to GPT partitioning - [[GUID_Partition_Table#Convert_from_MBR_to_GPT_without_data_loss]]<br />
<br />
{{Note|Create the 2MiB partition mentioned above BEFORE you convert to GPT. If you do not, gparted will not resize your boot partition to allow its creation, and when you reboot grub2 will not know where to look.}}<br />
<br />
==== UEFI systems ====<br />
<br />
===== Create and Mount the UEFI SYSTEM PARTITION =====<br />
<br />
Follow [[Unified_Extensible_Firmware_Interface#Create_an_UEFI_SYSTEM_PARTITION_in_Linux]] for instructions on creating a UEFI SYSTEM PARTITION. Then mount the UEFI SYSTEM PARTITION at {{ic|/boot/efi}}. It should be FAT32 formatted and should be >=200 MiB in size. If you have mounted the UEFISYS partition in some other mountpoint, replace {{ic|/boot/efi}} in the below instructions with that mountpoint:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFISYS_PART_DEVICE> /boot/efi<br />
<br />
Create a <UEFI_SYSTEM_PARTITION>/efi directory if it does not exist:<br />
<br />
# mkdir -p /boot/efi/efi<br />
<br />
== Installation ==<br />
<br />
=== During Arch Linux installation ===<br />
<br />
* Skip the '''Install Bootloader''' step and exit the installer.<br />
* Configure the network:<br />
# aif -p partial-configure-network<br />
This will bring up a prompt; put in the network interface to use, (e.g., eth0) and use DHCP for easy configuration.<br />
* If you did not configure the installed system's {{ic|/etc/resolv.conf}} file during installation (for instance, if you plan to let DHCP generate it later), you will need to copy the one generated by AIF when it configured the network:<br />
# cp /etc/resolv.conf /mnt/etc/resolv.conf<br />
* If you run into network issues in the pacman update step below, you may have needed to install the net-tools package.<br />
* Check and see if the dm_mod module is loaded. If it is not, load it manually. (you might need grub2-bios; install the package if needed):<br />
# lsmod | grep dm_mod<br />
# modprobe dm-mod<br />
{{Note|This is necessary at this point, and cannot be postponed after the chroot. If you try to use modprobe in a chroot environment that has a later kernel version from that of the installing device (at the time of writing, 2.6.33), modprobe will fail. This happens routinely using the Arch "net" installations.}}<br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# mount -t proc /proc /mnt/proc/<br />
# mount -t sysfs /sys /mnt/sys/<br />
# chroot /mnt bash<br />
* Update pacman's database:<br />
# pacman-db-upgrade<br />
* Refresh the package list (with an extra -y flag to force a refresh of all package lists even if they appear to be up to date):<br />
# pacman -Syy<br />
* Install the GRUB2 package as mentioned in the section [[#From a running Arch Linux]]. Note that the dm-mod module has already been loaded, no need to do that again.<br />
<br />
=== From a running Arch Linux ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== Backup Important Data =====<br />
<br />
In general, a grub installation should run smoothly. Sometimes it could mess up your system. You're strongly advised to make a backup before installing grub2-bios.<br />
<br />
* copy grub modules and configuration<br />
<br />
# cp -a /boot/grub /path/to/backup/<br />
<br />
* backup the MBR and GRUB-Legacy stage 1.5<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/first-sectors bs=512 count=63<br />
<br />
Replace /dev/sdaX with you disk path (mostly /dev/sda).<br />
<br />
{{Note|This command backs up the partition table too. Be careful while restoring if you've changed your partition setup in the meantime}}<br />
<br />
To backup only the MBR boot code use:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1<br />
<br />
You could now lightly remove {{ic|/boot/grub}} with:<br />
<br />
# rm -rf /boot/grub<br />
<br />
and follow the instructions below. You know that if things get nasty, you could reboot your system thanks to an installation media and:<br />
<br />
* move old grub-legacy or grub2 files out of the way<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* copy grub back to /boot<br />
<br />
# cp -a /path/to/backup/grub /boot/<br />
<br />
* replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=63<br />
<br />
{{Note|This command also restores the partition table. Be careful.}}<br />
<br />
To restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1<br />
<br />
===== Install grub2-bios package =====<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Pkg|grub}}, if it is installed). Simply installing the package won't update the {{ic|/boot/grub/core.img}} file and the grub2 modules in {{ic|/boot/grub}}. You need to update them manually using grub_bios-install as explained below.<br />
<br />
# pacman -S grub2-bios<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions:<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-bios boot files =====<br />
<br />
There are 3 ways to install grub2 boot files in BIOS booting:<br />
*[[#Install_to_440-byte_MBR_boot_code_region]] (recommended) , <br />
*[[#Install_to_Partition_or_Partitionless_Disk]] (not recommended),<br />
*[[#Generate_core.img_alone]] (safest method, but requires another BIOS bootloader like [[grub-legacy]] or [[syslinux]] to be installed to chainload {{ic|/boot/grub/core.img}} ). <br />
<br />
====== Install to 440-byte MBR boot code region ======<br />
<br />
To setup grub2-bios in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/core.img}} file, and embed it in the 32 KiB (minimum size - varies depending on partition alignment) post-MBR gap (MBR disks) or in BIOS Boot Partition (GPT disks), run:<br />
<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB2 on multiple physical disks. <br />
<br />
The {{ic|--no-floppy}} tells grub2-bios utilities not to search for any floppy devices which reduces the overall execution time of grub_bios-install on many systems (it will also prevent the issue below from occurring). Otherwise you get an error that looks like this:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
{{Warning|Make sure that you check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic| boot-directory}} parameter creates another {{ic|/boot}} folder inside of boot. A wrong install would look like this {{ic|/boot/boot/grub}} !}}.<br />
<br />
====== Install to Partition or Partitionless Disk ======<br />
<br />
{{Note|grub2-bios (any version - including upstream bzr repo) does not encourage installation to a partition boot sector or a partitionless disk like grub-legacy or syslinux does. Neither do the Arch devs.}}<br />
<br />
To setup grub2-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example /dev/sda1 as the /boot partition)<br />
<br />
# chattr -i /boot/grub/core.img<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --force --debug /dev/sda1<br />
# chattr +i /boot/grub/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating core.img).<br />
<br />
grub_bios-install will give out warnings like which should give you the idea of what might go wrong with this approach.<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and grub-setup will not setup its boot code in the partition boot sector.<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why grub-setup does not by default allow this is because in case of partition or a partitionless disk is that grub2-bios relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/core.img}} needs to be set only if grub2-bios is installed to a partition boot sector or a partitionless disk, not in case of installtion to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
====== Generate core.img alone ======<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/core.img}} file WITHOUT embedding any grub2-bios bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to grub_bios-install:<br />
<br />
# grub_bios-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
You can then chainload grub2's core.img from grub-legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
===== Generate GRUB2 BIOS Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2 complains about "no suitable mode found" while booting, go to [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB2 {{ic|/boot/grub/grub.cfg}} configfile and simply rebooted into GRUB2 Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB2 {{ic|/boot/grub/grub.cfg}} configfile.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
===== Multiboot in BIOS =====<br />
<br />
====== Boot Microsoft Windows installed in BIOS-MBR mode ======<br />
<br />
{{Note|GRUB2 supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
Find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the bootmgr and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/Windows/bootmgr}}:<br />
<br />
# grub-probe --target=fs_uuid /media/Windows/bootmgr<br />
69B235F6749E84CE<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} and regenerate grub.cfg with grub-mkconfig as explained above to chainload Windows (Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
menuentry "Microsoft Windows 7 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/bootmgr<br />
}<br />
<br />
For Windows XP<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/ntldr<br />
}<br />
<br />
==== [[UEFI]] systems ====<br />
<br />
===== Install grub2-uefi package =====<br />
<br />
{{Note|Unless specified as EFI 1.x , EFI and UEFI terms are used interchangeably to denote UEFI 2.x firmware. Also unless stated explicitely, the instructions are general and not Mac specific. Some of them may not work or may be different in Macs. Apple's EFI implementation is neither a EFI 1.x version nor UEFI 2.x version but mixes up both. This kind of firmware does not fall under any one UEFI Specification version and is therefore not a standard UEFI firmware.}}<br />
<br />
GRUB2 UEFI bootloader is available in Arch Linux only from version 1.99~rc1. To install, first [https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Detecting_UEFI_Firmware_Arch Detect which UEFI firmware arch] you have (either x86_64 or i386).<br />
<br />
Depending on that, install the appropriate package<br />
<br />
For 64-bit aka x86_64 UEFI firmware:<br />
# pacman -S grub2-efi-x86_64<br />
<br />
For 32-bit aka i386 UEFI firmware:<br />
# pacman -S grub2-efi-i386<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
{{Note|Simply installing the package won't update the grub.efi file and the grub2 modules in the UEFI System Partition. You need to update the grub.efi file and the grub2 modules in the UEFI System Partition manually using grub_efi_${UEFI_ARCH}-install as explained below.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-uefi boot files =====<br />
<br />
====== Install to UEFI SYSTEM PARTITION ======<br />
<br />
{{Note|The below commands assume you are using {{ic|grub2-efi-x86_64}} (for {{ic|grub2-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands).}}<br />
<br />
The UEFI system partition will need to be mounted at /boot/efi for the GRUB2 install script to detect it.<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application and its modules to {{ic|/boot/efi/efi/arch_grub}} using <br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
If you want to install grub2 modules and grub.cfg at the directory {{ic|/boot/grub}} and only the grubx64.efi application at {{ic|/boot/efi/efi/arch_grub}} use<br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
In this case grub2-efi-x86_64 will be installed into /boot/grub, making the behavior consistent with the BIOS verion of GRUB2, but this is not recommended if you use both grub2-bios and grub2-efi-x86_64 in your system, as this will overwrite grub2-bios modules in /boot/grub .<br />
<br />
The {{ic|--root-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the grubx64.efi file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which grub.cfg should be created).<br />
<br />
The actual paths are<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
Note the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to <boot-directory>/grub .<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == <boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/core.efi</nowiki>}} .<br />
<br />
{{Note| This behavior of --root-directory , --boot-directory , and --bootloader-id options are specific to UEFI systems and does not occur is BIOS mode. In grub_bios-install, --root-directory is deprecated and --bootloader-id option does not exist.}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for grub_efi_x86_64-install to install grubx64.efi in it, which will be launched by the firmware (using th efibootmgr created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub_efi_x86_64-install}} command unlike the case of setting up grub2 for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a grub.cfg file by following [[#Generate_GRUB2_UEFI_Config_file]] and [[#Create_GRUB2_entry_in_the_Firmware_Boot_Manager]].<br />
<br />
===== Create GRUB2 entry in the Firmware Boot Manager =====<br />
<br />
====== Non-Mac UEFI systems ======<br />
<br />
grub_efi_${UEFI_ARCH}-install will ensure that {{ic|/boot/efi/efi/arch_grub/grubx64.efi}} is launched by default if it detects {{ic|efibootmgr}} and if it is able to access UEFI Runtime Services. Follow [[Unified_Extensible_Firmware_Interface#efibootmgr]] for more info.<br />
<br />
If you have problems running GRUB2 in UEFI mode you can try the following (worked on an ASUS Z68 mainboard):<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shell/shellx64.efi<br />
<br />
After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The grub2 menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry (see above).<br />
<br />
====== Apple Mac EFI systems ======<br />
<br />
{{Note| TODO: Grub upstream bzr mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes}}<br />
{{Note| TODO: Fedora's mactel-boot ( https://bugzilla.redhat.com/show_bug.cgi?id&#61;755093 )}}<br />
<br />
Use bless command from within Mac OS X to set {{ic|grubx64.efi}} as the default boot option. You can also boot from the Mac OS X install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI System Partition:<br />
<br />
# cd /Volumes<br />
# mkdir efi<br />
# mount -t msdos /dev/disk0s1 /Volumes/efi<br />
<br />
Then run bless on {{ic|grub.efi}} and on the EFI partition to set them as the default boot options.<br />
<br />
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
<br />
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.<br />
<br />
===== Generate GRUB2 UEFI Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="<boot-directory>/grub" grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/efi</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/efi/efi/grub" grub-mkconfig -o /boot/efi/efi/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
This is independent of the value of --bootloader-id option. The {{ic|GRUB_PREFIX}} env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2-uefi complains about "no suitable mode found" while booting, try [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
===== Create GRUB2 Standalone UEFI Application =====<br />
<br />
It is possible to create a grubx64_standalone.efi application which has all the modules embeddded in a memdisk within the uefi application, thus removing the need for having a separate directory populated with all the grub2 uefi modules and other related files. This is done using the grub-mkstandalone command which is included in extra/grub2-common >= 1:1.99-6 package.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The grubx64_standalone.efi file expects grub.cfg to be within its $prefix which is (memdisk)/boot/grub. The memdisk is embedded within the efi app. The grub-mkstandlone script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the grub.cfg at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the grub-mkstandalone script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}} . That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to includ the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what grub.efi expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/efi/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB2 entry in the Firmware Boot Manager]].<br />
<br />
===== Multiboot in UEFI =====<br />
<br />
====== Chainload Microsoft Windows x86_64 UEFI-GPT ======<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/efi/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/boot/grub/grub.cfg}} OR {{ic|/boot/efi/efi/grub/grub.cfg}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|If GRUB2 was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in the BIOS version of GRUB2.}}<br />
<br />
=== Automatically generating using grub-mkconfig (Recommended) ===<br />
<br />
The GRUB2 {{ic|menu.1st}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. grub-mkconfig uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually by editing {{ic|/etc/grub.d/40_custom}}<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc<br />
|/boot/grub/grub.cfg<br />
|<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
''NOTE: If you want GRUB2 to automatically search for other systems, for example as in Ubuntu. Then you may need to install {{Pkg|os-prober}}.''<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}}. The entries in this file will be automatically added when running '''grub-mkconfig'''.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader (hd0,3)+1<br />
}<br />
<br />
If the windows bootloader is on an entirely different harddrive than grub, it may be necessary to trick Windows into believing that it is in fact the first harddrive. This was possible in the old grub with {{ic|map}} and is now done with {{ic|drivemap}}. Assume grub is on {{ic|hd0}} and windows on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, grub2 graphical terminal, gfxterm, with proper video mode, gfxmode, in grub2. This can be seen in the section [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]]. This video mode is passed by grub2 to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
====Setting the framebuffer resolution ====<br />
<br />
Grub2 can set the framebuffer for both grub2 itself and the kernel. The old ''vga='' way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen.}}<br />
{{Note|To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at grub2 prompt you can use the {{ic|1=vbeinfo}} command.}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}<br />
<br />
====915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
In the following I will proceed with the example for my system. Please adjust the recipe for your needs. First you need to find a video mode which will be modified later. For that, run {{ic|915resolution}} in GRUB2 command shell.<br />
915resolution -l<br />
The output will be something like:<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
...<br />
Mode 30 : 640x480, 8 bits/pixel<br />
...<br />
Next, our purpose is to overwrite mode 30. (You can choose what ever mode you want.) In the file {{ic|/etc/grub.d/00_header}} just before the {{ic|set gfxmode&#61;${GRUB_GFXMODE} }} line insert<br />
915resolution 30 1440 900<br />
Here we are overwriting the mode {{ic| 30}} with {{ic|1440x900}} resolution. Lastly we need to set {{ic | GRUB_GFXMODE}} as described earlier, regenerate grub configuration file and reboot to test changes.<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
sudo reboot<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{ic|unicode.pf2}}, or, as only ascii characters under the name {{ic|ascii.pf2}}. <br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [https://wiki.archlinux.org/index.php/GRUB2#Setting_the_framebuffer_resolution framebuffer resolution].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/archlinux.tga"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
<br />
(archlinux.tga is a placeholder; put your file name there)<br />
<br />
{{Note|If you have installed Grub on a separate partition, {{ic|/boot/grub/archlinux.tga}} becomes {{ic|/grub/archlinux.tga}}.}}<br />
<br />
To generate the changes and add the information into grub.cfg, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see "Found background image..." in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the grub.cfg file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in /etc/default/grub are correct.<br />
* The image is of the proper size and format (tga, png, 8-bit jpg).<br />
* The image was saved in the RGB mode, and is not indexed.<br />
* The console mode is not enabled in /etc/default/grub.<br />
* The command grub-mkconfig must be executed to place the background image information into the /boot/grub/grub.cfg file.<br />
<br />
====Menu colors====<br />
<br />
As in Grub (0.9x), you can change the menu colors in Grub2. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html#Theme-file-format.<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
====Hidden menu====<br />
<br />
One of the unique features of Grub2 is hiding/skipping the menu and showing it by holding "Shift" when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== Raid ====<br />
<br />
Grub2 provides convenient handling of raid-volumes. You need to add:<br />
insmod raid<br />
<br />
which allows you to address the volume natively. E.g. {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned raid-volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
You can use UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}} and {{ic|/dev/hd*}} scheming. It has the advantage of detecting partitions by their unique UUIDs, which is needed by some people booting with complicated partition setups.<br />
<br />
UUIDs are used by default in the recent versions of grub2 - there is no downside in it anyway except that you need to re-generate the {{ic|grub.cfg}} file every time you resize or reformat your partitions. Remember this when modifying partitions with Live-CD.<br />
<br />
The recent versions of grub2 use UUIDs by default. You can re-enable the use of UUIDS by simply commenting the UUID line (this is also what it looks like by default):<br />
#GRUB_DISABLE_LINUX_UUID=true<br />
you can also just set the value as {{ic|false}} as shown here:<br />
GRUB_DISABLE_LINUX_UUID=false<br />
<br />
Either way, do not forget to generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --no-floppy --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
Grub2 can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the setting of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that grub will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
Note that manually added menu items, eg Windows in {{ic|/etc/grub.d/40_custom}}, will need {{ic|savedefault}} added. Remember to regenerate your configuration file.<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB2 so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB2's configuration files. To do this, run the command {{ic|grub-mkpasswd_pbkdf2}}. Enter a password and confirm it. The output will look like this:<br />
<br />
{{bc|<nowiki><br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A</nowiki>}}Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{bc|<nowiki>cat << EOF<br />
<br />
set superusers="username"<br />
password_pbkdf2 username <password><br />
<br />
EOF</nowiki>}}<br />
where <password> is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB2 command line and boot parameters are now protected.<br />
<br />
==== Root Encryption ====<br />
<br />
To let GRUB2 automatically add the kernel parameters for root encryption,<br />
add "cryptdevice=/dev/yourdevice:label" to GRUB_CMDLINE_LINUX in /etc/defaults/grub .<br />
<br />
Example with root mapped to /dev/mapper/root :<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
=== Booting an ISO Directly From Grub2 ===<br />
Edit {{ic|/etc/grub.d/40_custom}} to add an entry for the target ISO. When finished, update the grub menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. Also adjust the img_dev line to match this same location.}}<br />
<br />
menuentry "Archlinux-2011.08.19-netinstall-x86_64.iso" {<br />
set isofile="/archives/archlinux-2011.08.19-netinstall-x86_64.iso"<br />
loopback loop (hd0,7)$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201108 img_dev=/dev/sda7 img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. }}<br />
<br />
menuentry "ubuntu-11.04-desktop-amd64.iso" {<br />
set isofile="/path/to/ubuntu-11.04-desktop-amd64.iso"<br />
loopback loop (hdX,Y)$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB2 supports pager for reading commands that provide long output (like the help command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB2 command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed from [[AUR]]<br />
* [https://aur.archlinux.org/packages.php?ID=44020 grub-customizer] (requires gettext gksu gtkmm hicolor-icon-theme openssl)<br />
*:Customize the bootloader (GRUB2 or BURG)<br />
* [http://kde-apps.org/content/show.php?content=139643 grub2-editor] (requires kdelibs)<br />
*:A KDE4 control module for configuring the GRUB2 bootloader<br />
* [http://kde-apps.org/content/show.php?content=137886 kcm-grub2] (requires kdelibs python2-qt kdebindings-python)<br />
*:This Kcm module manages the most common settings of Grub2.<br />
* [http://sourceforge.net/projects/startup-manager/ startupmanager] (requires gnome-python imagemagick yelp python2 xorg-xrandr)<br />
*:GUI app for changing the settings of GRUB, GRUB2, Usplash and Splashy<br />
<br />
== parttool or legacy hide/unhide ==<br />
<br />
If you have a win9x paradigm with hidden C disks GRUB legacy had the hide/unhide feature. In GRUB2 this has been replaced by parttool. For example, to boot the third C disk of three win9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then run:<br />
# grub-install /dev/sda --no-floppy<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUID's and basic scripting ==<br />
<br />
If you like the idea of using UUID's to avoid unreliable BIOS mappings or are struggling with Grub's syntax, here is an example boot menu item that uses UUID's and a small script to direct Grub to the proper disk partitions for your system. All you need to do is replace the UUID's in the sample with the correct UUID's for your system. (The example applies to a system with a boot and root partition. You will obviously need to modify the Grub configuration if you have additional partitions.)<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 <br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables <br />
search --fs-uuid --no-floppy --set=root $the_root_uuid <br />
search --fs-uuid --no-floppy --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== Enable GRUB2 debug messages ===<br />
<br />
Add<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== Correct GRUB2 No Suitable Mode Found Error ===<br />
<br />
If you get this error when booting any menuentry<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize grub2 graphical terminal (gfxterm) with proper video mode (gfxmode) in grub2. This video mode is passed by grub2 to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the grub2 video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in)<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB2_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems. If GRUB2 UEFI was installed with {{ic|1=--boot-directory=/boot/efi/efi}} set, then the directory is {{ic|/boot/efi/efi/grub/}}. <br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB2_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the unifont.pf2 file and then copy it to ${GRUB2_PREFIX_DIR}.<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable grub2 to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang:<br />
<br />
BIOS systems<br />
<br />
insmod vbe<br />
<br />
UEFI systems<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI)<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in ${GRUB2_PREFIX_DIR}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#MBR_aka_msdos_partitioning_specific_instructions]]<br />
<br />
=== UEFI GRUB2 drops to shell ===<br />
<br />
If grub loads but drop you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB2 UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== UEFI GRUB2 not loaded ===<br />
In some cases the EFI may fail to load grub correctly. Provided everything is set up correctly, the output of<br />
efibootmgr -v<br />
might look something like this:<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
If everything works correctly, the EFI would now automatically load grub.<br><br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving grub to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for grub should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
If trying to boot windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move grub's device configuration and let it reconfigure.<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
Grub-mkconfig should now mention all found boot options including windows. If it works, remove /boot/grub/device.map-old.<br />
<br />
== References ==<br />
<br />
# Official GRUB2 Manual - http://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for Grub2 - https://help.ubuntu.com/community/Grub2<br />
# GRUB2 wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]<br />
<br />
== External Links ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_bios.sh A Linux Bash Shell script to compile and install GRUB2 for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_uefi.sh A Linux Bash Shell script to compile and install GRUB2 for UEFI from BZR Source]</div>Martadinatahttps://wiki.archlinux.org/index.php?title=GRUB_(Bahasa_Indonesia)&diff=189329GRUB (Bahasa Indonesia)2012-03-13T10:49:05Z<p>Martadinata: </p>
<hr />
<div>[[Category:Boot loaders (English)]]<br />
{{i18n|GRUB2}}<br />
[[fr:GRUB2]]<br />
{{Article summary start}}<br />
{{Article summary text|GRUB2 adalah generasi terbaru dari grub.}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Boot process overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Burg}} - Burg adalah boot loader baru yang berdasar atas GRUB2. Yang menggunakan format object dimana hal ini membuat BURG dapat di gunakan di berbagai Operating System termasuk Linux/Windows/OSX/Solaris/FreeBSD, dll. Juga mempunyai tampilan untuk di konfigurasi yang unik baik melalui text mode atau GUI mode.<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|GNU GRUB -- GNU Project|http://www.gnu.org/software/grub/}}<br />
{{Article summary end}}<br />
<br />
[http://www.gnu.org/software/grub/ GRUB2] generasi berikutnya dari GRUB. GRUB2 adalah derivasi dari [http://www.nongnu.org/pupa/ PUPA] yang merupakan proyek pengembangand dari GRUB. GRUB 2 telah di tulis ulang untuk membersihkan segalanya dan memberikan modularitas dan portabilitas. [http://www.gnu.org/software/grub/grub-faq.en.html#q1].<br />
<br />
Secara singkat, ''bootloader'' adalah program software pertama yang berjalan ketika komputer pertama dinyalakan. ''Bootloader'' bertanggung jawab sebagai pemicu dan pengirim kontrol ke Kernel Linux. Kernel, selanjutnya, menginisialisasi seluruh sistem operasi.<br />
<br />
{{Note|grub2 dari 1.99 dan selanjutnya telah mendukung btrfs sebagai root (tanpa /boot filesistem yang terpisah), tetapi tingkat kompresinya terbatas pada zlib, tidak LZO. Dukungan kompresi LZO hanya terdapat pada repo bzr upstream.}}<br />
<br />
{{Note|Penginstall standar AIF (Arch Installation Framework) berdasar pada [[Archiso]] tidak mendukung penginstallan grub2-bios atau grub2-uefi. Akan tetapi [[Archboot]] iso mendukung penginstallan grub2-bios dan grub2-uefi.}}<br />
<br />
== Preface ==<br />
<br />
Although, [[GRUB]] (i.e. version 0.9x) is the standard bootloader of Arch Linux, it is considered 'legacy' by upstream. It is being replaced by GRUB2 and [[Syslinux]] in many distributions. Upstream recommends GRUB2 >=1.99 over grub-legacy, even for current grub-legacy users.<br />
<br />
=== Notes for current GRUB Legacy users ===<br />
<br />
* There are differences in the commands of GRUB and GRUB2. Familiarize yourself with [http://www.gnu.org/software/grub/manual/grub.html#Commands GRUB2 commands] before proceeding (e.g. "find" has been replaced with "search").<br />
<br />
* GRUB2 is now ''modular'' and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for [[LVM]] or RAID support).<br />
<br />
* Device naming has changed between GRUB and GRUB2. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0, and prefixed with partition-table type. For example, {{ic|/dev/sda1}} would be referred to as {{ic|(hd0,msdos1)}} (for MBR) or {{ic|(hd0,gpt1)}} (for GPT) using GRUB2.<br />
<br />
=== Preliminary Requirements for GRUB2 ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== [[GPT]] specific instructions =====<br />
<br />
GRUB2 in BIOS-GPT configuration requires a BIOS Boot Partition to embed its core.img in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB2 only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB2). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case. Syslinux does not require this partition.<br />
<br />
For a BIOS-GPT configuration, create a 2 MiB partition using cgdisk or GNU Parted with no filesystem. The location of the partition in the partition table does not matter but it should be within the first 2 TiB region of the disk. It is advisable to put it somewhere in the beginning of the disk before the /boot partition. Set the partition type to "EF02" in cgdisk or {{ic|set <BOOT_PART_NUM> bios_grub on}} in GNU Parted.<br />
<br />
{{Note|This partition should be created before grub_bios-install or grub-setup is run or before the '''Install Bootloader''' step of the Archlinux installer (if GRUB2 BIOS is selected as bootloader).}}<br />
<br />
===== [[MBR]] aka msdos partitioning specific instructions =====<br />
<br />
Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 32 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding grub2's core.img ( https://bugs.archlinux.org/task/24103 ). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of core.img).<br />
<br />
If you do not dual-boot with MS Windows (any version) in BIOS systems, it is advisable to switch to GPT partitioning - [[GUID_Partition_Table#Convert_from_MBR_to_GPT_without_data_loss]]<br />
<br />
{{Note|Create the 2MiB partition mentioned above BEFORE you convert to GPT. If you do not, gparted will not resize your boot partition to allow its creation, and when you reboot grub2 will not know where to look.}}<br />
<br />
==== UEFI systems ====<br />
<br />
===== Create and Mount the UEFI SYSTEM PARTITION =====<br />
<br />
Follow [[Unified_Extensible_Firmware_Interface#Create_an_UEFI_SYSTEM_PARTITION_in_Linux]] for instructions on creating a UEFI SYSTEM PARTITION. Then mount the UEFI SYSTEM PARTITION at {{ic|/boot/efi}}. It should be FAT32 formatted and should be >=200 MiB in size. If you have mounted the UEFISYS partition in some other mountpoint, replace {{ic|/boot/efi}} in the below instructions with that mountpoint:<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFISYS_PART_DEVICE> /boot/efi<br />
<br />
Create a <UEFI_SYSTEM_PARTITION>/efi directory if it does not exist:<br />
<br />
# mkdir -p /boot/efi/efi<br />
<br />
== Installation ==<br />
<br />
=== During Arch Linux installation ===<br />
<br />
* Skip the '''Install Bootloader''' step and exit the installer.<br />
* Configure the network:<br />
# aif -p partial-configure-network<br />
This will bring up a prompt; put in the network interface to use, (e.g., eth0) and use DHCP for easy configuration.<br />
* If you did not configure the installed system's {{ic|/etc/resolv.conf}} file during installation (for instance, if you plan to let DHCP generate it later), you will need to copy the one generated by AIF when it configured the network:<br />
# cp /etc/resolv.conf /mnt/etc/resolv.conf<br />
* If you run into network issues in the pacman update step below, you may have needed to install the net-tools package.<br />
* Check and see if the dm_mod module is loaded. If it is not, load it manually. (you might need grub2-bios; install the package if needed):<br />
# lsmod | grep dm_mod<br />
# modprobe dm-mod<br />
{{Note|This is necessary at this point, and cannot be postponed after the chroot. If you try to use modprobe in a chroot environment that has a later kernel version from that of the installing device (at the time of writing, 2.6.33), modprobe will fail. This happens routinely using the Arch "net" installations.}}<br />
* From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# mount -t proc /proc /mnt/proc/<br />
# mount -t sysfs /sys /mnt/sys/<br />
# chroot /mnt bash<br />
* Update pacman's database:<br />
# pacman-db-upgrade<br />
* Refresh the package list (with an extra -y flag to force a refresh of all package lists even if they appear to be up to date):<br />
# pacman -Syy<br />
* Install the GRUB2 package as mentioned in the section [[#From a running Arch Linux]]. Note that the dm-mod module has already been loaded, no need to do that again.<br />
<br />
=== From a running Arch Linux ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== Backup Important Data =====<br />
<br />
In general, a grub installation should run smoothly. Sometimes it could mess up your system. You're strongly advised to make a backup before installing grub2-bios.<br />
<br />
* copy grub modules and configuration<br />
<br />
# cp -a /boot/grub /path/to/backup/<br />
<br />
* backup the MBR and GRUB-Legacy stage 1.5<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/first-sectors bs=512 count=63<br />
<br />
Replace /dev/sdaX with you disk path (mostly /dev/sda).<br />
<br />
{{Note|This command backs up the partition table too. Be careful while restoring if you've changed your partition setup in the meantime}}<br />
<br />
To backup only the MBR boot code use:<br />
<br />
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1<br />
<br />
You could now lightly remove {{ic|/boot/grub}} with:<br />
<br />
# rm -rf /boot/grub<br />
<br />
and follow the instructions below. You know that if things get nasty, you could reboot your system thanks to an installation media and:<br />
<br />
* move old grub-legacy or grub2 files out of the way<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* copy grub back to /boot<br />
<br />
# cp -a /path/to/backup/grub /boot/<br />
<br />
* replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=63<br />
<br />
{{Note|This command also restores the partition table. Be careful.}}<br />
<br />
To restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1<br />
<br />
===== Install grub2-bios package =====<br />
<br />
The GRUB2 package can be installed with pacman (and will replace {{Pkg|grub}}, if it is installed). Simply installing the package won't update the {{ic|/boot/grub/core.img}} file and the grub2 modules in {{ic|/boot/grub}}. You need to update them manually using grub_bios-install as explained below.<br />
<br />
# pacman -S grub2-bios<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions:<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-bios boot files =====<br />
<br />
There are 3 ways to install grub2 boot files in BIOS booting:<br />
*[[#Install_to_440-byte_MBR_boot_code_region]] (recommended) , <br />
*[[#Install_to_Partition_or_Partitionless_Disk]] (not recommended),<br />
*[[#Generate_core.img_alone]] (safest method, but requires another BIOS bootloader like [[grub-legacy]] or [[syslinux]] to be installed to chainload {{ic|/boot/grub/core.img}} ). <br />
<br />
====== Install to 440-byte MBR boot code region ======<br />
<br />
To setup grub2-bios in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/core.img}} file, and embed it in the 32 KiB (minimum size - varies depending on partition alignment) post-MBR gap (MBR disks) or in BIOS Boot Partition (GPT disks), run:<br />
<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
where {{ic|/dev/sda}} is the destination of the installation (in this case the MBR of the first SATA disk). If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB2 on multiple physical disks. <br />
<br />
The {{ic|--no-floppy}} tells grub2-bios utilities not to search for any floppy devices which reduces the overall execution time of grub_bios-install on many systems (it will also prevent the issue below from occurring). Otherwise you get an error that looks like this:<br />
<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
<br />
{{Warning|Make sure that you check the {{ic|/boot}} directory if you use the latter. Sometimes the {{ic| boot-directory}} parameter creates another {{ic|/boot}} folder inside of boot. A wrong install would look like this {{ic|/boot/boot/grub}} !}}.<br />
<br />
====== Install to Partition or Partitionless Disk ======<br />
<br />
{{Note|grub2-bios (any version - including upstream bzr repo) does not encourage installation to a partition boot sector or a partitionless disk like grub-legacy or syslinux does. Neither do the Arch devs.}}<br />
<br />
To setup grub2-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example /dev/sda1 as the /boot partition)<br />
<br />
# chattr -i /boot/grub/core.img<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --force --debug /dev/sda1<br />
# chattr +i /boot/grub/core.img<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating core.img).<br />
<br />
grub_bios-install will give out warnings like which should give you the idea of what might go wrong with this approach.<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and grub-setup will not setup its boot code in the partition boot sector.<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why grub-setup does not by default allow this is because in case of partition or a partitionless disk is that grub2-bios relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/core.img}} needs to be set only if grub2-bios is installed to a partition boot sector or a partitionless disk, not in case of installtion to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
====== Generate core.img alone ======<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/core.img}} file WITHOUT embedding any grub2-bios bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to grub_bios-install:<br />
<br />
# grub_bios-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
<br />
You can then chainload grub2's core.img from grub-legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
<br />
===== Generate GRUB2 BIOS Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2 complains about "no suitable mode found" while booting, go to [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB2 {{ic|/boot/grub/grub.cfg}} configfile and simply rebooted into GRUB2 Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB2 {{ic|/boot/grub/grub.cfg}} configfile.<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
===== Multiboot in BIOS =====<br />
<br />
====== Boot Microsoft Windows installed in BIOS-MBR mode ======<br />
<br />
{{Note|GRUB2 supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
Find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the bootmgr and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/Windows/bootmgr}}:<br />
<br />
# grub-probe --target=fs_uuid /media/Windows/bootmgr<br />
69B235F6749E84CE<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} and regenerate grub.cfg with grub-mkconfig as explained above to chainload Windows (Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
menuentry "Microsoft Windows 7 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/bootmgr<br />
}<br />
<br />
For Windows XP<br />
<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/ntldr<br />
}<br />
<br />
==== [[UEFI]] systems ====<br />
<br />
===== Install grub2-uefi package =====<br />
<br />
{{Note|Unless specified as EFI 1.x , EFI and UEFI terms are used interchangeably to denote UEFI 2.x firmware. Also unless stated explicitely, the instructions are general and not Mac specific. Some of them may not work or may be different in Macs. Apple's EFI implementation is neither a EFI 1.x version nor UEFI 2.x version but mixes up both. This kind of firmware does not fall under any one UEFI Specification version and is therefore not a standard UEFI firmware.}}<br />
<br />
GRUB2 UEFI bootloader is available in Arch Linux only from version 1.99~rc1. To install, first [https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#Detecting_UEFI_Firmware_Arch Detect which UEFI firmware arch] you have (either x86_64 or i386).<br />
<br />
Depending on that, install the appropriate package<br />
<br />
For 64-bit aka x86_64 UEFI firmware:<br />
# pacman -S grub2-efi-x86_64<br />
<br />
For 32-bit aka i386 UEFI firmware:<br />
# pacman -S grub2-efi-i386<br />
<br />
{{Note|Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option {{ic|--no-floppy}}. For more details search this option in the article.}}<br />
<br />
{{Note|Simply installing the package won't update the grub.efi file and the grub2 modules in the UEFI System Partition. You need to update the grub.efi file and the grub2 modules in the UEFI System Partition manually using grub_efi_${UEFI_ARCH}-install as explained below.}}<br />
<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions<br />
<br />
# modprobe dm-mod<br />
<br />
===== Install grub2-uefi boot files =====<br />
<br />
====== Install to UEFI SYSTEM PARTITION ======<br />
<br />
{{Note|The below commands assume you are using {{ic|grub2-efi-x86_64}} (for {{ic|grub2-efi-i386}} replace {{ic|x86_64}} with {{ic|i386}} in the below commands).}}<br />
<br />
The UEFI system partition will need to be mounted at /boot/efi for the GRUB2 install script to detect it.<br />
<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
<br />
Install GRUB UEFI application and its modules to {{ic|/boot/efi/efi/arch_grub}} using <br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
If you want to install grub2 modules and grub.cfg at the directory {{ic|/boot/grub}} and only the grubx64.efi application at {{ic|/boot/efi/efi/arch_grub}} use<br />
<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
<br />
In this case grub2-efi-x86_64 will be installed into /boot/grub, making the behavior consistent with the BIOS verion of GRUB2, but this is not recommended if you use both grub2-bios and grub2-efi-x86_64 in your system, as this will overwrite grub2-bios modules in /boot/grub .<br />
<br />
The {{ic|--root-directory}} option mentions the mountpoint of UEFI SYSTEM PARTITION , {{ic|--bootloader-id}} mentions the name of the directory used to store the grubx64.efi file and {{ic|--boot-directory}} mentions the directory wherein the actual modules will be installed (and into which grub.cfg should be created).<br />
<br />
The actual paths are<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi<br />
<br />
<boot-directory>/grub/<all modules, grub.efi, core.efi, grub.cfg><br />
<br />
Note the {{ic|--bootloader-id}} option does not change {{ic|<boot-directory>/grub}}, i.e. you cannot install the modules to {{ic|<boot-directory>/<bootloader-id>}}, the path is hard-coded to <boot-directory>/grub .<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == <boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/efi/efi/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
In {{ic|<nowiki>--root-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub</nowiki>}}<br />
<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/grub<br />
<boot-directory>/grub == /boot/grub<br />
<br />
The {{ic|<nowiki><root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi</nowiki>}} is an exact copy of {{ic|<nowiki><boot-directory>/grub/core.efi</nowiki>}} .<br />
<br />
{{Note| This behavior of --root-directory , --boot-directory , and --bootloader-id options are specific to UEFI systems and does not occur is BIOS mode. In grub_bios-install, --root-directory is deprecated and --bootloader-id option does not exist.}}<br />
<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for grub_efi_x86_64-install to install grubx64.efi in it, which will be launched by the firmware (using th efibootmgr created boot entry in non-Mac systems).<br />
<br />
If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub_efi_x86_64-install}} command unlike the case of setting up grub2 for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
<br />
You may now be able to UEFI boot your system by creating a grub.cfg file by following [[#Generate_GRUB2_UEFI_Config_file]] and [[#Create_GRUB2_entry_in_the_Firmware_Boot_Manager]].<br />
<br />
===== Create GRUB2 entry in the Firmware Boot Manager =====<br />
<br />
====== Non-Mac UEFI systems ======<br />
<br />
grub_efi_${UEFI_ARCH}-install will ensure that {{ic|/boot/efi/efi/arch_grub/grubx64.efi}} is launched by default if it detects {{ic|efibootmgr}} and if it is able to access UEFI Runtime Services. Follow [[Unified_Extensible_Firmware_Interface#efibootmgr]] for more info.<br />
<br />
If you have problems running GRUB2 in UEFI mode you can try the following (worked on an ASUS Z68 mainboard):<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shellx64.efi<br />
<br />
or<br />
<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shell/shellx64.efi<br />
<br />
After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The grub2 menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry (see above).<br />
<br />
====== Apple Mac EFI systems ======<br />
<br />
{{Note| TODO: Grub upstream bzr mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes}}<br />
{{Note| TODO: Fedora's mactel-boot ( https://bugzilla.redhat.com/show_bug.cgi?id&#61;755093 )}}<br />
<br />
Use bless command from within Mac OS X to set {{ic|grubx64.efi}} as the default boot option. You can also boot from the Mac OS X install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI System Partition:<br />
<br />
# cd /Volumes<br />
# mkdir efi<br />
# mount -t msdos /dev/disk0s1 /Volumes/efi<br />
<br />
Then run bless on {{ic|grub.efi}} and on the EFI partition to set them as the default boot options.<br />
<br />
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
<br />
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.<br />
<br />
===== Generate GRUB2 UEFI Config file =====<br />
<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
<br />
# GRUB_PREFIX="<boot-directory>/grub" grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot/efi/efi</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/efi/efi/grub" grub-mkconfig -o /boot/efi/efi/grub/grub.cfg<br />
<br />
If you used {{ic|<nowiki>--boot-directory=/boot</nowiki>}} :<br />
<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
This is independent of the value of --bootloader-id option. The {{ic|GRUB_PREFIX}} env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
<br />
If grub2-uefi complains about "no suitable mode found" while booting, try [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]].<br />
<br />
===== Create GRUB2 Standalone UEFI Application =====<br />
<br />
It is possible to create a grubx64_standalone.efi application which has all the modules embeddded in a memdisk within the uefi application, thus removing the need for having a separate directory populated with all the grub2 uefi modules and other related files. This is done using the grub-mkstandalone command which is included in extra/grub2-common >= 1:1.99-6 package.<br />
<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
<br />
The grubx64_standalone.efi file expects grub.cfg to be within its $prefix which is (memdisk)/boot/grub. The memdisk is embedded within the efi app. The grub-mkstandlone script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
<br />
If you have the grub.cfg at {{ic|/home/user/Desktop/grub.cfg}}, then create a temporary {{ic|/home/user/Desktop/boot/grub/}} directory, copy the {{ic|/home/user/Desktop/grub.cfg}} to {{ic|/home/user/Desktop/boot/grub/grub.cfg}}, cd into {{ic|/home/user/Desktop/boot/grub/}} and run<br />
<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
<br />
The reason to cd into {{ic|/home/user/Desktop/boot/grub/}} and to pass the file path as {{ic|boot/grub/grub.cfg}} (notice the lack of a leading slash - boot/ vs /boot/ ) is because {{ic|dir1/dir2/file}} is included as {{ic|(memdisk)/dir1/dir2/file}} by the grub-mkstandalone script. <br />
<br />
If you pass {{ic|/home/user/Desktop/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/grub.cfg}}. If you pass {{ic|/home/user/Desktop/boot/grub/grub.cfg}} the file will be included as {{ic|(memdisk)/home/user/Desktop/boot/grub/grub.cfg}} . That is the reason for cd'ing into {{ic|/home/user/Desktop/boot/grub/}} and passing {{ic|boot/grub/grub.cfg}}, to includ the file as {{ic|(memdisk)/boot/grub/grub.cfg}}, which is what grub.efi expects the file to be.<br />
<br />
You need to create an UEFI Boot Manager entry for {{ic|/boot/efi/efi/arch_grub/grubx64_standalone.efi}} using {{ic|efibootmgr}}. Follow [[#Create GRUB2 entry in the Firmware Boot Manager]].<br />
<br />
===== Multiboot in UEFI =====<br />
<br />
====== Chainload Microsoft Windows x86_64 UEFI-GPT ======<br />
<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows {{ic|bootmgfw.efi}} exists at {{ic|/boot/efi/efi/Microsoft/Boot/bootmgfw.efi}} (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
<br />
# grub-probe --target=fs_uuid /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
<br />
# grub-probe --target=hints_string /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
<br />
Then, add this code to {{ic|/boot/grub/grub.cfg}} OR {{ic|/boot/efi/efi/grub/grub.cfg}} to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
<br />
menuentry "Microsoft Windows x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
== Configuration ==<br />
<br />
You can also choose to automatically generate or manually edit {{ic|grub.cfg}}.<br />
<br />
{{Note|If GRUB2 was installed with the {{ic|--boot-directory}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in the BIOS version of GRUB2.}}<br />
<br />
=== Automatically generating using grub-mkconfig (Recommended) ===<br />
<br />
The GRUB2 {{ic|menu.1st}} equivalent configuration files are {{ic|/etc/default/grub}} and {{ic|/etc/grub.d/*}}. grub-mkconfig uses these files to generate {{ic|grub.cfg}}. By default the script outputs to stdout. To generate a {{ic|grub.cfg}} file run the command:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|/etc/grub.d/10_linux}} is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually by editing {{ic|/etc/grub.d/40_custom}}<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
A basic grub file uses the following options<br />
* {{ic|(hdX,Y)}} is the partition {{ic|Y}} on disk {{ic|X}}, partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=N}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=M}} is the time {{ic|M}} to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hdX,Y)}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc<br />
|/boot/grub/grub.cfg<br />
|<nowiki><br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
''NOTE: If you want GRUB2 to automatically search for other systems, for example as in Ubuntu. Then you may need to install {{Pkg|os-prober}}.''<br />
<br />
==== Using grub-mkconfig ====<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}}. The entries in this file will be automatically added when running '''grub-mkconfig'''.<br />
After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
===== With GNU/Linux =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
<br />
===== With FreeBSD =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
<br />
===== With Windows =====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}.<br />
<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader (hd0,3)+1<br />
}<br />
<br />
If the windows bootloader is on an entirely different harddrive than grub, it may be necessary to trick Windows into believing that it is in fact the first harddrive. This was possible in the old grub with {{ic|map}} and is now done with {{ic|drivemap}}. Assume grub is on {{ic|hd0}} and windows on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
drivemap -s hd0 hd2<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
<br />
===Visual Configuration===<br />
<br />
In GRUB2 it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, grub2 graphical terminal, gfxterm, with proper video mode, gfxmode, in grub2. This can be seen in the section [[#Correct_GRUB2_No_Suitable_Mode_Found_Error]]. This video mode is passed by grub2 to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
====Setting the framebuffer resolution ====<br />
<br />
Grub2 can set the framebuffer for both grub2 itself and the kernel. The old ''vga='' way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen.}}<br />
{{Note|To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at grub2 prompt you can use the {{ic|1=vbeinfo}} command.}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}<br />
<br />
====915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
In the following I will proceed with the example for my system. Please adjust the recipe for your needs. First you need to find a video mode which will be modified later. For that, run {{ic|915resolution}} in GRUB2 command shell.<br />
915resolution -l<br />
The output will be something like:<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
...<br />
Mode 30 : 640x480, 8 bits/pixel<br />
...<br />
Next, our purpose is to overwrite mode 30. (You can choose what ever mode you want.) In the file {{ic|/etc/grub.d/00_header}} just before the {{ic|set gfxmode&#61;${GRUB_GFXMODE} }} line insert<br />
915resolution 30 1440 900<br />
Here we are overwriting the mode {{ic| 30}} with {{ic|1440x900}} resolution. Lastly we need to set {{ic | GRUB_GFXMODE}} as described earlier, regenerate grub configuration file and reboot to test changes.<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
sudo reboot<br />
<br />
====Background image and bitmap fonts====<br />
<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename {{ic|unicode.pf2}}, or, as only ascii characters under the name {{ic|ascii.pf2}}. <br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [https://wiki.archlinux.org/index.php/GRUB2#Setting_the_framebuffer_resolution framebuffer resolution].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/archlinux.tga"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
<br />
(archlinux.tga is a placeholder; put your file name there)<br />
<br />
{{Note|If you have installed Grub on a separate partition, {{ic|/boot/grub/archlinux.tga}} becomes {{ic|/grub/archlinux.tga}}.}}<br />
<br />
To generate the changes and add the information into grub.cfg, run: <br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
If adding the splash image was successful, the user will see "Found background image..." in the terminal as the command is executed. <br />
If this phrase is not seen, the image information was probably not incorporated into the grub.cfg file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in /etc/default/grub are correct.<br />
* The image is of the proper size and format (tga, png, 8-bit jpg).<br />
* The image was saved in the RGB mode, and is not indexed.<br />
* The console mode is not enabled in /etc/default/grub.<br />
* The command grub-mkconfig must be executed to place the background image information into the /boot/grub/grub.cfg file.<br />
<br />
====Menu colors====<br />
<br />
As in Grub (0.9x), you can change the menu colors in Grub2. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html#Theme-file-format.<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
Generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
====Hidden menu====<br />
<br />
One of the unique features of Grub2 is hiding/skipping the menu and showing it by holding "Shift" when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
<br />
and run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
=== Other Options ===<br />
<br />
==== LVM ====<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=(''lvm_group_name''-''lvm_logical_boot_partition_name'')<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
==== Raid ====<br />
<br />
Grub2 provides convenient handling of raid-volumes. You need to add:<br />
insmod raid<br />
<br />
which allows you to address the volume natively. E.g. {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned raid-volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
==== Persistent block device naming ====<br />
You can use UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}} and {{ic|/dev/hd*}} scheming. It has the advantage of detecting partitions by their unique UUIDs, which is needed by some people booting with complicated partition setups.<br />
<br />
UUIDs are used by default in the recent versions of grub2 - there is no downside in it anyway except that you need to re-generate the {{ic|grub.cfg}} file every time you resize or reformat your partitions. Remember this when modifying partitions with Live-CD.<br />
<br />
The recent versions of grub2 use UUIDs by default. You can re-enable the use of UUIDS by simply commenting the UUID line (this is also what it looks like by default):<br />
#GRUB_DISABLE_LINUX_UUID=true<br />
you can also just set the value as {{ic|false}} as shown here:<br />
GRUB_DISABLE_LINUX_UUID=false<br />
<br />
Either way, do not forget to generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Using Labels ====<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L a <LABEL> <PARTITION><br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --no-floppy --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
==== Recall previous entry ====<br />
<br />
Grub2 can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the setting of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that grub will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
Note that manually added menu items, eg Windows in {{ic|/etc/grub.d/40_custom}}, will need {{ic|savedefault}} added. Remember to regenerate your configuration file.<br />
<br />
==== Security ====<br />
<br />
If you want to secure GRUB2 so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB2's configuration files. To do this, run the command {{ic|grub-mkpasswd_pbkdf2}}. Enter a password and confirm it. The output will look like this:<br />
<br />
{{bc|<nowiki><br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A</nowiki>}}Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
{{bc|<nowiki>cat << EOF<br />
<br />
set superusers="username"<br />
password_pbkdf2 username <password><br />
<br />
EOF</nowiki>}}<br />
where <password> is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB2 command line and boot parameters are now protected.<br />
<br />
==== Root Encryption ====<br />
<br />
To let GRUB2 automatically add the kernel parameters for root encryption,<br />
add "cryptdevice=/dev/yourdevice:label" to GRUB_CMDLINE_LINUX in /etc/defaults/grub .<br />
<br />
Example with root mapped to /dev/mapper/root :<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
Regenerate the configuration.<br />
<br />
=== Booting an ISO Directly From Grub2 ===<br />
Edit {{ic|/etc/grub.d/40_custom}} to add an entry for the target ISO. When finished, update the grub menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. Also adjust the img_dev line to match this same location.}}<br />
<br />
menuentry "Archlinux-2011.08.19-netinstall-x86_64.iso" {<br />
set isofile="/archives/archlinux-2011.08.19-netinstall-x86_64.iso"<br />
loopback loop (hd0,7)$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201108 img_dev=/dev/sda7 img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
{{Note|Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. }}<br />
<br />
menuentry "ubuntu-11.04-desktop-amd64.iso" {<br />
set isofile="/path/to/ubuntu-11.04-desktop-amd64.iso"<br />
loopback loop (hdX,Y)$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB2 supports pager for reading commands that provide long output (like the help command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB2 command shell type:<br />
sh:grub> set pager=1<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed from [[AUR]]<br />
* [https://aur.archlinux.org/packages.php?ID=44020 grub-customizer] (requires gettext gksu gtkmm hicolor-icon-theme openssl)<br />
*:Customize the bootloader (GRUB2 or BURG)<br />
* [http://kde-apps.org/content/show.php?content=139643 grub2-editor] (requires kdelibs)<br />
*:A KDE4 control module for configuring the GRUB2 bootloader<br />
* [http://kde-apps.org/content/show.php?content=137886 kcm-grub2] (requires kdelibs python2-qt kdebindings-python)<br />
*:This Kcm module manages the most common settings of Grub2.<br />
* [http://sourceforge.net/projects/startup-manager/ startupmanager] (requires gnome-python imagemagick yelp python2 xorg-xrandr)<br />
*:GUI app for changing the settings of GRUB, GRUB2, Usplash and Splashy<br />
<br />
== parttool or legacy hide/unhide ==<br />
<br />
If you have a win9x paradigm with hidden C disks GRUB legacy had the hide/unhide feature. In GRUB2 this has been replaced by parttool. For example, to boot the third C disk of three win9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the "linux" module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see [[#Configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then run:<br />
# grub-install /dev/sda --no-floppy<br />
<br />
to reinstall GRUB2 and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Bootloader installation]] for details.<br />
<br />
== Combining the use of UUID's and basic scripting ==<br />
<br />
If you like the idea of using UUID's to avoid unreliable BIOS mappings or are struggling with Grub's syntax, here is an example boot menu item that uses UUID's and a small script to direct Grub to the proper disk partitions for your system. All you need to do is replace the UUID's in the sample with the correct UUID's for your system. (The example applies to a system with a boot and root partition. You will obviously need to modify the Grub configuration if you have additional partitions.)<br />
<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 <br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables <br />
search --fs-uuid --no-floppy --set=root $the_root_uuid <br />
search --fs-uuid --no-floppy --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
Any troubleshooting should be added here.<br />
<br />
=== Enable GRUB2 debug messages ===<br />
<br />
Add<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== Correct GRUB2 No Suitable Mode Found Error ===<br />
<br />
If you get this error when booting any menuentry<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize grub2 graphical terminal (gfxterm) with proper video mode (gfxmode) in grub2. This video mode is passed by grub2 to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the grub2 video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in)<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB2_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems. If GRUB2 UEFI was installed with {{ic|1=--boot-directory=/boot/efi/efi}} set, then the directory is {{ic|/boot/efi/efi/grub/}}. <br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB2_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the unifont.pf2 file and then copy it to ${GRUB2_PREFIX_DIR}.<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable grub2 to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang:<br />
<br />
BIOS systems<br />
<br />
insmod vbe<br />
<br />
UEFI systems<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI)<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in ${GRUB2_PREFIX_DIR}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it [http://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#MBR_aka_msdos_partitioning_specific_instructions]]<br />
<br />
=== UEFI GRUB2 drops to shell ===<br />
<br />
If grub loads but drop you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB2 UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== UEFI GRUB2 not loaded ===<br />
In some cases the EFI may fail to load grub correctly. Provided everything is set up correctly, the output of<br />
efibootmgr -v<br />
might look something like this:<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
If everything works correctly, the EFI would now automatically load grub.<br><br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving grub to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for grub should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
If trying to boot windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move grub's device configuration and let it reconfigure.<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
Grub-mkconfig should now mention all found boot options including windows. If it works, remove /boot/grub/device.map-old.<br />
<br />
== References ==<br />
<br />
# Official GRUB2 Manual - http://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for Grub2 - https://help.ubuntu.com/community/Grub2<br />
# GRUB2 wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [http://en.wikipedia.org/wiki/BIOS_Boot_partition BIOS Boot Partition]<br />
<br />
== External Links ==<br />
<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_bios.sh A Linux Bash Shell script to compile and install GRUB2 for BIOS from BZR Source]<br />
# [https://github.com/the-ridikulus-rat/My_Shell_Scripts/blob/master/grub2/grub2_uefi.sh A Linux Bash Shell script to compile and install GRUB2 for UEFI from BZR Source]</div>Martadinatahttps://wiki.archlinux.org/index.php?title=GRUB_(Bahasa_Indonesia)&diff=189322GRUB (Bahasa Indonesia)2012-03-13T10:35:47Z<p>Martadinata: Created page with "GRUB2 is the next generation of the GRand Unified Bootloader (GRUB). GRUB2 is derived from PUPA which was a research project to investigate the next generation of GRUB. GRUB 2..."</p>
<hr />
<div>GRUB2 is the next generation of the GRand Unified Bootloader (GRUB). GRUB2 is derived from PUPA which was a research project to investigate the next generation of GRUB. GRUB 2 has been rewritten from scratch to clean up everything and provide modularity and portability [1].<br />
In brief, the bootloader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
Note: grub2 from 1.99 onwards supports btrfs as root (without a separate /boot filesystem), but the compression is limited to only zlib, not lzo. LZO compression support is currently in upstream bzr repo.<br />
Note: The official installer AIF (Arch Installation Framework) based Archiso does not support grub2-bios or grub2-uefi installation. However Archboot iso supports both grub2-bios and grub2-uefi installation.<br />
Contents [hide] <br />
1 Preface<br />
1.1 Notes for current GRUB Legacy users<br />
1.2 Preliminary Requirements for GRUB2<br />
1.2.1 BIOS systems<br />
1.2.1.1 GPT specific instructions<br />
1.2.1.2 MBR aka msdos partitioning specific instructions<br />
1.2.2 UEFI systems<br />
1.2.2.1 Create and Mount the UEFI SYSTEM PARTITION<br />
2 Installation<br />
2.1 During Arch Linux installation<br />
2.2 From a running Arch Linux<br />
2.2.1 BIOS systems<br />
2.2.1.1 Backup Important Data<br />
2.2.1.2 Install grub2-bios package<br />
2.2.1.3 Install grub2-bios boot files<br />
2.2.1.3.1 Install to 440-byte MBR boot code region<br />
2.2.1.3.2 Install to Partition or Partitionless Disk<br />
2.2.1.3.3 Generate core.img alone<br />
2.2.1.4 Generate GRUB2 BIOS Config file<br />
2.2.1.5 Multiboot in BIOS<br />
2.2.1.5.1 Boot Microsoft Windows installed in BIOS-MBR mode<br />
2.2.2 UEFI systems<br />
2.2.2.1 Install grub2-uefi package<br />
2.2.2.2 Install grub2-uefi boot files<br />
2.2.2.2.1 Install to UEFI SYSTEM PARTITION<br />
2.2.2.3 Create GRUB2 entry in the Firmware Boot Manager<br />
2.2.2.3.1 Non-Mac UEFI systems<br />
2.2.2.3.2 Apple Mac EFI systems<br />
2.2.2.4 Generate GRUB2 UEFI Config file<br />
2.2.2.5 Create GRUB2 Standalone UEFI Application<br />
2.2.2.6 Multiboot in UEFI<br />
2.2.2.6.1 Chainload Microsoft Windows x86_64 UEFI-GPT<br />
3 Configuration<br />
3.1 Automatically generating using grub-mkconfig (Recommended)<br />
3.2 Manually creating grub.cfg<br />
3.3 Dual-booting<br />
3.3.1 Using grub-mkconfig<br />
3.3.1.1 With GNU/Linux<br />
3.3.1.2 With FreeBSD<br />
3.3.1.3 With Windows<br />
3.3.2 With Windows via EasyBCD and NeoGRUB<br />
3.4 Visual Configuration<br />
3.4.1 Setting the framebuffer resolution<br />
3.4.2 915resolution hack<br />
3.4.3 Background image and bitmap fonts<br />
3.4.4 Menu colors<br />
3.4.5 Hidden menu<br />
3.5 Other Options<br />
3.5.1 LVM<br />
3.5.2 Raid<br />
3.5.3 Persistent block device naming<br />
3.5.4 Using Labels<br />
3.5.5 Recall previous entry<br />
3.5.6 Security<br />
3.5.7 Root Encryption<br />
3.6 Booting an ISO Directly From Grub2<br />
3.6.1 Arch ISO<br />
3.6.2 Ubuntu ISO<br />
4 Using the command shell<br />
4.1 Pager support<br />
5 GUI configuration tools<br />
6 parttool or legacy hide/unhide<br />
7 Using the rescue console<br />
8 Combining the use of UUID's and basic scripting<br />
9 Troubleshooting<br />
9.1 Enable GRUB2 debug messages<br />
9.2 Correct GRUB2 No Suitable Mode Found Error<br />
9.3 msdos-style error message<br />
9.4 UEFI GRUB2 drops to shell<br />
9.5 UEFI GRUB2 not loaded<br />
9.6 Invalid signature<br />
10 References<br />
11 External Links<br />
[edit] Preface<br />
<br />
Although, GRUB (i.e. version 0.9x) is the standard bootloader of Arch Linux, it is considered 'legacy' by upstream. It is being replaced by GRUB2 and Syslinux in many distributions. Upstream recommends GRUB2 >=1.99 over grub-legacy, even for current grub-legacy users.<br />
[edit] Notes for current GRUB Legacy users<br />
There are differences in the commands of GRUB and GRUB2. Familiarize yourself with GRUB2 commands before proceeding (e.g. "find" has been replaced with "search").<br />
GRUB2 is now modular and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for LVM or RAID support).<br />
Device naming has changed between GRUB and GRUB2. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0, and prefixed with partition-table type. For example, /dev/sda1 would be referred to as (hd0,msdos1) (for MBR) or (hd0,gpt1) (for GPT) using GRUB2.<br />
[edit] Preliminary Requirements for GRUB2<br />
[edit] BIOS systems<br />
[edit] GPT specific instructions<br />
GRUB2 in BIOS-GPT configuration requires a BIOS Boot Partition to embed its core.img in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB2 only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB2). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case. Syslinux does not require this partition.<br />
For a BIOS-GPT configuration, create a 2 MiB partition using cgdisk or GNU Parted with no filesystem. The location of the partition in the partition table does not matter but it should be within the first 2 TiB region of the disk. It is advisable to put it somewhere in the beginning of the disk before the /boot partition. Set the partition type to "EF02" in cgdisk or set <BOOT_PART_NUM> bios_grub on in GNU Parted.<br />
Note: This partition should be created before grub_bios-install or grub-setup is run or before the Install Bootloader step of the Archlinux installer (if GRUB2 BIOS is selected as bootloader).<br />
[edit] MBR aka msdos partitioning specific instructions<br />
Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 32 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding grub2's core.img ( https://bugs.archlinux.org/task/24103 ). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of core.img).<br />
If you do not dual-boot with MS Windows (any version) in BIOS systems, it is advisable to switch to GPT partitioning - GUID_Partition_Table#Convert_from_MBR_to_GPT_without_data_loss<br />
Note: Create the 2MiB partition mentioned above BEFORE you convert to GPT. If you do not, gparted will not resize your boot partition to allow its creation, and when you reboot grub2 will not know where to look.<br />
[edit] UEFI systems<br />
[edit] Create and Mount the UEFI SYSTEM PARTITION<br />
Follow Unified_Extensible_Firmware_Interface#Create_an_UEFI_SYSTEM_PARTITION_in_Linux for instructions on creating a UEFI SYSTEM PARTITION. Then mount the UEFI SYSTEM PARTITION at /boot/efi. It should be FAT32 formatted and should be >=200 MiB in size. If you have mounted the UEFISYS partition in some other mountpoint, replace /boot/efi in the below instructions with that mountpoint:<br />
# mkdir -p /boot/efi<br />
# mount -t vfat <UEFISYS_PART_DEVICE> /boot/efi<br />
Create a <UEFI_SYSTEM_PARTITION>/efi directory if it does not exist:<br />
# mkdir -p /boot/efi/efi<br />
[edit] Installation<br />
<br />
[edit] During Arch Linux installation<br />
Skip the Install Bootloader step and exit the installer.<br />
Configure the network:<br />
# aif -p partial-configure-network<br />
This will bring up a prompt; put in the network interface to use, (e.g., eth0) and use DHCP for easy configuration.<br />
If you did not configure the installed system's /etc/resolv.conf file during installation (for instance, if you plan to let DHCP generate it later), you will need to copy the one generated by AIF when it configured the network:<br />
# cp /etc/resolv.conf /mnt/etc/resolv.conf<br />
If you run into network issues in the pacman update step below, you may have needed to install the net-tools package.<br />
Check and see if the dm_mod module is loaded. If it is not, load it manually. (you might need grub2-bios; install the package if needed):<br />
# lsmod | grep dm_mod<br />
# modprobe dm-mod<br />
Note: This is necessary at this point, and cannot be postponed after the chroot. If you try to use modprobe in a chroot environment that has a later kernel version from that of the installing device (at the time of writing, 2.6.33), modprobe will fail. This happens routinely using the Arch "net" installations.<br />
From the installer's live shell, chroot to the installed system:<br />
# mount -o bind /dev /mnt/dev<br />
# mount -t proc /proc /mnt/proc/<br />
# mount -t sysfs /sys /mnt/sys/<br />
# chroot /mnt bash<br />
Update pacman's database:<br />
# pacman-db-upgrade<br />
Refresh the package list (with an extra -y flag to force a refresh of all package lists even if they appear to be up to date):<br />
# pacman -Syy<br />
Install the GRUB2 package as mentioned in the section #From a running Arch Linux. Note that the dm-mod module has already been loaded, no need to do that again.<br />
[edit] From a running Arch Linux<br />
[edit] BIOS systems<br />
[edit] Backup Important Data<br />
In general, a grub installation should run smoothly. Sometimes it could mess up your system. You're strongly advised to make a backup before installing grub2-bios.<br />
copy grub modules and configuration<br />
# cp -a /boot/grub /path/to/backup/<br />
backup the MBR and GRUB-Legacy stage 1.5<br />
# dd if=/dev/sdX of=/path/to/backup/first-sectors bs=512 count=63<br />
Replace /dev/sdaX with you disk path (mostly /dev/sda).<br />
Note: This command backs up the partition table too. Be careful while restoring if you've changed your partition setup in the meantime<br />
To backup only the MBR boot code use:<br />
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1<br />
You could now lightly remove /boot/grub with:<br />
# rm -rf /boot/grub<br />
and follow the instructions below. You know that if things get nasty, you could reboot your system thanks to an installation media and:<br />
move old grub-legacy or grub2 files out of the way<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
copy grub back to /boot<br />
# cp -a /path/to/backup/grub /boot/<br />
replace MBR and next 62 sectors of sda with backed up copy (DANGEROUS!)<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=63<br />
Note: This command also restores the partition table. Be careful.<br />
To restore only the MBR boot code use:<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1<br />
[edit] Install grub2-bios package<br />
The GRUB2 package can be installed with pacman (and will replace grub, if it is installed). Simply installing the package won't update the /boot/grub/core.img file and the grub2 modules in /boot/grub. You need to update them manually using grub_bios-install as explained below.<br />
# pacman -S grub2-bios<br />
Note: Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option --no-floppy. For more details search this option in the article.<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions:<br />
# modprobe dm-mod<br />
[edit] Install grub2-bios boot files<br />
There are 3 ways to install grub2 boot files in BIOS booting:<br />
#Install_to_440-byte_MBR_boot_code_region (recommended) ,<br />
#Install_to_Partition_or_Partitionless_Disk (not recommended),<br />
#Generate_core.img_alone (safest method, but requires another BIOS bootloader like grub-legacy or syslinux to be installed to chainload /boot/grub/core.img ).<br />
[edit] Install to 440-byte MBR boot code region<br />
To setup grub2-bios in the 440-byte Master Boot Record boot code region, populate the /boot/grub directory, generate the /boot/grub/core.img file, and embed it in the 32 KiB (minimum size - varies depending on partition alignment) post-MBR gap (MBR disks) or in BIOS Boot Partition (GPT disks), run:<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
where /dev/sda is the destination of the installation (in this case the MBR of the first SATA disk). If you use LVM for your /boot, you can install GRUB2 on multiple physical disks.<br />
The --no-floppy tells grub2-bios utilities not to search for any floppy devices which reduces the overall execution time of grub_bios-install on many systems (it will also prevent the issue below from occurring). Otherwise you get an error that looks like this:<br />
grub-probe: error: Cannot get the real path of '/dev/fd0'<br />
Auto-detection of a filesystem module failed.<br />
Please specify the module with the option '--modules' explicitly.<br />
Warning: Make sure that you check the /boot directory if you use the latter. Sometimes the boot-directory parameter creates another /boot folder inside of boot. A wrong install would look like this /boot/boot/grub !<br />
.<br />
[edit] Install to Partition or Partitionless Disk<br />
Note: grub2-bios (any version - including upstream bzr repo) does not encourage installation to a partition boot sector or a partitionless disk like grub-legacy or syslinux does. Neither do the Arch devs.<br />
To setup grub2-bios to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example /dev/sda1 as the /boot partition)<br />
# chattr -i /boot/grub/core.img<br />
# grub_bios-install --boot-directory=/boot --no-floppy --recheck --force --debug /dev/sda1<br />
# chattr +i /boot/grub/core.img<br />
You need to use the --force option to allow usage of blocklists and should not use --grub-setup=/bin/true (which is similar to simply generating core.img).<br />
grub_bios-install will give out warnings like which should give you the idea of what might go wrong with this approach.<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
Without --force you may get the below error and grub-setup will not setup its boot code in the partition boot sector.<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
With --force you should get<br />
Installation finished. No error reported.<br />
The reason why grub-setup does not by default allow this is because in case of partition or a partitionless disk is that grub2-bios relies on embedded blocklists in the partition bootsector to locate the /boot/grub/core.img file and the prefix dir /boot/grub. The sector locations of core.img may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
The workaround for this is to set the immutable flag on /boot/grub/core.img (using chattr command as mentioned above) so that the sector locations of the core.img file in the disk is not altered. The immutable flag on /boot/grub/core.img needs to be set only if grub2-bios is installed to a partition boot sector or a partitionless disk, not in case of installtion to MBR or simple generation of core.img without embedding any bootsector (mentioned above).<br />
[edit] Generate core.img alone<br />
To populate the /boot/grub directory and generate a /boot/grub/core.img file WITHOUT embedding any grub2-bios bootsector code in the MBR, post-MBR region, or the partition bootsector, add --grub-setup=/bin/true to grub_bios-install:<br />
# grub_bios-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck --debug /dev/sda<br />
You can then chainload grub2's core.img from grub-legacy or syslinux as a Linux kernel or a multiboot kernel.<br />
[edit] Generate GRUB2 BIOS Config file<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
If grub2 complains about "no suitable mode found" while booting, go to #Correct_GRUB2_No_Suitable_Mode_Found_Error.<br />
If grub-mkconfig fails, convert your /boot/grub/menu.lst file to /boot/grub/grub.cfg using:<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
For example:<br />
/boot/grub/menu.lst<br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
/boot/grub/grub.cfg<br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
If you forgot to create a GRUB2 /boot/grub/grub.cfg configfile and simply rebooted into GRUB2 Command Shell, type:<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
Boot into Arch and re-create the proper GRUB2 /boot/grub/grub.cfg configfile.<br />
Note: This option works only in BIOS systems, not in UEFI systems.<br />
[edit] Multiboot in BIOS<br />
[edit] Boot Microsoft Windows installed in BIOS-MBR mode<br />
Note: GRUB2 supports booting bootmgr directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.<br />
Find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the bootmgr and its files reside. For example, if Windows bootmgr exists at /media/Windows/bootmgr:<br />
# grub-probe --target=fs_uuid /media/Windows/bootmgr<br />
69B235F6749E84CE<br />
Then, add the below code to /etc/grub.d/40_custom and regenerate grub.cfg with grub-mkconfig as explained above to chainload Windows (Vista, 7 or 8) installed in BIOS-MBR mode:<br />
menuentry "Microsoft Windows 7 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/bootmgr<br />
}<br />
For Windows XP<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --no-floppy --set=root 69B235F6749E84CE<br />
ntldr (${root})/ntldr<br />
}<br />
[edit] UEFI systems<br />
[edit] Install grub2-uefi package<br />
Note: Unless specified as EFI 1.x , EFI and UEFI terms are used interchangeably to denote UEFI 2.x firmware. Also unless stated explicitely, the instructions are general and not Mac specific. Some of them may not work or may be different in Macs. Apple's EFI implementation is neither a EFI 1.x version nor UEFI 2.x version but mixes up both. This kind of firmware does not fall under any one UEFI Specification version and is therefore not a standard UEFI firmware.<br />
GRUB2 UEFI bootloader is available in Arch Linux only from version 1.99~rc1. To install, first Detect which UEFI firmware arch you have (either x86_64 or i386).<br />
Depending on that, install the appropriate package<br />
For 64-bit aka x86_64 UEFI firmware:<br />
# pacman -S grub2-efi-x86_64<br />
For 32-bit aka i386 UEFI firmware:<br />
# pacman -S grub2-efi-i386<br />
Note: Installing grub2-common (a dependency of grub2-bios) 1.99~rc1 or later, may take forever in some systems since the post_install script runs grub-mkconfig and this script does not provide the option --no-floppy. For more details search this option in the article.<br />
Note: Simply installing the package won't update the grub.efi file and the grub2 modules in the UEFI System Partition. You need to update the grub.efi file and the grub2 modules in the UEFI System Partition manually using grub_efi_${UEFI_ARCH}-install as explained below.<br />
Also load the device-mapper kernel module without which grub-probe does not reliably detect disks and partitions<br />
# modprobe dm-mod<br />
[edit] Install grub2-uefi boot files<br />
[edit] Install to UEFI SYSTEM PARTITION<br />
Note: The below commands assume you are using grub2-efi-x86_64 (for grub2-efi-i386 replace x86_64 with i386 in the below commands).<br />
The UEFI system partition will need to be mounted at /boot/efi for the GRUB2 install script to detect it.<br />
# mkdir -p /boot/efi<br />
# mount -t vfat /dev/sdXY /boot/efi<br />
Install GRUB UEFI application and its modules to /boot/efi/efi/arch_grub using<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
If you want to install grub2 modules and grub.cfg at the directory /boot/grub and only the grubx64.efi application at /boot/efi/efi/arch_grub use<br />
# grub_efi_x86_64-install --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub --no-floppy --recheck --debug<br />
In this case grub2-efi-x86_64 will be installed into /boot/grub, making the behavior consistent with the BIOS verion of GRUB2, but this is not recommended if you use both grub2-bios and grub2-efi-x86_64 in your system, as this will overwrite grub2-bios modules in /boot/grub .<br />
The --root-directory option mentions the mountpoint of UEFI SYSTEM PARTITION , --bootloader-id mentions the name of the directory used to store the grubx64.efi file and --boot-directory mentions the directory wherein the actual modules will be installed (and into which grub.cfg should be created).<br />
The actual paths are<br />
<root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi<br />
<boot-directory>/grub/<all modules, grub.efi, core.efi, grub.cfg><br />
Note the --bootloader-id option does not change <boot-directory>/grub, i.e. you cannot install the modules to <boot-directory>/<bootloader-id>, the path is hard-coded to <boot-directory>/grub .<br />
In --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub<br />
<root-directory>/<efi or EFI>/<bootloader-id> == <boot-directory>/grub == /boot/efi/efi/grub<br />
In --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=arch_grub<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/efi/efi/grub<br />
In --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=arch_grub<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/arch_grub<br />
<boot-directory>/grub == /boot/grub<br />
In --root-directory=/boot/efi --boot-directory=/boot --bootloader-id=grub<br />
<root-directory>/<efi or EFI>/<bootloader-id> == /boot/efi/efi/grub<br />
<boot-directory>/grub == /boot/grub<br />
The <root-directory>/<efi or EFI>/<bootloader-id>/grubx64.efi is an exact copy of <boot-directory>/grub/core.efi .<br />
Note: This behavior of --root-directory , --boot-directory , and --bootloader-id options are specific to UEFI systems and does not occur is BIOS mode. In grub_bios-install, --root-directory is deprecated and --bootloader-id option does not exist.<br />
In all the cases the UEFI SYSTEM PARTITION should be mounted for grub_efi_x86_64-install to install grubx64.efi in it, which will be launched by the firmware (using th efibootmgr created boot entry in non-Mac systems).<br />
If you notice carefully, there is no <device_path> option (Eg: /dev/sda) at the end of the grub_efi_x86_64-install command unlike the case of setting up grub2 for BIOS systems. Any <device_path> provided will be ignored by the install script as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
You may now be able to UEFI boot your system by creating a grub.cfg file by following #Generate_GRUB2_UEFI_Config_file and #Create_GRUB2_entry_in_the_Firmware_Boot_Manager.<br />
[edit] Create GRUB2 entry in the Firmware Boot Manager<br />
[edit] Non-Mac UEFI systems<br />
grub_efi_${UEFI_ARCH}-install will ensure that /boot/efi/efi/arch_grub/grubx64.efi is launched by default if it detects efibootmgr and if it is able to access UEFI Runtime Services. Follow Unified_Extensible_Firmware_Interface#efibootmgr for more info.<br />
If you have problems running GRUB2 in UEFI mode you can try the following (worked on an ASUS Z68 mainboard):<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
or<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shellx64.efi<br />
or<br />
# cp /boot/efi/efi/arch_grub/grubx64.efi /boot/efi/efi/shell/shellx64.efi<br />
After this launch the UEFI Shell from the UEFI setup/menu (in ASUS UEFI BIOS, switch to advanced mode, press Exit in the top right corner and choose "Launch EFI shell from filesystem device"). The grub2 menu will show up and you can boot into your system. Afterwards you can use efibootmgr to setup a menu entry (see above).<br />
[edit] Apple Mac EFI systems<br />
Note: TODO: Grub upstream bzr mactel branch http://bzr.savannah.gnu.org/lh/grub/branches/mactel/changes<br />
Note: TODO: Fedora's mactel-boot ( https://bugzilla.redhat.com/show_bug.cgi?id=755093 )<br />
Use bless command from within Mac OS X to set grubx64.efi as the default boot option. You can also boot from the Mac OS X install disc and launch a Terminal there if you only have Linux installed. In the Terminal, create a directory and mount the EFI System Partition:<br />
# cd /Volumes<br />
# mkdir efi<br />
# mount -t msdos /dev/disk0s1 /Volumes/efi<br />
Then run bless on grub.efi and on the EFI partition to set them as the default boot options.<br />
# bless --folder=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
# bless --mount=/Volumes/efi --file=/Volumes/efi/efi/arch_grub/grubx64.efi --setBoot<br />
More info at https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems_.28both_EFI_architecture.29.<br />
[edit] Generate GRUB2 UEFI Config file<br />
Finally, generate a configuration for grub2 (this is explained in greater detail in the Configuration section):<br />
# GRUB_PREFIX="<boot-directory>/grub" grub-mkconfig -o <boot-directory>/grub/grub.cfg<br />
If you used --boot-directory=/boot/efi/efi :<br />
# GRUB_PREFIX="/boot/efi/efi/grub" grub-mkconfig -o /boot/efi/efi/grub/grub.cfg<br />
If you used --boot-directory=/boot :<br />
# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg<br />
This is independent of the value of --bootloader-id option. The GRUB_PREFIX env variable is supported in extra/grub2-common >=1:1.99-6 package.<br />
If grub2-uefi complains about "no suitable mode found" while booting, try #Correct_GRUB2_No_Suitable_Mode_Found_Error.<br />
[edit] Create GRUB2 Standalone UEFI Application<br />
It is possible to create a grubx64_standalone.efi application which has all the modules embeddded in a memdisk within the uefi application, thus removing the need for having a separate directory populated with all the grub2 uefi modules and other related files. This is done using the grub-mkstandalone command which is included in extra/grub2-common >= 1:1.99-6 package.<br />
The easiest way to do this would be with the install command already mentioned before, but specifying the modules to include. For example:<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" <any extra files you want to include><br />
The grubx64_standalone.efi file expects grub.cfg to be within its $prefix which is (memdisk)/boot/grub. The memdisk is embedded within the efi app. The grub-mkstandlone script allow passing files to be included in the memdisk image to be as the arguments to the script (in <any extra files you want to include>).<br />
If you have the grub.cfg at /home/user/Desktop/grub.cfg, then create a temporary /home/user/Desktop/boot/grub/ directory, copy the /home/user/Desktop/grub.cfg to /home/user/Desktop/boot/grub/grub.cfg, cd into /home/user/Desktop/boot/grub/ and run<br />
# grub-mkstandlone --directory="/usr/lib/grub-x86_64-efi" --format="x86_64-efi" --compression="xz" \<br />
--output="/boot/efi/efi/arch_grub/grubx64_standalone.efi" "boot/grub/grub.cfg"<br />
The reason to cd into /home/user/Desktop/boot/grub/ and to pass the file path as boot/grub/grub.cfg (notice the lack of a leading slash - boot/ vs /boot/ ) is because dir1/dir2/file is included as (memdisk)/dir1/dir2/file by the grub-mkstandalone script.<br />
If you pass /home/user/Desktop/grub.cfg the file will be included as (memdisk)/home/user/Desktop/grub.cfg. If you pass /home/user/Desktop/boot/grub/grub.cfg the file will be included as (memdisk)/home/user/Desktop/boot/grub/grub.cfg . That is the reason for cd'ing into /home/user/Desktop/boot/grub/ and passing boot/grub/grub.cfg, to includ the file as (memdisk)/boot/grub/grub.cfg, which is what grub.efi expects the file to be.<br />
You need to create an UEFI Boot Manager entry for /boot/efi/efi/arch_grub/grubx64_standalone.efi using efibootmgr. Follow #Create GRUB2 entry in the Firmware Boot Manager.<br />
[edit] Multiboot in UEFI<br />
[edit] Chainload Microsoft Windows x86_64 UEFI-GPT<br />
Find the UUID of the FAT32 filesystem in the UEFI SYSTEM PARTITION where the Windows UEFI Bootloader files reside. For example, if Windows bootmgfw.efi exists at /boot/efi/efi/Microsoft/Boot/bootmgfw.efi (ignore the upper-lower case differences since that is immaterial in FAT filesystem):<br />
# grub-probe --target=fs_uuid /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28<br />
# grub-probe --target=hints_string /boot/efi/efi/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1<br />
Then, add this code to /boot/grub/grub.cfg OR /boot/efi/efi/grub/grub.cfg to chainload Windows x86_64 (Vista SP1+, 7 or 8) installed in UEFI-GPT mode:<br />
menuentry "Microsoft Windows x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
[edit] Configuration<br />
<br />
You can also choose to automatically generate or manually edit grub.cfg.<br />
Note: If GRUB2 was installed with the --boot-directory option set, the grub.cfg file must be placed in the same directory as grubx64.efi. Otherwise, the grub.cfg file goes in /boot/grub/, just like in the BIOS version of GRUB2.<br />
[edit] Automatically generating using grub-mkconfig (Recommended)<br />
The GRUB2 menu.1st equivalent configuration files are /etc/default/grub and /etc/grub.d/*. grub-mkconfig uses these files to generate grub.cfg. By default the script outputs to stdout. To generate a grub.cfg file run the command:<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
/etc/grub.d/10_linux is set to automatically add menu items for Arch linux that work out of the box, to any generated configuration. Other operating systems may need to be added manually by editing /etc/grub.d/40_custom<br />
[edit] Manually creating grub.cfg<br />
A basic grub file uses the following options<br />
(hdX,Y) is the partition Y on disk X, partition numbers starting at 1, disk numbers starting at 0<br />
set default=N is the default boot entry that is chosen after timeout for user action<br />
set timeout=M is the time M to wait in seconds for a user selection before default is booted<br />
menuentry "title" {entry options} is a boot entry titled title<br />
set root=(hdX,Y) sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition (/)<br />
An example configuration:<br />
/boot/grub/grub.cfg<br />
# Config file for GRUB2 - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
#set root=(hd0,3)<br />
#chainloader +1<br />
#}<br />
[edit] Dual-booting<br />
NOTE: If you want GRUB2 to automatically search for other systems, for example as in Ubuntu. Then you may need to install os-prober.<br />
[edit] Using grub-mkconfig<br />
The best way to add other entries is editing the /etc/grub.d/40_custom. The entries in this file will be automatically added when running grub-mkconfig. After adding the new lines, run:<br />
# grub-mkconfig -o /boot/grub/grub.cfg <br />
to generate an updated grub.cfg.<br />
[edit] With GNU/Linux<br />
Assuming that the other distro is on partition sda2:<br />
menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}<br />
[edit] With FreeBSD<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on sda4:<br />
menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}<br />
[edit] With Windows<br />
This assumes that your Windows partition is sda3.<br />
# (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root=(hd0,3)<br />
chainloader (hd0,3)+1<br />
}<br />
If the windows bootloader is on an entirely different harddrive than grub, it may be necessary to trick Windows into believing that it is in fact the first harddrive. This was possible in the old grub with map and is now done with drivemap. Assume grub is on hd0 and windows on hd2, you need to add the following after set root:<br />
drivemap -s hd0 hd2<br />
[edit] With Windows via EasyBCD and NeoGRUB<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB2 menu format, chainload to it by replacing the contents of your C:\NST\menu.lst file with lines similar to the following:<br />
default 0<br />
timeout 1<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/core.img<br />
[edit]Visual Configuration<br />
In GRUB2 it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, grub2 graphical terminal, gfxterm, with proper video mode, gfxmode, in grub2. This can be seen in the section #Correct_GRUB2_No_Suitable_Mode_Found_Error. This video mode is passed by grub2 to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
[edit]Setting the framebuffer resolution<br />
Grub2 can set the framebuffer for both grub2 itself and the kernel. The old vga= way is deprecated. The preferred method is editing /etc/default/grub as the following sample:<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
To generate the changes, run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
The gfxpayload property will make sure the kernel keeps the resolution.<br />
Note: If this example does not work for you try to replace gfxmode="1024x768x32" by vbemode="0x105". Remember to replace the specified resolution with one suitable for your screen.<br />
Note: To show all the modes you can use # hwinfo --framebuffer (hwinfo is available in [community]), while at grub2 prompt you can use the vbeinfo command.<br />
If this method does not work for you, the deprecated vga= method will still work. Just add it next to the "GRUB_CMDLINE_LINUX_DEFAULT=" line in /etc/default/grub for eg: "GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792" will give you a 1024x768 resolution.<br />
You can choose one of these resolutions: 640×480, 800×600, 1024×768, 1280×1024, 1600×1200<br />
[edit]915resolution hack<br />
Some times for Intel graphic adapters neither # hwinfo --framebuffer nor vbeinfo will show you the desired resolution. In this case you can use 915resolution hack. This hack will temporarily modify video BIOS and add needed resolution. See 915resolution's home page<br />
In the following I will proceed with the example for my system. Please adjust the recipe for your needs. First you need to find a video mode which will be modified later. For that, run 915resolution in GRUB2 command shell.<br />
915resolution -l<br />
The output will be something like:<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
...<br />
Mode 30 : 640x480, 8 bits/pixel<br />
...<br />
Next, our purpose is to overwrite mode 30. (You can choose what ever mode you want.) In the file /etc/grub.d/00_header just before the set gfxmode=${GRUB_GFXMODE} line insert<br />
915resolution 30 1440 900<br />
Here we are overwriting the mode 30 with 1440x900 resolution. Lastly we need to set GRUB_GFXMODE as described earlier, regenerate grub configuration file and reboot to test changes.<br />
sudo grub-mkconfig -o /boot/grub/grub.cfg<br />
sudo reboot<br />
[edit]Background image and bitmap fonts<br />
GRUB2 comes with support for background images and bitmap fonts in pf2 format. The unifont font is included in the grub2 package under the filename unicode.pf2, or, as only ascii characters under the name ascii.pf2.<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
Make sure you have set up the proper framebuffer resolution.<br />
Edit /etc/default/grub like this:<br />
GRUB_BACKGROUND="/boot/grub/archlinux.tga"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
(archlinux.tga is a placeholder; put your file name there)<br />
Note: If you have installed Grub on a separate partition, /boot/grub/archlinux.tga becomes /grub/archlinux.tga.<br />
To generate the changes and add the information into grub.cfg, run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
If adding the splash image was successful, the user will see "Found background image..." in the terminal as the command is executed. If this phrase is not seen, the image information was probably not incorporated into the grub.cfg file.<br />
If the image is not displayed, check:<br />
The path and the filename in /etc/default/grub are correct.<br />
The image is of the proper size and format (tga, png, 8-bit jpg).<br />
The image was saved in the RGB mode, and is not indexed.<br />
The console mode is not enabled in /etc/default/grub.<br />
The command grub-mkconfig must be executed to place the background image information into the /boot/grub/grub.cfg file.<br />
[edit]Menu colors<br />
As in Grub (0.9x), you can change the menu colors in Grub2. The available colors for GRUB2 are at http://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html#Theme-file-format. Here is an example:<br />
Edit /etc/default/grub:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
Generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
[edit]Hidden menu<br />
One of the unique features of Grub2 is hiding/skipping the menu and showing it by holding "Shift" when needed. You can also adjust whether you want to see the timeout counter.<br />
Edit /etc/default/grub as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
and run:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
[edit] Other Options<br />
[edit] LVM<br />
If you use LVM for your /boot, add the following before menuentry lines:<br />
insmod lvm<br />
and specify your root in the menuentry as:<br />
set root=(lvm_group_name-lvm_logical_boot_partition_name)<br />
Example:<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=(VolumeGroup-lv_boot)<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
[edit] Raid<br />
Grub2 provides convenient handling of raid-volumes. You need to add:<br />
insmod raid<br />
which allows you to address the volume natively. E.g. /dev/md0 becomes:<br />
set root=(md0)<br />
whereas a partitioned raid-volume (e.g. /dev/md0p1) becomes:<br />
set root=(md0,1)<br />
[edit] Persistent block device naming<br />
You can use UUIDs to detect partitions instead of the "old" /dev/sd* and /dev/hd* scheming. It has the advantage of detecting partitions by their unique UUIDs, which is needed by some people booting with complicated partition setups.<br />
UUIDs are used by default in the recent versions of grub2 - there is no downside in it anyway except that you need to re-generate the grub.cfg file every time you resize or reformat your partitions. Remember this when modifying partitions with Live-CD.<br />
The recent versions of grub2 use UUIDs by default. You can re-enable the use of UUIDS by simply commenting the UUID line (this is also what it looks like by default):<br />
#GRUB_DISABLE_LINUX_UUID=true<br />
you can also just set the value as false as shown here:<br />
GRUB_DISABLE_LINUX_UUID=false<br />
Either way, do not forget to generate the changes:<br />
grub-mkconfig -o /boot/grub/grub.cfg<br />
[edit] Using Labels<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the --label option to search. First of all, label your existing partition:<br />
# tune2fs -L a <LABEL> <PARTITION><br />
Then, add an entry using labels. An example of this:<br />
menuentry "Arch Linux, session texte" {<br />
search --label --no-floppy --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
[edit] Recall previous entry<br />
Grub2 can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit /etc/default/grub and change the setting of GRUB_DEFAULT:<br />
GRUB_DEFAULT=saved<br />
This ensures that grub will default to the saved entry. To enable saving the selected entry, add the following line to /etc/default/grub:<br />
GRUB_SAVEDEFAULT=true<br />
Note that manually added menu items, eg Windows in /etc/grub.d/40_custom, will need savedefault added. Remember to regenerate your configuration file.<br />
[edit] Security<br />
If you want to secure GRUB2 so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB2's configuration files. To do this, run the command grub-mkpasswd_pbkdf2. Enter a password and confirm it. The output will look like this:<br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A<br />
Then, add the following to /etc/grub.d/00_header:<br />
cat << EOF<br />
<br />
set superusers="username"<br />
password_pbkdf2 username <password><br />
<br />
EOF<br />
where <password> is the string generated by grub-mkpasswd_pbkdf2.<br />
Regenerate your configuration file. Your GRUB2 command line and boot parameters are now protected.<br />
[edit] Root Encryption<br />
To let GRUB2 automatically add the kernel parameters for root encryption, add "cryptdevice=/dev/yourdevice:label" to GRUB_CMDLINE_LINUX in /etc/defaults/grub .<br />
Example with root mapped to /dev/mapper/root :<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
Also, disable the usage of UUIDs for the rootfs:<br />
GRUB_DISABLE_LINUX_UUID=true<br />
Regenerate the configuration.<br />
[edit] Booting an ISO Directly From Grub2<br />
Edit /etc/grub.d/40_custom to add an entry for the target ISO. When finished, update the grub menu as with the usual grub-mkconfig -o /boot/grub/grub.cfg (as root).<br />
[edit] Arch ISO<br />
Note: Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile. Also adjust the img_dev line to match this same location.<br />
menuentry "Archlinux-2011.08.19-netinstall-x86_64.iso" {<br />
set isofile="/archives/archlinux-2011.08.19-netinstall-x86_64.iso"<br />
loopback loop (hd0,7)$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201108 img_dev=/dev/sda7 img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
[edit] Ubuntu ISO<br />
Note: Be sure to adjust the "hdX,Y" in the third line to point to the correct disk/partition number of the isofile.<br />
menuentry "ubuntu-11.04-desktop-amd64.iso" {<br />
set isofile="/path/to/ubuntu-11.04-desktop-amd64.iso"<br />
loopback loop (hdX,Y)$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
[edit] Using the command shell<br />
<br />
Since the MBR is too small to store all GRUB2 modules, only the menu and a few basic commands reside there. The majority of GRUB2 functionality remains in modules in /boot/grub, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB2 may fail to boot. When this happens, a command shell may appear.<br />
GRUB2 offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/normal.mod<br />
rescue:grub> normal<br />
[edit] Pager support<br />
GRUB2 supports pager for reading commands that provide long output (like the help command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB2 command shell type:<br />
sh:grub> set pager=1<br />
[edit] GUI configuration tools<br />
<br />
Following package may be installed from AUR<br />
grub-customizer (requires gettext gksu gtkmm hicolor-icon-theme openssl)<br />
Customize the bootloader (GRUB2 or BURG)<br />
grub2-editor (requires kdelibs)<br />
A KDE4 control module for configuring the GRUB2 bootloader<br />
kcm-grub2 (requires kdelibs python2-qt kdebindings-python)<br />
This Kcm module manages the most common settings of Grub2.<br />
startupmanager (requires gnome-python imagemagick yelp python2 xorg-xrandr)<br />
GUI app for changing the settings of GRUB, GRUB2, Usplash and Splashy<br />
[edit] parttool or legacy hide/unhide<br />
<br />
If you have a win9x paradigm with hidden C disks GRUB legacy had the hide/unhide feature. In GRUB2 this has been replaced by parttool. For example, to boot the third C disk of three win9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
[edit] Using the rescue console<br />
<br />
See #Using the command shell first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
The available commands in GRUB rescue include "insmod", "ls", "set", and "unset". This example uses "set" and "insmod". "set" modifies variables and "insmod" inserts new modules to add functionality.<br />
Before starting, the user must know the location of their /boot partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
where X is the physical drive number and Y is the partition number.<br />
To expand console capabilities, insert the "linux" module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
Note: With a separate boot partition, omit /boot from the path, (i.e. type set prefix=(hdX,Y)/grub and insmod (hdX,Y)/grub/linux.mod).<br />
This introduces the "linux" and "initrd" commands, which should be familiar (see #Configuration).<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
After successfully booting the Arch Linux installation, users can correct grub.cfg as needed and then run:<br />
# grub-install /dev/sda --no-floppy<br />
to reinstall GRUB2 and fix the problem completely, changing /dev/sda if needed. See #Bootloader installation for details.<br />
[edit] Combining the use of UUID's and basic scripting<br />
<br />
If you like the idea of using UUID's to avoid unreliable BIOS mappings or are struggling with Grub's syntax, here is an example boot menu item that uses UUID's and a small script to direct Grub to the proper disk partitions for your system. All you need to do is replace the UUID's in the sample with the correct UUID's for your system. (The example applies to a system with a boot and root partition. You will obviously need to modify the Grub configuration if you have additional partitions.)<br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07 <br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables <br />
search --fs-uuid --no-floppy --set=root $the_root_uuid <br />
search --fs-uuid --no-floppy --set=grub_boot $the_boot_uuid<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid] ; then<br />
set grub_boot=$grub_boot/boot<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux ($grub_boot)/vmlinuz-linux root=/dev/disk/by-uuid/$uuid_os_root ro<br />
initrd ($grub_boot)/initramfs-linux.img<br />
}<br />
[edit] Troubleshooting<br />
<br />
Any troubleshooting should be added here.<br />
[edit] Enable GRUB2 debug messages<br />
Add<br />
set pager=1<br />
set debug=all<br />
to grub.cfg.<br />
[edit] Correct GRUB2 No Suitable Mode Found Error<br />
If you get this error when booting any menuentry<br />
error: no suitable mode found<br />
Booting however<br />
Then you need to initialize grub2 graphical terminal (gfxterm) with proper video mode (gfxmode) in grub2. This video mode is passed by grub2 to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the grub2 video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in)<br />
Copy /usr/share/grub/unicode.pf2 to ${GRUB2_PREFIX_DIR} (/boot/grub/ in case of BIOS and UEFI systems. If GRUB2 UEFI was installed with --boot-directory=/boot/efi/efi set, then the directory is /boot/efi/efi/grub/.<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB2_PREFIX_DIR}<br />
If /usr/share/grub/unicode.pf2 does not exist, install bdf-unifont, create the unifont.pf2 file and then copy it to ${GRUB2_PREFIX_DIR}.<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
Then, in the grub.cfg file, add the following lines to enable grub2 to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang:<br />
BIOS systems<br />
insmod vbe<br />
UEFI systems<br />
insmod efi_gop<br />
insmod efi_uga<br />
After that add the following code (common to both BIOS and UEFI)<br />
insmod font<br />
if loadfont ${prefix}/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
As you can see for gfxterm (graphical terminal) to function properly, unicode.pf2 font file should exist in ${GRUB2_PREFIX_DIR}.<br />
[edit] msdos-style error message<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
This error may occur when you try installing GRUB2 in a VMware container. Read more about it here. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read #MBR_aka_msdos_partitioning_specific_instructions<br />
[edit] UEFI GRUB2 drops to shell<br />
If grub loads but drop you into the rescue shell with no errors, it may be because of a missing or misplaced grub.cfg. This will happen if GRUB2 UEFI was installed with --boot-directory and grub.cfg is missing OR if the partition number of the boot partition changed (which is hard-coded into the grubx64.efi file).<br />
[edit] UEFI GRUB2 not loaded<br />
In some cases the EFI may fail to load grub correctly. Provided everything is set up correctly, the output of<br />
efibootmgr -v<br />
might look something like this:<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
If everything works correctly, the EFI would now automatically load grub.<br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to this post, moving grub to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for grub should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
[edit] Invalid signature<br />
If trying to boot windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move grub's device configuration and let it reconfigure.<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
Grub-mkconfig should now mention all found boot options including windows. If it works, remove /boot/grub/device.map-old.<br />
[edit] References<br />
<br />
Official GRUB2 Manual - http://www.gnu.org/software/grub/manual/grub.html<br />
Ubuntu wiki page for Grub2 - https://help.ubuntu.com/community/Grub2<br />
GRUB2 wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
Wikipedia's page on BIOS Boot Partition<br />
[edit] External Links<br />
<br />
A Linux Bash Shell script to compile and install GRUB2 for BIOS from BZR Source<br />
A Linux Bash Shell script to compile and install GRUB2 for UEFI from BZR Source<br />
Category: Boot loaders (English)</div>Martadinata