Hmmm.. grub2 looks really strange to me ! .. In earlier versions of ‘grub’ it was really easy to manage. for example if you we want to edit a kernel parameter, get into /boot/grub/grub.conf and change the entry.. thats it.. but I failed to do that in my fedora 19 system with grub2.
This article may be a silly one for grub2 experts.. how-ever nothing stopping me to share it for newbies like me 🙂
Lets examine important locations of grub2.
Those are ‘/etc.grub.d/’ and ”/etc/default/grub’..
Lets see what are inside it:
[root@humbles-lap grub.d]# pwd
/etc/grub.d
[root@humbles-lap grub.d]#
[root@humbles-lap grub.d]# ls
00_header 10_linux 20_linux_xen 20_ppc_terminfo 30_os-prober 40_custom 41_custom README
So, grub2 have its scripts in more modular format as shown above.. Lets..
[root@humbles-lap grub.d]# cat README
All executable files in this directory are processed in shell expansion order.
00_*: Reserved for 00_header.
10_*: Native boot entries.
20_*: Third party apps (e.g. memtest86+).
The number namespace in-between is configurable by system installer and/or
administrator. For example, you can add an entry to boot another OS as
01_otheros, 11_otheros, etc, depending on the position you want it to occupy in
the menu; and then adjust the default setting via /etc/default/grub.
So, second location is ‘/etc/default/grub’ file.
Whats inside it ?
[root@humbles-lap grub.d]# cat /etc/default/grub
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=”rd.md=0 rd.dm=0 vconsole.font=latarcyrheb-sun16 vconsole.keymap=us $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || 🙂 rd.luks=0 rd.lvm.lv=fedora_humbles-lap/root rd.lvm.lv=fedora_humbles-lap/swap rhgb quiet”
GRUB_DISABLE_RECOVERY=”true”
I would like to add a kernel parameter to my kernel command line.. may be ‘edd=off’ :
For that, I edited it in GRUB_CMDLINE_LINUX value..
[root@humbles-lap grub.d]# cat /etc/default/grub
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=”rd.md=0 rd.dm=0 vconsole.font=latarcyrheb-sun16 vconsole.keymap=us $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || 🙂 rd.luks=0 rd.lvm.lv=fedora_humbles-lap/root rd.lvm.lv=fedora_humbles-lap/swap edd=off rhgb quiet”
GRUB_DISABLE_RECOVERY=”true”
[root@humbles-lap grub.d]#
Once you do that, you have to generate the new configuration by using grub2-mkconfig command..
[root@humbles-lap grub.d]# grub2-mkconfig
Generating grub.cfg …
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
load_env
fi
**************
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the ‘exec tail’ line above.
### END /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z “${config_directory}” -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
done
[root@humbles-lap grub.d]#
How-ever the above output have to be recorded inside ‘/boot/grub2/grub.cfg’.. for that you can use -o switch of grub2-mkconfig as shown below:
[root@humbles-lap grub.d]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg …
Found linux image: /boot/vmlinuz-3.9.9-301.fc19.x86_64
Found initrd image: /boot/initramfs-3.9.9-301.fc19.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-ac5b98a1b389435db9c1e2fe627c59ab
Found initrd image: /boot/initramfs-0-rescue-ac5b98a1b389435db9c1e2fe627c59ab.img
done
[root@humbles-lap grub.d]#
Lets cross verify whether it reflected in the configuration setting by:
[root@humbles-lap grub.d]# cat /boot/grub2/grub.cfg |grep -i edd
linux /vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/fedora_hp–dl120g6–2-root ro rd.md=0 rd.dm=0 vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rd.luks=0 rd.lvm.lv=fedora_humbles-lap/root rd.lvm.lv=fedora_humbles-lap/swap edd=off rhgb quiet
linux /vmlinuz-0-rescue-ac5b98a1b389435db9c1e2fe627c59ab root=/dev/mapper/fedora_hp–dl120g6–2-root ro rd.md=0 rd.dm=0 vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rd.luks=0 rd.lvm.lv=fedora_humbles-lap/root rd.lvm.lv=fedora_humbles-lap/swap edd=off rhgb quiet
[root@humbles-lap grub.d]#
Coooooooool, hope it helps..