Booting and systems initialization

CIT 371 Lab 16:  Booting and systems initialization

Due date

 

This lab starts as soon as you start your VM so make sure you follow the instructions as soon as you can.

 

  1. As your VM starts, the initial boot screen shows the available kernels to select between. This is handled by the program GRUB2. You should see two kernels, one to launch to the normal kernel and one to launch to a rescue kernel. You can select between these using the arrow keys. If you do not select in a short time limit, the normal kernel is selected.
    1. At the bottom of the screen are instructions to edit the command to launch the kernel (e) and to enter command mode (c). Type c. You are given a grub command prompt. Type help which will display the available grub commands. You might notice that some Linux instructions appear as grub commands. For instance, you can use ls and cat. Type ls /. There are probably three subdirectories along with several files (whose names start with vmlinuz, System.map and initramfs). Which one is your Linux kernel (what is its name)?
    2. Type ls /grub2. Three items are files: device.map, grubenv and grub.cfg, the latter two are environment variables and configuration used by grub. Type cat /grub2/grubenv to view the environment variables and then cat /grub2/grub.cfg and step through the configuration file (note: tab completion works here). You will see one of the defined variables used by grub is $prefix. Exit out of cat (you have to step through the entire listing hitting any key to move forward). Once you regain the grub command prompt, type echo $prefix. What is defined? View grub.cfg again. Explain the first if-else statement in the file. Scroll down to approximately the third screen and you will an if-then-else statement that contains several insmod statements. These load modules. Which modules are loaded if the condition is true? If the condition is false? Scroll down to the end of grub.cfg and when you have prompt, type lsmod. This lists all of the loaded modules.
    3. Ultimately, there is not much we can or want to do from the grub command prompt other than inspect how the system boots. Type <ESC> to resume the boot process but now type e to edit the boot command. There will be approximately five commands listed. What module is loaded? This is followed by a linux command to load the kernel. What is the exact command shown? This is followed by a command called initrd, which loads an initial ramdisk. The ramdisk stores an initramfs, which acts as a file system (stored in memory) so that the kernel can start system initialization. What initramfs is loaded? Type <ESC> again to resume the boot process and boot as normal. Log in as yourself, open a terminal window and su to root.

 

  1. After the system boots, we can see view the boot operations by looking through the Linux kernel ring buffer, We do so with the command dmesg. We can also view booting and system administration steps by looking at /var/log/boot.log.
    1. Type dmesg | less. Read through the first screen. The first entry lists Linux version information and the second contains the Linux boot command. The next few mention what type of hardware device? These actions are followed by BIOS examining memory. The next several screens note detection of/availability of different hardware devices. Some mentioned are ACPI, NUMA, DMA and PCI. Look these up, what do each stand for? As booting continues, we reach the first systemd message. What mode does it run in? What parameters are supplied to the systemd command?
    2. After systemd starts running, the process shifts from booting Linux to initializing Linux. Some of these operations are shown via dmesg. The rest of the operations are shown in the boot.log file. If you are still viewing dmesg, type q to exit less. Type cd /var/log followed by ls –l boot*. You will find at least one boot.log file. View the most recent boot.log file that is not empty (its name may include a hyphen and a date). Use more to view the file rather than less. What is the first event logged? In this first screen, you will see that the boot process has found some devices. Which devices? Next, the boot process resumes from hibernation, starting which device? At the bottom of the first screen (and/or at the top of the second) you will see that a file system is mounted. Which one? This file system is placed into a ramdisk. What is a ramdisk? At this point, various targets are stopped in case they had been running and this boot was a soft boot (reboot) rather than a hard boot. On approximately the 4th screen’s worth of output, you will find Starting Switch Root… At this point, the file system changes from the initial file system loaded into a ramdisk to a file system stored on disk. Which is the first partition mounted? As initialization continues, initramfs is shut down, Step through the items started and list any whose names are already familiar to you. What are the last two items started?

 

  1. System initialization has already taken place by the time you log in, so what you saw in step 2 were actions to initialize the kernel for use. Handling the startup routines is the first process launched called systemd. systemd performs its initialization tasks through target files. Targets are one type of unit. Each unit comes with its own unit file, whose name is type where name is the name of the unit and type is its type (e.g., target, service, socket). Let’s step through this process.
    1. The first process launched by the Linux kernel is systemd. Confirm this by typing ps axo pid,cmd,ppid | less. This version of ps lists only the three items specified (the PID of the processes, the process’ command/name, and the process’ parent PID (PPID). What is the process with PID 1? What PPID does it have? What does this tell you about the process’ parent?
    2. Type cd /usr/lib/systemd/system. This directory (along with /usr/lib/systemd/users) contains most of the unit files. The first target run is called default.target. In the /usr/lib/systemd/system directory, type ls –l default.target. What type of file is this? What is the first target actually run? Use cat, more or less and examine that target file. Target files have a [Unit] section that contain directives that systemd examines and applies in launching that target. The directive Requires lists items that this target requires so that they are also launched. Wants specifically lists services that this target requires. Before and After indicate the order that these units start. These terms are somewhat counterintuitively used in that After lists those targets that must start before this target (that is, this target starts After those). Conflicts lists items that must stop before this one can run. From what you see here, what starts before this target, and which of those must stop before this one can run?
    3. The first target (the one indicated by default) requires on other target. Which one? Examine that target file. What target(s) does it require? Look at that target file. What target does it require? That target does not require another target, but it lists two wants and two conflicts. What targets does it want and what targets does it conflict with?
    4. Within the /usr/lib/systemd/system directory are subdirectories whose names are of the form name.target.wants where name is the name of a target. These directories contain symbolic links to the service files that they want. What entry do you find in graphical.target.wants? What entries do you find in multi-user.target.wants?
    5. You will find additional unit files (and wants subdirectories) in /usr/lib/systemd/user. Two other directories that contain unit files and wants directories are /etc/systemd/system and /etc/systemd/user. Type ls –l /etc/systemd/system. The unit files here are actually symbolic links. Where do they point?

 

  1. targets are one form of unit and are used to control the start-up of systemd. Other units control other aspects of the system including services, sockets, mounting of file systems and timers for scheduling. Each unit is implemented in a unit file and the unit files’ names end with .type sch as .target or .timer. Let’s look at some of these other types of unit files.
    1. Type cat atd.service. Service files have two additional sections, [Service] and [Install]. The ExecStart directive is the start-up command to launch the service. OPTS is an environment variable. In this case, OPTS is defined in the file listed under the EnvironmentFile directive. Look at that file to get the value of OPTS (assume it is not commented out). What is the full command, including the value in OPTS, to start atd? WantedBy is a directive that lists the units that want this particular unit. What wants atd.service? Now look at auditd.service (as this file is longer, use less instead of cat). What directives appear in this file that do not appear in atd.service? One, Type, lists forking. Read in chapter 9 (page 403) what forking means and explain it here. Type ls *.service | wc –l to get a count of all the service unit files. How many are listed?
    2. The mount units describe actions that need to take place to perform various mountings while automounts take place automatically. If there is an automount unit, there must be a corresponding mount unit, but not necessarily the other way. View the file proc-sys-fs-binfmt_misc.mount. Two directives are What and Where. What values are listed for these directives? Read what these two directives define (page 404). What do each of What and Where define? This particular mount unit has an automount unit of the same name. They share some of the same directives. Which directives appear in the .mount file that are not in the .automount file? Are there any directives in the .automount file that are not in the .mount file? If so, which ones?
    3. Timer units are used for scheduling actions. One such unit handles updating the dnf cache called dnf-makecache.timer. View this file. What target wants it? What target is this wanted by? Note that these are two separate directives. There is a comment in this file (under the [Unit] section). It refers to another unit file of the same name but a different type. What type? In fact every timer unit file has a corresponding file of this type. There are three directives in this timer file that proscribe when the timer acts. What are the three times? These are listed under a [Timer] section.
    4. We saw that every timer also has another unit type of the same name. This is also true of socket units. One directive often found in a socket unit file is the port that it listens to. What ports do each of cockpit.socket, rpcbind.socket, sshd.socket and libvirtd-tcp.socket? Another directive in a socket file is to indicate the permissions (mode) of the socket. What is the numeric value of the modes for each of dm-event.socket and syslog.socket?

 

  1. Changing the systemd process can be done in a couple of ways. The simplest change is to alter the default target. We can make substantial changes by modifying existing target files to change how they operate and/or to adding our own .target files. Examples are described in section 9.3.4. We will limit our changes to modifying default.target.
    1. Type systemctl get-default. This will display the target that is the first one selected. What do you see? This should match your answer to the first question 3b. We can use systemctl set-default filename.target to change the default target. Do so to change it to multi-user.target. Type ls –l default.target. You should notice that the symbolic link has not been changed. Let’s see which target is now the default. Type systemctl default. This will cause Linux to shut down and restart. Linux restarts in multi-user mode, but without the GUI (text-only). Log in as yourself and us to root. To revert back to the graphical interface, we will need to change the default back. Redo the set-default instruction changing it to graphical.target and then reissue the systemctl default Log in as yourself (do not su to root). Other commands available to change the machine’s state are emergency, rescue, halt and reboot. systemctl rescue does the same thing as telinit 1 which we used in lab 15. In fact, the telinit program is now a symbolic link to systemctl and 1 maps to rescue.
    2. We will explore systemctl in detail in the next lab. But for now, we will look at a couple of its other capabilities. We can use systemctl to list various units. Type systemctl list-units. This lists all available units. You will notice .target, .device, .service, .mount, .timer and others. At the bottom of the output will be a total of loaded units listed, how many? We use systemctl list-units –t type to see units of that type. Do this for target, device, service, mount, timer, automount, socket and slice. For each, how many were listed? Another thing we can do is determine unit dependencies. Type systemctl list-dependencies multi-user.target. This lists all dependencies of this target (including items that those items are dependent on). Add –after to the command to view those units that this target must launch after and –before to list all units this target must launch before. Notice to do the commands in this step you did not need to be root. How do these operations differ from the ones we looked at in step 5a?

 

Close your terminal window and shut down your VM.

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!