In a normal boot, you use the up- and down-arrow keys to navigate through the menu and then select your desired entry by pressing Enter. On Linux systems, GRUB then loads the kernel and initial RAM disk and passes control of the computer to the kernel. Changing your boot options If you get to a GRUB menu similar to the one shown in but your selection fails to start, there might be a problem with the boot entry. GRUB includes a simple text editor so that you can make temporary changes your boot stanzas at runtime. To change your boot options, select the entry in the GRUB menu that's closest to what you want to achieve and then press the e key. The result resembles Figure 2: Figure 2. The GRUB text editor.
This document contains installation instructions for the Ubuntu 18.04 system (codename “'Bionic Beaver'”), for the 32-bit PC (“i386”). Disabling the Windows 8 “fast boot” feature. Hard disk installer booting from Linux using LILO or GRUB. Looking for the Ubuntu Installer ISO Image.
The lines in Figure 2 are the same as those in the boot stanza in. You can edit these entries much as if you were using a text-mode text editor in Linux. Any changes that you make in this editor are temporary.
(To learn how make your changes permanent, see, later in this article.) One common reason to edit a boot stanza in the text editor is to make a one-boot change. For instance, suppose that you want to boot into single-user mode to perform low-level maintenance, but there's no single-user entry in GRUB. You can achieve your goal by editing the boot stanza and adding single to the end of the linux line.
When you're done, press Ctrl-x or F10 to boot, as the prompt at the bottom of the screen reminds you. If you create a new GRUB entry and it fails to start, you might be able to discover the problem by examining the boot entry. Perhaps the entry contains a typo, such as linu instead of linux. Maybe you omitted the initrd line. Perhaps you specified the wrong root file system.
You might be able to correct such problems by using your knowledge of your system and of GRUB 2 configuration generally. In other cases, though, you might lack critical knowledge. For instance, you might need to learn what your root file system's identifier is. In such cases, or when problems are more severe, you can use the GRUB 2 shell.
Using the GRUB 2 shell GRUB includes its own built-in shell where you can type commands similar to those you can type in Bash or other Linux text-mode shells. The GRUB shell is simple by Linux standards, but it's adequate for many emergency maintenance tasks.
To enter the shell from the GRUB main menu , press c. To enter the shell from the GRUB editor , press Ctrl-c or F2. The result resembles Figure 3: Figure 3.
The GRUB shell. The GRUB 2 shell supports a range of commands, many of which are similar or identical to the commands used in grub.cfg to control the menu-driven boot process. If you're familiar enough with the GRUB 2 configuration file format, you can boot your computer by typing commands at the shell. In practice, you're more likely to use the shell for recovery operations.
Table 1 presents some of the commands that are most likely to be useful in this respect. GRUB 2 supports many additional commands, which you can read about in the. Common GRUB 2 command-line commands Command Options Explanation boot None Boot a kernel or chain loader that's already been defined. Cat filename Display the contents of the specified file.
Configfile filename Load the specified configuration file. Help command Display help—either a list of commands or help on the specified command. Initrd filename Load the specified initial RAM disk file. Insmod modulename Load the specified module (driver). Linux filename Load the specified Linux kernel. Ls arg List devices or files on a device.
Reboot None Reboot the computer. Set envvar=value Set an environment variable equal to a value. One problem that can motivate use of GRUB's command line is GRUB's inability to locate its own configuration file. Reinstalling GRUB, as I describe in this article's section, is the long-term solution. In the meantime, though, you can issue a few commands to bring up your regular GRUB menu and boot Linux.
To begin, you must identify the partition on which GRUB is installed. You can do this with the help of the ls command. Used without any options, ls displays the disks and partitions that GRUB can detect. You can then look inside particular partitions by specifying the device's name with a trailing slash ( /), as shown in Listing 2: Listing 2. Using ls to view devices or the contents of file systems grub ls (hd0) (hd0,gpt5) (hd0,gpt4) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) grub ls (hd0,gpt5)/ abi-3.2.0-22-generic grub/ initrd.img-3.2.0-22-generic memtest86+bin System.map-3.2.0-22-generic vmcoreinfo-3.2.0-22-generic vmlinuz-3.2.0-22-generic The example in Listing 2 shows a computer with a single disk (hd0) that holds five globally unique identifier (GUID) Partition Table (GPT) partitions. The contents of (hd0,gpt5) appear to be a Linux /boot partition, including a GRUB configuration directory (grub/). You might need to peek inside other partitions before finding your Linux /boot partition.
If your system doesn't use a separate /boot partition, you must look for your Linux root (/) partition instead. With the home of the GRUB configuration file identified, you can tell GRUB where to find it by setting the prefix and root environment variables. These variable identify, respectively, the directory in which grub.cfg lives and the partition on which it resides: grub set prefix=(hd0,gpt5)/grub grub set root=(hd0,gpt5) From here, you can load the normal module and launch it to bring up the GRUB menu: grub insmod normal grub normal Using Super GRUB2 Disk. A BIOS-only tool Super GRUB2 Disk is a BIOS-only tool. If you normally boot in EFI mode, Super GRUB2 Disk isn't helpful. EFI-mode booting doesn't rely on code that's stored in the MBR or a disk's boot sector, which are code areas that — when damaged — make Super GRUB2 Disk most useful. In case of EFI boot problems, your firmware's boot manager or an ancillary program, such as rEFInd, might help you recover from problems caused by corrupted NVRAM settings.
I also recommend backing up the files in an EFI computer's ESP in case that partition becomes damaged. Because EFI doesn't rely on hidden code, you can restore the ESP with a simple file-copy operation. (Full disclosure: I maintain rEFInd.) In some cases, GRUB won't even give you a grub prompt, or you might have trouble resolving a problem even with the prompt.
In these cases, the rescue tool can help. Preparing for disaster Even if you can boot successfully now, I recommend that you have copy of Super GRUB2 Disk on hand for immediate use when you need it. The is a hybrid image file with a.iso extension.
You can use dd to copy this file to a floppy disk, a CompactFlash (CF) disk, a Universal Serial Bus (USB) flash drive, or a similar type of disk. Alternatively, you can use cdrecord or a GUI optical disk tool to copy the file to a CD-R. After you create your boot medium, I recommend that you test it — ideally, on multiple computers — to familiarize yourself with the tool and to verify that it works on the hardware you use. Booting with Super GRUB2 Disk After you prepare a Super GRUB2 Disk, you can boot it like any other bootable disk. In some cases, you might need to change your boot order by pressing a key during your boot process. F2, F10, and F12 are common choices, but you should consult your computer's manual for details. When Super GRUB2 Disk boots, you're greeted by a display, similar to the one shown in Figure 4, that includes options to detect OSs or enable various types of support: Figure 4.
GRUB menu that's displayed when you boot Super GRUB2 Disk. If your computer uses redundant array of independent disks (RAID) or Logical Volume Management (LVM) — or relies on older Parallel ATA (PATA) disks or external USB disks — you might need to activate those features by selecting them and pressing Enter. When that's done, you can try the detection options.
I find that the Detect any GRUB2 configuration file (grub.cfg) and Detect any GRUB2 installation (even if the MBR is overwritten) options generally work best for recovering a damaged GRUB installation. But the Detect any Operating System option might also be worth trying.
If the detection is successful, you should see a new GRUB menu of options. On a single-OS installation, this menu probably contains just one entry that identifies the GRUB configuration file by its path, as in (hd0,gpt5)/grub/grub.cfg. When you select this option, your installation's normal GRUB screen should appear. (Fonts and colors might be different, but the menu options should work normally.) Making permanent repairs Repairs such as those that I've described so far are impermanent. You might boot Linux successfully, but as soon as you reboot you end up with the original GRUB screen.
To make your changes permanent, you need to take additional steps. The simplest of these steps is to adjust your GRUB configuration file. Although you can edit grub.cfg directly to alter your settings, this approach is inadvisable because automated scripts are likely to reconstruct the file from other files whenever you upgrade your distribution-provided kernel. Instead, edit files in /etc/grub.d and default global settings in /etc/default/grub. You can then generate a new grub.cfg file from the Linux command prompt by using grub-mkconfig: grub-mkconfig -o /boot/grub/grub.cfg If your problem is that GRUB brought up only a grub prompt or didn't start at all, you must reinstall GRUB to your hard disk: grub-install /dev/sda In some cases, you might need to install to a device other than /dev/sda, such as /dev/sdb.
Installing GRUB 2 to a partition is generally inadvisable. If you're installing GRUB to a GPT disk on a BIOS-based computer, ensure that the computer includes a BIOS Boot Partition. Without it, GRUB might refuse to install or might be unreliable. If you're installing GRUB to an EFI-based computer, omit the device specification and ensure that your ESP is mounted at /boot/efi. Grub-install copies the necessary files to this directory (and hence to the ESP) automatically. If GRUB doesn't start on an EFI-based computer because of improper NVRAM settings, you might be able to fix those within the firmware itself, but details vary greatly among implementations. Alternatively, if you can boot an emergency system in EFI mode, you can use efibootmgr to restore your boot loader: efibootmgr -c -l EFI loaderdir loadername.efi -L MenuName Conclusion GRUB 2 is a flexible tool for directly booting Linux (and several other) OS kernels.
But because of vulnerabilities in the boot process and GRUB's own complexity, problems can occur that can render a system unbootable. In such situations, knowing how to edit individual GRUB stanzas, use the GRUB command line, and use Super GRUB2 Disk are invaluable skills. By using these techniques, you can recover from various boot problems and boot into your normal installation.
At that point, you can edit your GRUB 2 configuration file or reinstall the boot loader to make your repairs permanent. Related topics.: Consult the official GRUB 2 manual to access a wealth of information about the GRUB 2 boot loader.
' (Roderick W. Smith, developerWorks, April 2010): Get background information on boot loaders in general and an overview of GRUB 2 in particular.: Learn more about Super GRUB2 Disk from the project website.: Find out how rEFInd can help you recover from some types of low-level EFI boot problems. In the, find hundreds of as well as downloads, discussion forums, and a wealth of other resources for Linux developers and administrators.: Download the Super GRUB2 Disk.: Download rEFInd from SourceForge.