How to set the default boot order in CentOS 7?
To configure the default boot order of CentOS 7, you can follow these steps:
- Open the terminal and log into the system as root.
- Use the command ls /etc/grub.d/ to list all files in the directory /etc/grub.d/.
- Please confirm if the 40_custom file exists. If it does not, you can create it using the touch /etc/grub.d/40_custom command.
- Open the file /etc/grub.d/40_custom using a text editor such as vi or nano.
- Add the following content at the end of the document:
- menuItem ‘CentOS 7′ {
set root=’hd0,msdosX’ # Replace X with the disk partition number where your CentOS 7 is located
linux /vmlinuz-3.10.0-514.el7.x86_64 root=/dev/sdaX ro # Replace X with the disk partition number where your CentOS 7 is located
initrd /initramfs-3.10.0-514.el7.x86_64.img
} - Please make sure to replace the disk partition number and kernel/image version in the ‘set root’, ‘linux’, and ‘initrd’ lines with your own values. You can use the ‘ls /’ command to view available disk partitions and kernel/image version numbers.
- Save and close the file.
- Execute the following command in the terminal to update the GRUB bootloader:
- Generate a new configuration file for GRUB2 and save it to /boot/grub2/grub.cfg.
- Restart the system and confirm if CentOS 7 is booting in the default order as set.
Please note that this only applies to systems using the GRUB bootloader. If you are using another bootloader manager (such as LILO or Syslinux), you will need to modify the boot configuration file accordingly.