Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

GRUB Configuration File For Linux Multi-system Coexistence

The GRUB (GRand Unified Bootloader) is a bootloader used in Linux systems to manage the boot process and allow users to select which operating system to launch. When you have multiple operating systems installed on your computer, GRUB can help you manage and coexist with them.

The main GRUB configuration file is /boot/grub/grub.cfg or /boot/grub2/grub.cfg, depending on your Linux distribution. However, it is not recommended to edit this file directly, as it is automatically generated by the grub-mkconfig tool. Instead, you should modify the /etc/default/grub file, which is used as a source for generating the main configuration file.

Here are some basic steps to configure GRUB for a multi-system coexistence:

  • Open the /etc/default/grub file in a text editor with root privileges:

For Ubuntu, Debian, and related distributions:

sudo nano /etc/default/grub

For CentOS, RHEL, and related distributions:

sudo vi /etc/default/grub
  • Modify the GRUB configuration options as needed:
  • Change the default OS to boot:

    Look for the line GRUB_DEFAULT=0. The number represents the OS index in the GRUB menu, starting from 0. Change it to the index of the OS you want to set as default.

  • Set the GRUB menu timeout:

    Look for the line GRUB_TIMEOUT=10. The number represents the number of seconds the GRUB menu will be displayed before automatically booting the default OS. Modify the value as desired.

  • Add additional kernel options:

    If needed, you can add kernel options to the GRUB_CMDLINE_LINUX or GRUB_CMDLINE_LINUX_DEFAULT variables.

  • Save and close the file.

  • Update the main GRUB configuration file by running:

For Ubuntu, Debian, and related distributions:

sudo update-grub

For CentOS, RHEL, and related distributions:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  • Reboot your system to see the changes in the GRUB menu.

In summary, you can configure GRUB to manage multiple operating systems by modifying the /etc/default/grub file and updating the main GRUB configuration file. This enables you to set the default OS, adjust the menu timeout, and add kernel options to ensure a smooth multi-system coexistence.