Technology Encyclopedia Home >How to change the boot order of bootloader in Linux?

How to change the boot order of bootloader in Linux?

To change the boot order of the bootloader in Linux, you typically edit the configuration file associated with your bootloader. The most common bootloader on Linux systems is GRUB (GRand Unified Bootloader).

Steps to Change Boot Order in GRUB:

  1. Open the GRUB Configuration File:

    • On most Linux distributions, you can find the GRUB configuration file at /etc/default/grub.
  2. Edit the GRUB Configuration File:

    • Use a text editor like nano or vim to open the file. For example:
      sudo nano /etc/default/grub
      
    • Look for the line that starts with GRUB_DEFAULT. This setting determines which menu entry GRUB boots by default.
      • To set a specific menu entry by number, you can use:
        GRUB_DEFAULT=2
        
        This sets the third entry in the GRUB menu as the default (since numbering starts at 0).
      • To set a specific menu entry by name, you can use:
        GRUB_DEFAULT="Ubuntu, with Linux 5.4.0-72-generic"
        
  3. Update GRUB:

    • After making changes to the GRUB configuration file, you need to update GRUB to apply these changes. This is typically done with the following command:
      sudo update-grub
      
  4. Reboot the System:

    • Finally, reboot your system to see the changes take effect:
      sudo reboot
      

Example:

Suppose you have a dual-boot setup with Ubuntu and Windows, and you want to change the default boot operating system to Windows. Here’s how you might do it:

  1. Open the GRUB configuration file:

    sudo nano /etc/default/grub
    
  2. Change the GRUB_DEFAULT line to point to the Windows entry. You might need to check the GRUB menu during boot to find the exact name or number of the Windows entry. For example:

    GRUB_DEFAULT="Windows Boot Manager (on /dev/sda1)"
    
  3. Update GRUB:

    sudo update-grub
    
  4. Reboot the system:

    sudo reboot
    

Now, your system should boot into Windows by default.

Cloud-Related Recommendation:

If you are managing multiple Linux instances in a cloud environment, consider using services like Tencent Cloud's Cloud Virtual Machine (CVM) to simplify the management of your virtual machines, including bootloader configurations. Tencent Cloud provides robust tools for managing VMs, which can help streamline tasks like changing boot orders across multiple instances.