Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
GNU GRUB
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==={{anchor|GRUB 2}}Version 2 (GRUB 2)=== [[File:GNU GRUB components.svg|thumb|upright=1.5|GRUB 2 β MBR vs. GPT partitioning and boot sequence visualized (systems using BIOS firmware).]] ==== Startup on systems using [[BIOS]] firmware ==== * See illustration in last image on the right.<ref>{{Cite web|title=GNU GRUB Manual 2.04|url=https://www.gnu.org/software/grub/manual/grub/grub.html#Images|access-date=2020-11-10|website=www.gnu.org|archive-date=April 3, 2018|archive-url=https://web.archive.org/web/20180403023208/http://www.gnu.org/software/grub/manual/grub/grub.html#Images|url-status=live}}</ref> * <code>boot.img</code> ('''stage 1''') is written to the first 440 bytes of the [[Master boot record|Master Boot Record]] (MBR boot code in sector 0), or optionally in a [[partition boot sector]] (PBR). It addresses <code>diskboot.img</code> by a 64-bit [[Logical block addressing | LBA]] address. The actual sector number is written by <code>grub-install</code>. <code>diskboot.img</code> is the first sector of <code>core.img</code> with the sole purpose to load the rest of <code>core.img</code> identified by LBA sector numbers also written by <code>grub-install</code>. ** On MBR partitioned disks, <code>core.img</code> ('''stage 1.5''') is stored in the empty sectors (if available) between the MBR and the first partition. Recent operating systems suggest a 1 MiB gap here for alignment (2047 512-byte, or 255 4KiB, sectors). This gap used to be 62 sectors (31 KiB) as a reminder of the sector number limit of [[Cylinder-Head-Sector]] (C/H/S) addressing used by [[BIOS]] before 1996, therefore <code>core.img</code> is designed to be smaller than 32 KiB. **On GPT partitioned disks <code>core.img</code> is written to its own partition. It must be flagged "BIOS_grub", must not be [[file system|formatted]] and can be as tiny as 1 MiB. * '''stage 2:''' <code>core.img</code> loads <code>/boot/grub/i386-pc/normal.mod</code> from the partition configured by <code>grub-install</code>. If the partition index has changed, GRUB will be unable to find the <code>normal.mod</code>, and presents the user with the GRUB Rescue prompt. * Depending on how GRUB2 was installed, the <code>/boot/grub/</code> is either in the ''root'' partition of the Linux distribution, or in the separate ''/boot'' partition. * '''after normal.mod loaded:''' <code>normal.mod</code> parses <code>/boot/grub/grub.cfg</code>, optionally loads modules (eg. for graphical UI and file system support) and shows the menu. ==== Startup on systems using [[UEFI]] firmware ==== * <code>/efi/<distro>/grubx64.efi</code> (for [[x64]] UEFI systems) is installed as a file in the [[EFI system partition|EFI System Partition]], and booted by the firmware directly, without a <code>boot.img</code> in MBR sector 0. This file is like stage1 and stage1.5. * <code>/boot/grub/</code> can be installed on the EFI System Partition or the separate ''/boot'' partition, among others. * For x64 UEFI systems, stage2 are the <code>/boot/grub/x86_64-efi/normal.mod</code> file and other <code>/boot/grub/</code> files. ==== After startup ==== GRUB presents a menu where the user can choose from operating systems (OS) found by grub-install. GRUB can be configured to automatically load a specified OS after a user-defined timeout. If the timeout is set to zero seconds, pressing and holding {{Keypress|Shift}}, or in some modern GRUB versions loaded using UEFI, pressing {{Keypress|Esc}} rapidly while the computer is booting makes it possible to access the boot menu.<ref name="howtogeek.com">{{cite web|url=http://www.howtogeek.com/196655/how-to-configure-the-grub2-boot-loaders-settings/|title=How to Configure the GRUB2 Boot Loader's Settings|website=HowToGeek.com|first=Chris|last=Hoffman|date=September 22, 2014|access-date=April 25, 2015|archive-date=April 28, 2015|archive-url=https://web.archive.org/web/20150428233135/http://www.howtogeek.com/196655/how-to-configure-the-grub2-boot-loaders-settings/|url-status=live}}</ref> In the operating system selection menu GRUB accepts a couple of commands: * By pressing {{key press|e}}, it is possible to edit kernel parameters of the selected menu item ''before the operating system is started''. The reason for doing this in GRUB (i.e. not editing the parameters in an already booted system) can be an emergency case: the system has failed to boot. Using the kernel parameters line it is possible, among other things, to specify a module to be disabled (blacklisted) for the kernel. This could be required if the specific kernel module is broken and thus prevents boot-up. For example, to blacklist the kernel module <code>nvidia-current</code>, one could append <code>modprobe.blacklist=nvidia-current</code> at the end of the kernel parameters. * By pressing {{key press|c}}, the user enters the GRUB command line. The GRUB command line resembles GNU Bash, but only implements a subset of the line editing functions and GRUB-specific commands.<ref>{{cite web |url=https://www.gnu.org/software/grub/grub-documentation.html |title=GNU GRUB documentation |access-date=April 16, 2014 |archive-date=April 18, 2014 |archive-url=https://web.archive.org/web/20140418191412/http://www.gnu.org/software/grub/grub-documentation.html |url-status=live }}</ref> Once boot options have been selected, GRUB loads the selected kernel into memory and passes control to the kernel. Alternatively, GRUB can pass control of the boot process to another boot loader, using ''[[chain loading]]''. This is the method used to load operating systems that do not support the [[Multiboot Specification]] or are not supported directly by GRUB.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)