Saturday 11 April 2020

Make a custom GRUB entry in Linux

How to make a custom GRUB entry

Copy menuentry for CentOS Linux 3.10.0-957.el7.x86_64 to 40_custom edit as,
$ vi /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# 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.
menuentry 'Custom Linux Boot Entry' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-4f940ed7-acd6-4631-bf35-ee2f43b49c9f' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  5971f3cb-eb26-4c88-af0a-b6c96e12965c
        else
          search --no-floppy --fs-uuid --set=root 5971f3cb-eb26-4c88-af0a-b6c96e12965c
        fi
        linux16 /vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet initcall_debug
        initrd16 /initramfs-3.10.0-957.el7.x86_64.img
}

                                                OR

menuentry 'Custom Linux Boot' {
        linux16 /vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet initcall_debug
        initrd16 /initramfs-3.10.0-957.el7.x86_64.img
}

$ grub2-mkconfig -o /etc/grub2.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-e45307abc30a407dbbd42a0632810083
Found initrd image: /boot/initramfs-0-rescue-e45307abc30a407dbbd42a0632810083.img
done

$ dmesg | grep initcall #check the current kernel have any init call
If no output then reboot and check.

$ dmesg | grep initcall | head
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet initcall_debug
[    0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-957.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet initcall_debug
[    0.131139] initcall init_hw_perf_events+0x0/0x5f1 returned 0 after 0 usecs
[    0.131167] initcall set_real_mode_permissions+0x0/0x102 returned 0 after 0 usecs
[    0.131173] initcall trace_init_flags_sys_exit+0x0/0xf returned 0 after 0 usecs
[    0.131178] initcall trace_init_flags_sys_enter+0x0/0xf returned 0 after 0 usecs
[    0.131184] initcall register_trigger_all_cpu_backtrace+0x0/0x16 returned 0 after 0 usecs
[    0.131190] initcall kvm_spinlock_init_jump+0x0/0x28 returned 0 after 0 usecs
[    0.131197] initcall early_efi_map_fb+0x0/0x32 returned 0 after 0 usecs
[    0.131228] initcall spawn_ksoftirqd+0x0/0x26 returned 0 after 0 usecs

No comments:

Post a Comment