Troubleshoot Grand and Configure Unified Bootloader

Troubleshoot Grand, Because of the latest changes within the LFCS certification. exam goals powerful from February 2nd, 2016, we’re including the wanted subjects to the LFCS collection posted here. To put together for this examination, you are incredibly recommended to follow the LFCE collection as properly.

In this newsletter we can introduce you to GRUB and explain why a boot loader is vital. and the way it provides versatility to the system.

The Linux boot technique from the time you press the power button of your pc. until you get a totally-practical machine follows this high-degree series:

  1. A system known as POST (Power-On Self Test) plays an normal check at the hardware components of your computer.
  2. When POST completes, it passes the manage over to the boot loader. Which in turn loads the Linux kernel. In reminiscence (in conjunction with initramfs) and executes it. The maximum used boot loader in Linux is the GRand Unified Boot loader, or GRUB for brief.
  3. The kernel tests and accesses the hardware, after which runs the preliminary procedure. (ordinarily regarded by means of its conventional name “init”) which in flip completes the gadget boot via starting offerings.

In Part 7 of this series (“SysVinit, Upstart, and Systemd”) .we introduced the service control systems and gear used by modern Linux distributions. You may want to check that article earlier than intending further.

Introducing GRUB Boot Loader, Troubleshoot Grand

Two foremost GRUB versions (v1 every now and then referred to as GRUB Legacy and v2). Can be discovered in modern-day systems. Despite the fact that maximum distributions use v2 by using default of their cutting-edge variations. Only Red Hat Enterprise Linux 6 and its derivatives still use v1 nowadays.

Thus, we are able to cognizance basically at the functions of v2 in this guide.

Regardless of the GRUB version, a boot loader permits the person to:

  • 1). Regulate the manner the gadget behaves by using specifying distinct kernels to apply,
  • 2). Pick out among trade operating structures as well, and
  • 3). Upload or edit configuration stanzas to trade boot options, amongst other matters.

Today, GRUB is maintained by way of the GNU assignment and is properly documented of their internet site. You are recommended to apply the GNU authentic documentation even as going thru this guide.

When the system boots you are provided with the subsequent GRUB screen inside the important console. Initially, you are induced to pick among alternate kernels (via defaul.

The system will boot the usage of the present day kernel) and are allowed to go into a GRUB command line (with c) or edit the boot alternatives (by using urgent the e key ).

One of the motives why you will remember booting with an older kernel is a hardware device. That used to paintings properly and has commenced.

acting up” after an improve (talk to this hyperlink inside the AskUbuntu boards for an instance).

The GRUB v2 configuration is read on boot from /boot/grub/grub.cfg or /boot/grub2/grub.cfg, whereas /boot/grub/grub.conf or /boot/grub/menu.lst are used in v1.

These files are NOT to be edited by hand, but are modified based on the contents of /etc/default/grub and the files found inside /etc/grub.d.

In a CentOS 7, here’s the configuration document that is created while the gadget is first mounted:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="vconsole.keymap=la-latin1 rd.lvm.lv=centos_centos7-2/swap crashkernel=auto  vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos_centos7-2/root rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

In addition to the net documentation, you can also find the GNU GRUB guide the usage of info as follows:

# info grub

If you’re involved mainly in the options to be had for /etc/default/grub, you could invoke the configuration section without delay:

# info -f grub -n 'Simple configuration'

Using the command above you may find that GRUB_TIMEOUTsets the time among the moment while the preliminary screen seems.

And the machine computerized booting begins unless interrupted by using the person. When this variable is ready to -1, boot will now not be started till the user makes a diffusion.

When a couple of working systems or kernels are established inside the same machine, GRUB_DEFAULT requires an integer value that indicates which OS or kernel entry in the GRUB preliminary screen need to be selected besides by means of default.

The listing of entries can be regarded not simplest within the splash screen proven above. However also the usage of the subsequent command:

Troubleshoot Grand CentOS and openSUSE:

# awk -F\' '$1=="menuentry " {print $2}' /boot/grub2/grub.cfg

Ubuntu:

# awk -F\' '$1=="menuentry " {print $2}' /boot/grub/grub.cfg

In the example proven inside the beneath photograph, if we choice to boot with the kernel version 3.10.0-123.el7.x86_64 (4th access).

We need to set GRUB_DEFAULT to 3 ( entries are internally numbered beginning with zero) as follows:

GRUB_DEFAULT=3

One final GRUB configuration variable that is of unique interest is GRUB_CMDLINE_LINUX, ,which is used to bypass options to the kernel.

The alternatives that can be handed via GRUB to the kernel are nicely documented. Within the Kernel Parameters file and in guy 7 bootparam.

Current alternatives in my CentOS 7 server are:

GRUB_CMDLINE_LINUX="vconsole.keymap=la-latin1 rd.lvm.lv=centos_centos7-2/swap crashkernel=auto  vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos_centos7-2/root rhgb quiet"

Why would you want to alter the default kernel parameters or bypass more alternatives? In easy phrases, there may be instances when you need to inform the kernel.

Sure hardware parameters that it is able to no longer be capable of decide on its own. Or to override the values that it’d discover.

This happened to me no longer too lengthy ago once I attempted Vector Linux. A by-product of Slackware, on my 10-12 months vintage laptop.

After set up it did now not hit upon the proper settings for my video card. So I had to alter the kernel options passed through GRUB on the way to make it work.

Another instance is when you want to deliver the device to single-consumer mode to carry out upkeep obligations. You can do this by way of appending the word unmarried to GRUB_CMDLINE_LINUX and rebooting:

GRUB_CMDLINE_LINUX="vconsole.keymap=la-latin1 rd.lvm.lv=centos_centos7-2/swap crashkernel=auto  vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos_centos7-2/root rhgb quiet single"

After modifying /etc/defalt/grub, you may need to run update-grub (Ubuntu) or grub2-mkconfig -o /boot/grub2/grub.cfg (CentOS and openSUSE) afterwards to update grub.cfg (in any other case, adjustments can be lost upon boot).

Troubleshoot Grand, This command will system the boot configuration documents mentioned in advance to replace grub.cfg.

This approach guarantees adjustments are permanent. Even as alternatives exceeded thru GRUB at boot time will most effective last all through the cutting-edge session.

Fixing Linux GRUB Issues

If you put in a second operating gadget. In case your GRUB configuration report gets corrupted because of human mistakes. There are ways you can get your system lower back on its ft and be able to boot again.

In the preliminary display screen. Press c to get a GRUB command line (take into account that you could additionally press e to edit the default boot options). And use assist to carry the available instructions within the GRUB set off:

Troubleshoot Grand, We will attention on ls, a good way to listing the set up devices and filesystems. And we will study what it finds. In the picture beneath we can see that there are 4 difficult drives (hd0 via hd3).

Only hd0 appears to were partitioned (as evidenced through msdos1 and msdos2. Where 1 and a pair of are the partition numbers and msdos is the partitioning scheme).

Let’s now observe the first partition on hd0 (msdos1) to look if we will locate GRUB there. This method will allow us in addition Linux and there use other high stage. Gear to restore the configuration report or reinstall GRUB altogether if it’s far wished:

# ls (hd0,msdos1)/

As we will see inside the highlighted area, we found the grub2 listing in this partition:

Troubleshoot Grand, Once we’re sure that GRUB is living in (hd0,msdos1). Let’s tell GRUB where to locate its configuration record and then educate it to try to launch its menu:

set prefix=(hd0,msdos1)/grub2
set root=(hd0,msdos1)
insmod normal
normal

Troubleshoot Grand, Then in the GRUB menu, pick an access and press Enter to boot the usage of it. Once the system has booted you may problem the grub2-install /dev/sdX command. (change sdX with the tool you need to install GRUB on). The boot information will then be up to date and all associated documents be restored.

# grub2-install /dev/sdX

Other more complex situations are documented, together with their counseled fixes, inside the Ubuntu GRUB2 Troubleshooting manual. The concepts explained there are legitimate for different distributions as properly.