Tech Junkie Blog - Real World Tutorials, Happy Coding!: Linux System Administration GRUB2: Custom GRUB2 Entrie

Monday, February 21, 2022

Linux System Administration GRUB2: Custom GRUB2 Entrie

 GRUB2 is a wonderful tool, and one of the cool thing you can do is create a custom entry on the boot menu.  Let's say you built a system especially for HR and it's different than the rest of the organization's system.  Well with GRUB2 you can create an entry for the HR system as one of the choices in the boot menu.

Here are the steps to create a custom entry in GRUB2:

1. The first thing we want to do is create a custom file in our root home directory with the following contents.  Log in as root and make sure you are at the root home directory and type vi custom your linux16 entry might be different so make sure you have the right path in production.  In this post we are more concerned about making it show up in the boot menu

menuentry 'HR Department' {
    insmod gzio
    insmod part_msdos
    insmod xfs
    set root='hd0,msdos1'
    linux16 /vmlinuz-3.10.0-327.3.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap 
    initrd16 /initramfs-3.10.0-327.3.1.el7.x86_64.img
}







2. To make it show up in the boot menu we want to edit the 40_custom file in the /etc/grub.d/ directory.  So type vi /etc/grub.d/40_custom in the terminal.  Now you want to go to the end of the file and append the custom file to the end of it.  The way you can do that in vi is type esc then type :r /root/custom and press ENTER








The completed file should look something like this

#!/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 'HR Department' {
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        linux16 /vmlinuz-3.10.0-327.3.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap 
        initrd16 /initramfs-3.10.0-327.3.1.el7.x86_64.img
}

Type esc, :x to save the file

3.  Now regenerate the grub.cfg file with the following command grub2-mkconfig -o /boot/grub2/grub.cfg


Now if you reboot the machine you will see the custom entry in the boot menu




4 comments:

  1. Casino Tycoon – Slots & Table Games - Mapyro
    Welcome to Casino Tycoon, the ultimate casino game hub, where you 서귀포 출장안마 can have the best 서울특별 출장안마 of 순천 출장안마 all your favourite online slots 포천 출장샵 and table 창원 출장샵 games.

    ReplyDelete
  2. Hey. All the posts are very informative for the people who visit this site. Good work. We also have a Blog.
    Please feel free to visit our site. Best printer Blogs
    Or visit Posts page. . Best Inexpensive Printer for home
    Thank You.

    ReplyDelete
  3. This is very informative and interesting blog.
    https://www.infosectrain.com/courses/cissp-certification-training/

    ReplyDelete
  4. The synergy between sticker rolls and MUNBYN PDA products opens up new possibilities for businesses looking to enhance their operational efficiency. With the seamless compatibility, users can integrate these devices into their workflows effortlessly, utilizing sticker roll for labeling and organization with ease. The extended warranty not only speaks to the quality of MUNBYN products but also provides users with peace of mind, knowing that their investment is protected.

    ReplyDelete

Search This Blog