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

Practical Exercise 13a - GRUB: The Linux Boot Loader (Part I)

GENERAL CONDITIONS
1- Report Deadline:   29-3-19
9- 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_m01tu01pr13a or daw1_surname_name_m01tu01pr13a depending on what your group is. 
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. Screenshots sent with a wrong name will not be graded, in other words, their mark will be 0 points!!!!!!!!!!!!
 


MEETING
1.-  Date: Tuesday the 24th of March, 2020
2.- Time: From 5:00 p.m. to 7:30 p.m.
3.-  Place: Jesu´tes Educaciˇ NET --> VideoconferŔncies --> Join a meeting --> meeting name: asix1daw1m01tu1
4- Before attending the meeting you should read the DOCUMENTATION section  and the first external link  (the external links can be found after the DOCUMENTATION section)

DOCUMENTATION


1- Bootstrat or boot  process. MBR. Boot Loader. GRUB.
It is the process of loading an operating system into memory and starting it running without any outside help or assistance. If you are ruunig Linux, the following steps are taken in order to start the operating system:

1
st step) When  you turn on the computer, the CPU begins to carry out a set of instructions contained in the the BIOS. The first set of instructions is the POST (Power On Self  Test). The POST performs initial hardware checks such as determining if RAM memory,  mass storages devices or video card  are present in the system, the amount of RAM memory and so on. If an error is found, the  BIOS will warn us displaying a message on the screen or emitting a sequence of beeps, and the start up process will be stopped..

2nd step)
When the  POST process  finishes, instructions contained in  the BIOS make the  CPU load and start a very small program  called  Boot Loader, which is responsible for starting the process of loading and running the operating system.  The Boot Loader is part of the  Master Boot Record (MBR), which usually resides on the boot sector (also called zero sector) of a hard disk drive. Nowadays, the typical Linux Boot Loader is GRUB.

3rd step)
  The Boot Loader in MBR contains a small  part (called phase 1) of GRUB (Grand Unified Boot Loader).  Phase 1 loads  phase 2, which is the bulk of the Boot Loader and it is stored in the Linux partition  where resides  the /boot/grub directory.

4th step)
GRUB is a boot manager as well and therefore it will present a menu of posible boot options, which allows us to load differents kinds of operating system kernels (Windows, Linux, minix, BSD and so on) or different versions of  Linux kernels stored in the /boot directory of a disk partition. One you have selected an operating system from the menu, GRUB will be responsible for  locating the operating system kernel, loading it into memory and transferring control to the selected operating system kernel. The kernel, in turn, initializes the rest of the operating system (services, some drivers, etc...).  

2- 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.

2.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.

2.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

2.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.

2.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.

3- 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 - I (WORKING WITH A CLONE OF YOUR debian10v1 VIRTUAL MACHINE)

BEFORE STARTING
1.- Clone debian10v1 with the follwing options:
    *
Name:  debian10v1_clone_xxyyzz where xx=two first letters of your name, yy=two first letters of your first surname and zz=two first letters of your second surname
    * MAC Address Policy:  Generate new MAC addresses for all network adapters
    * Full clone

2.- Boot
debian10v1_clone

FIRST PART

1.- Take a screenshot  of the boot menu initial conditions. 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
. Capture name: asix1/daw1_surname_name_m01tu1ex13a_part1_cap1.jpg. 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!!!!!!!!!!!!
2.- Disable submenus
3
.- Configure GRUB for waiting 15 seconds before booting the operating system by default if no key is pressed.
4.- Disable the graphical menu for GRUB.
5.- Update GRUB.
6.- Boot your computer. Take a screenshot of the new menu. 
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 . Capture name: asix1/daw1_surname_name_m01tu1ex13a_part1_cap2.jpg. 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!!!!!!!!!!!!

SECOND PART
1.- Make the  Debian GNU/Linux, with 4.19.0-6-amd64 (recovery mode) your default menu entry.
2.- Update GRUB.
3.- If your new configuration works then call us to correct your exercise.
6.- Boot your computer. Take a screenshot of the new menu. 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. Capture name: asix1/daw1_surname_name_m01tu1ex13a_part2_cap1.jpg. 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!!!!!!!!!!!!

THIRD PART
1.- Make the  Debian GNU/Linux, with 4.19.0-6-amd64 your default menu entry.
2.- Remove the Debian GNU/Linux, with 4.19.0-6-amd64 (recovery mode) entry.
3.- Update GRUB.
4.- If your new configuration works then call us to correct your exercise.
5.- Boot your computer. Take a screenshot of the new menu. 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 .Capture name: asix1/daw1_surname_name_m01tu1ex13a_part3_cap1.jpg. 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!!!!!!!!!!!!

FOURTH PART
1.- Return your bootloader (GRUB) to its initial conditions (that are conditions previous the start of this exercise).
2.- If your new configuration works then call us to correct your exercise.
3.- Disable the GRUB background theme.

4.- Boot your computer. Take a screenshot of the new menu. 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 . Capture name: asix1/daw1_surname_name_m01tu1ex13a_part4_cap1.jpg. 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!!!!!!!!!!!!


IMPORTANT WARNINGS (YES...AGAIN!!!!!!!!!!)

1- Your screenshots have to show clearly the virtual machine name. WARNING: Screenshots where the virtual machine name is not shown will not be graded, in other words, their marks will be 0 points!!!!!!!!!

2- 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. Screenshots sent with a wrong name will not be graded, in other words, their mark will be 0 points!!!!!!!!!!!!