Laboratory 1 - Linux boot management

This is the first article presenting lab excercises for Boot management.

Laboratory 1 - Linux boot management

Lab 1 - Boot management

In this laboratory you will exercise working with GRUB, system shutdown and restart, /proc filesystem and Kernel runtime parameters.

Contents

  1. Lab 1.1 Booting the system
    • Lab objective 1: Shutdown, halt, reboot
    • Lab objective 2: Booting into non-graphical mode from GRUB
  2. Lab 1.2 Change Kernel runtime parameters
    • Lab objective 3: Working with the /proc filesystem
    • Lab objective 4: Change Linux Kernel runtime parameters

Laboratory objective 1: Shutdown vs. halt vs. reboot

Commands used: shutdown

Solution:

  1. Boot up the system. By default it will boot into Graphical mode. Open a terminal and reboot the system from the console using the command:
    sudo shutdown -r now
  2. After reboot, do the same as in previous exercise and now execute the command:
    sudo shutdown -h now

Laboratory objective 2: Booting into non-graphical mode from GRUB

Solution:

For the purpose of this exercise, I strongly recommend testing on a virtual machine, not on a live system. My solution is given on a openSUSE Leap system inside a virtual machine.

  1. boot the system and when GRUB is loading, hit the key "e" on your keyboard. This will get you into editing the GRUB file.

  2. find the line in the file that says: linux /boot/vmlinuz-4.4.76-1-default root=UUID=d8bba85c-d1ec-4b77-814a-7210fcd22113fd ${extra_cmdline} resume=/dev/sda1 splash=silent quiet showopts - NOTE: your line could be different depending on the system, but what is important is to find the exact line that consists of the string: "splah=silent quiet" or something like this.

  3. set your cursor on that line and insert a "3" after the string, so that it will look like this:
    splah=silent quiet showopts 3. The number 3 comes from init3, which represents the command mode specific runlevel.

  4. now press Ctrl-x or F10 to continue to boot your system. Now it will boot in console mode, not Graphical mode.

  5. to get back to your graphical mode, you should use one of the following commands, depending on your Graphical Environment.

In most cases the command that should work is:
startx, but depending on your system, you could try some of other commands from below.

In my case, on that virtual machine, openSUSE is running with XFCE, so I will have to do:
sudo systemctl start lightdm. Lightdm is the default display manager for XFCE.

If you have another graphical environment, you should use:

sudo systemctl start gdm - for standard GNOME

sudo systemctl start lightdm - for Ubuntu running Unity

sudo systemctl start mdm - for MATE and Cinnamon (in case of Mint)

sudo systemctl start kdm - for KDE

Laboratory objective 3: Working with the /proc filesystem

Commands used: sysctl, less, wc

Solution:

  1. explore the /proc filesystem - it represents the default method to handle processes and system information. /proc/sys is the place where you find information about your system devices, drivers and kernel features.

  2. to modify the kernel runtime parameters you will use the sysctl command. Use the -a option to see the complete list of Kernel parameters. Use it with a pipe to less, as the output is very large...sudo sysctl -a | less

  3. to view the number of parameters that can be modified can be viewed with the command:
    sudo sysctl -a | wc -l
    My output is:
    alexandru@linux-vje9:~> sudo sysctl -a | wc -l 1193

  4. analyze a specific line, for example:
    dev.cdrom.info = drive name: sr0
    this indicates that sr0 (srzero) is an alias for the optical drive and that the kernel knows the drive as sr0 and uses that name to refer to it.

Laboratory objective 4: Change and modify Linux Kernel runtime parameters

Commands used:cd, sysctl, echo

Solution:

The name of a parameter matches the directory structure inside /proc/sys.

  1. this is a test on some of the parameters, to see how the sysctl output relates to the /proc/sys/ directory
alexandru@linux-vje9:~> cd /proc/sys
alexandru@linux-vje9:/proc/sys> ls
abi debug dev fs kernel net vm
alexandru@linux-vje9:/proc/sys> sudo sysctl dev.cdrom.autoclose
[sudo] password for root:
dev.cdrom.autoclose = 1
alexandru@linux-vje9:/proc/sys> cat /proc/sys/dev/cdrom/autoclose
1
alexandru@linux-vje9:/proc/sys> sudo sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
alexandru@linux-vje9:/proc/sys> cat /proc/sys/net/ipv4/ip_forward
0
  1. modify the Linux Kernel parameters by using the sysctl command, with the -w option, the parameters name, the equal sign and the value to be changed. For example:
    sudo sysctl -w net.ipv4.ip_forward=1
  2. try the same with the echo command and redirection:
    echo 0 > /proc/sys/net/ipv4/ip_forward

Cover image credit: Photo by Csaba Balazs on Unsplash