On my workstation at home I have a dual boot with Red Hat Enterprise Linux 7.3 Workstation and Windows 10.  My system boots with UEFI which makes setting up dual boots such as this fairly easy.  I did want to make some changes to the default grub2 menu when my computer boots however.  First while I enjoy working with RHEL, my wife does not, so having the system boot into RHEL by default was causing some unneeded friction.  I also wanted to increase the default timeout, and remove RHGB quite from the boot menu as I like to see what is going on during the boot process.  So I set out to make the needed changes.  You’ll need to be root to perform all the following tasks.  First off, you don’t just edit the grub.cfg file directly, as this file is automatically generated, and if you issue the command cat /boot/efi/EFI/redhat/grub.cfg | less it will tell you as much at the start of the file:

# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub

Okay, easy enough.  So we use vim to edit /etc/default/grub

GRUB_DISTRIBUTOR=”$(sed ‘s, release .*$,,g’ /etc/system-release)”
GRUB_DEFAULT=”Windows Boot Manager (on /dev/sdc2)”
GRUB_CMDLINE_LINUX=”crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap”

The above file is after I had made all my changes.  I changed GRUB_TIMEOUT to equal 15, changed the GRUB_DEFAULT to read “Windows Boot Manager (on /dev/sdc2), and removed RHGB quite from after rd.lvm.lv=rhel/swap on the GRUB_CMDLINE_LINUX line.  For the exact wording of the default just look at the grub boot menu when your system is booting up and it write down which OS or option you wish.  By default it reads GRUB_DEFAULT=saved, and this would always give me the first option as my default.  I wanted the last option to always be my default, so I changed it to read my Windows Boot Manager instead.

Now while editing this file be VERY CAREFUL not to make any typos as it can cause your system to not boot properly.  I (which I’m still not sure how it happened) accidently ended up changing rd.lvm.lv-rhel/root to dd.lvm.lv-rhel/root.  Like I said, I’m not sure how it happened and I didn’t notice it and after I wrote the file and rebooted my system would no longer boot.  Instead I was greeted with hundreds of dracut-initqueue[345]: Warning: dracut-initqueue timeout – starting timeout scripts.  I was very confused at first why it would do this.  I tried a few other things like trying to boot to an older kernel, none of them worked.  I tried breaking into the boot and adding systemd.unit=rescue.target to the boot parameters, however seeing the issue was the root volume wasn’t being mounted none of these options would have ever worked.  I knew it had to be something I had just done, as the system worked just seconds ago, but for the life of me I couldn’t see why removing RHGB quite would have any negative effect.  It wasn’t until I was staring at the boot parameters I noticed the dd instead of the rd.  I was then able to edit the grub file again, and write my changes to grub.cfg.

So our final step in this process is how do you get your changes you made in /etc/default/grub to /boot/efi/EFI/redhat/grub.cfg.

[root@rhelws redhat]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Running the grub2-mkconfig file with -o (for output) and telling it where to create the file, which for a UEFI system would be something like /boot/efi/EFI/redhat/grub.cfg.  If you don’t see yours there one way I found to find it is to look in the /boot/grub2 folder and do a ll command:

[root@rhelws grub2]# ll
total 8
-rw-r–r–. 1 root root 4710 Apr 11 13:09 grub.conf
lrwxrwxrwx. 1 root root   28 Apr 11 15:11 grubenv -> /boot/efi/EFI/redhat/grubenv
drwxr-xr-x. 3 root root   19 May  9  2012 themes
[root@rhelws grub2]#

Notice the hard link with the file grubenv which is pointing to /boot/efi/EFI/redhat/grubenv.  This would be a good bet of where your grub.cfg file should go.  Once you are done you can do a cat grub.cfg | less to view the newly created file and verify all is right before issuing the reboot.  When you are happy, just issue the systemctl reboot command and you’ll see the results of your changes upon bootup.

I hope you have found this short tutorial (and tale of caution) informative and helpful.  If you have any questions, feel free to ask, and be sure and visit again soon for my posts on RHEL 7.x


Ivan Windon

Leave a Reply

Your email address will not be published. Required fields are marked *

twenty + 7 =