From the course: LPIC-1 Exam 101 (Version 5.0) Cert Prep

Create a custom GRUB menu - Linux Tutorial

From the course: LPIC-1 Exam 101 (Version 5.0) Cert Prep

Start my 1-month free trial

Create a custom GRUB menu

- [Instructor] If you want to add a custom menu item to the boot menu, you can. Custom boot menus are handy because they don't get modified during a kernel update, or after running the grub two dash MK config command. They are static boot menu entries that we have control over. We may create a custom boot menu entry for a kernel that we compiled ourselves manually, or one that has special debug parameters added to it. On Biospace systems, we'll append the contents of slash boot slash grub two slash grub dot CFG to the end of the slash ETC slash grub dot D slash 40 underscore custom file. In a terminal, type in sudo space cat space slash ETC slash grub dot D slash 40 underscore custom space slash boot slash grub two slash grub dot CFG space greater than space tilde slash 40 underscore custom. What this will do is concatenate the 40 underscore custom file and the grub dot CFG file into one file, which is exactly what the cat command is designed for. It then redirects this output to a file in our home directory called 40 underscore custom. Hit enter and type in your password. This file we can edit to our liking. Type in VI space tilde slash 40 underscore custom, and hit enter. The reason we combined both of these files is we need to keep the lines of the original 40 underscore custom template file at the top. Now we need to delete all of the lines we don't need. Find the line that says do not edit this file, and delete all lines after it until it says begin space slash ETC slash grub dot D slash 10 underscore linux. This is the beginning of our first menu entry. It ends with a right curly bracket. Let's also delete everything after the right curly bracket until the end of the file. What remains when we're done is one menu entry that we can edit. Let's change the menu entry name inside of the single quotes and add dash modified to it. Then, let's go down to the line that includes VN linuz and add a parameter. Find a space and add console equals TTY zero. This would be a useful parameter if we were running a KBM virtual machine instead of Virtual Box. You can add any parameter that you want here, or you can specify a different kernel altogether. Now, save this by pressing escape colon X exclamation mark, and hit enter. Let's copy this 40 underscore custom file over the original. Type in sudo space CP space tilde slash 40 underscore custom space slash ETC slash grub dot D slash 40 underscore custom, and hit enter. Now, we need to recreate the grub dot CFG file. For Biospace systems, type in sudo space grub two dash MK config space dash O space slash boot slash grub two slash grub dot CFG, and hit enter. On UEFI systems, we would specify the slash boot slash EFI slash capital EFI slash red hat slash grub dot CFG file instead. To see if our custom menu entry is part of the grub dot CFG file, let's use awk. Type in clear and then type in sudo space AWK space dash capital F backslash single quote, we're going to use a single quote as a field telemeter, space single quote forward slash menu entry forward slash, this is the lines we're going to search for, left curly bracket print space dollar sign two right curly bracket single quote space, and then the file we're going to look in is slash boot slash grub two slash grub dot CFG, and hit enter. Awk will show us the menu entry names of our installed kernels. We should now see our modified entry. If we rebooted, we'd be able to choose this entry.

Contents