M01: Introduction to Operating Systems
TU1: Installing, configuring and exploiting a computer system
ASIX1
Practical Exercise 13b - GRUB: The Linux Boot Loader (Part II)  30-03-20

Practical Exercise 13b - GRUB: The Linux Boot Loader (Part II)

GENERAL CONDITIONS
1- Report Deadline:   5-4-20

2-
Send your screenshots attached to an e-mail with the following specifications:
     a)
E-mail address: cf(at)collados.org or jordi.binefa(at)fje.edu depending on who your teacher is.
     b
)
Subject:  asix1_surname_name_m01tu01pr13b or daw1_surname_name_m01tu01pr13b depending on what your group is.

3-
Please note that "surname" means your real surname. Do not write "surname". Write your real surname . Additionally, "name" means your real name. Do not write "name". Write your real name.  Please note that you have to write asix1 if you are an asix1 student but you have to write daw1 if you are a daw1 student. WARNING: Mails sent with a wrong name will not be graded, in other words, their mark will be 0 points!!!!!!!!!!!!

 

DOCUMENTATION

1- Configuring the GRUB menu.
You can change  any aspect of the GRUB menu by:
    1st step) Editing the /etc/default/grub configurations file.
    2nd step) Renaming and changing permissions of special scripts located in
/etc/grub.d.
   
3rd step) Running update-grub. When update-grub is executed, the results are saved in  a file called /boot/grub/grub.cfg, which is the is the main GRUB file and  contains the menu information.. The  /boot/grub/grub.cfg should not be     edited manually and any change in this file should be made by update-grub, which for his part, combines the settings from the /etc/default/grub file and the scripts from /etc/grub.d, creating a /boot/grub/grub.cfg file that is read at boot.

1.1- /etc/default/grub
Changing the values of variables in the /etc/default/grub file allows you to modify many aspects of how the system boots and how GRUB displays its menu. Some of the most important variables are the following:
a) GRUB_DEFAULT: It specifies the ordinal  number of the default menu entry. Menu entries are numbered starting with 0 (0 specifies the first menu entry).
b) GRUB_TIMEOUT: It specifies the number of seconds GRUB waits before booting the operating system by default.
c) GRUB_DISABLE_RECOVERY: It specifies whether or not update-grub   generates recovery-mode menu entries. Commented out  by default. Default value is false, which means that entries are generated.
d) GRUB_TERMINAL: It enables (#GRUB_TERMINAL=console) or disables (
GRUB_TERMINAL=console)  the graphical menu.
e) GRUB_DISABLE_SUBMENU: It disables ("y") or enables (with #) submenus.

IMPORTANT ---> GRUB
does not evaluate a line that begin with a hasmark (#). These lines are comments.

1.2- /etc/grub.d
The files in this folder are read during execution of  the update-grub utility. The contents are imported into /boot/grub/grub.cfg. The order of the entries in the GRUB menu is based on the order of the file names. The order the files are run determines the menu order in grub.cfg. Some of the most important files are the following:
a) 00_header: It is the script that loads GRUB settings from /etc/default/grub, including timeout, default boot entry, and others.
b) 05_debian_theme: Sets the background and text colors themes.
c) 10_linux: It  loads the menu entries for the installed distribution. Creates a menu entry for each kernel in /boot. A kernel is specified by a file named vmlinuz-*.
d) 20_memtest86+: If the file /boot/memtest86+.bin (memory test utility) exists, it is included as a menu item.
e) 20_linux_xen: It loads xen linux kernels which are a special kind of virtual kernels.
f) 30_os-prober: It  is the script that will scan the hard disks for other operating systems (Windows, Linux on other partitions,....) and add them to the boot menu.
g) 40_custom: A template for adding custom menu entries.

IMPORTANT NOTES:
a) Each of these files must be executable if you want update-grub to process it. If you do not want update-grub to process one of the files, remove the execute bits from the file.
b) All executable files are processed in order according to their number namespace

1.3- update-grub

A utility for updating /boot/grub/grub.cfg according to the contents of the /etc/default/grub file and files in the /etc/grub.d directory.

1.4.- /boot/grub/grub.cfg
The main GRUB file, which contains the GRUB menu information. This file is automatically changed or generated when update-grub is run.You should not edit this file.

2- External Links
(1) http://www.howtogeek.com/196655/how-to-configure-the-grub2-boot-loaders-settings/

(2) http://www.howtogeek.com/howto/17787/clean-up-the-new-ubuntu-grub2-boot-menu/
(3) http://ubuntuforums.org/showthread.phpF?t=1195275
(4)
https://jamielinux.com/articles/2013/01/hide-grub-menu-fedora/



PRACTICAL EXERCISE

a) Your screenshot has to show clearly the virtual machine name. WARNING: Screenshots where the virtual machine name is not shown will not be graded, in other words, its mark will be 0 points

b) Please note that "surname" means your real surname. Do not write "surname". Write your real surname . Additionally, "name" means your real name. Do not write "name". Write your real name.  Please note that you have to write asix1 if you are an asix1 student but you have to write daw1 if you are a daw1 student. WARNING: Screenshots sent with a wrong name will not be graded, in other words, its mark will be 0 points!!!!!!!!!!!!

FIRST PART
1.-
Take note of the boot menu initial conditions.

2.-
Disable submenus.
3
.- Configure GRUB for waiting 20 seconds before booting the operating system by default if no key is pressed.

4- Install the memtest86+ menu option.  Run the command: sudo aptitude install memtest86+
5.- Reboot your computer. Take a screenshot of the new menu. Capture name: asix1/daw1_surname_name_m01tu1ex13b_part1_cap1.jpg.
6- Select  the Memory test (memtest86+)  menu option.  In the Memtest86+ windows, press F1.  Test your system memory  for a few seconds. Capture name: asix1/daw1_surname_name_m01tu1ex13b_part1_cap2.jpg.

SECOND PART
1.-  Create a backup of 20_memtest86+. Copy 20_memtest86+ to your default user's personal folder.
2.- Edit with
20_memtest86+. Run geany 20_memtest86+ and remove lines 42 to 59. You are removing the following menu entries:
    * Memory test (memtest86+, experimental multiboot)
    *
Memory test (memtest86+, serial console 115200, experimental multiboot)
Save 
20_memtest86+.
3.- 
Make  Memory test (memstat86+) your first menu entry.  Rename 20_memtest86+  to xx_memtest86+ where xx must be a number between 05 (because 05_debian_theme starts with 05) and 10 (because 10_linux starts with 10). For instance xx could be equal to 07.
4.-
Update GRUB
5.- Reboot your computer. Take a screenshot of the new menu. Capture name: asix1/daw1_surname_name_m01tu1ex13b_part2_cap1.jpg.

THIRD PART
1.- Modify the the first Memory test menu entry. Change i line 27 "Memory test (memtest86+)   to "Memory test".
2.- R
emove lines 33 to 38. You are removing the "Memory test (memtest86+, serial console 115200)" menu entries
3.- Update GRUB
4.- Reboot your computer. Take a screenshot of the new menu. Capture name: asix1/daw1_surname_name_m01tu1ex13b_part3_cap1.jpg.

FOURTH PART
1.- Read (4) of External Links (Documentation).
2
.-
 Make the  Debian GNU/Linux, with 4.19.0-6-amd64 the default menu entry.
3
.-
Hide Grub menu.

4.- At system boot, give yourself 2 seconds to access the hidden menu pressing <Esc>.
5.- Take a screenshot of lines 1 to 12 of /etc/default/grub. Capture name: asix1/daw1_surname_name_m01tu1ex13b_part4_cap1.jpg.
6.-
Update GRUB
7.- Reboot your computer. Take a screenshot of the new menu. Capture name: asix1/daw1_surname_name_m01tu1ex13b_part4_cap2.jpg.

FIFTH PART
1.- Unhide Grub menu.
2.-
Configure GRUB for waiting 15 seconds before booting the operating system by default if no key is pressed.
3.- Remove memtest86+ package. Run:
    sudo aptitude remove memtest86+
    sudo aptitude purge memtest86+
    sudo rm /etc/grub.d/07_memtest86+
4.-
Make the  Debian GNU/Linux, with 4.19.0-6-amd64 the default menu entry.
5.- Update GRUB
6
.-
Reboot your computer. 
Take a screenshot of the new menu. Capture name: asix1/daw1_surname_name_m01tu1ex13b_part5_cap1.jpg.