Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q1 (a) Describe the role of the UNIX kernel in the system startup process. (b) H

ID: 3905793 • Letter: Q

Question

Q1

(a) Describe the role of the UNIX kernel in the system startup process.

(b) How does a UNIX machine know where to locate the kernel to boot?

(c) Can a UNIX machine be running multiple kernels at the same time? If so, how? If not, why not?

(d) Briefly describe the difference between a monolithic kernel and a modular kernel, and list two ad- vantages of modular kernels.

Q2.

(a) Give two different examples of situations when you might compile a program from source rather than installing it from an rpm package.

(b) Wbat is the relationship between yum and rpm?

(c) Wben you are running a program from the UNIX shell prompt, whatis the difference between pressing Ctrl-Z and pressing Ctrl-C while the program is executing?

Q3.

Consider the following disk partition layout that a systems administrator designed on paper for a system

with one 500GB SCSI hard disk:

Disk partition name /dev/sdal
/dev/sda2
/dev/sda3

/dev/sda4 /dev/sdaS /dev/sda6

Mount point Size

I 50GB

swap l100 GB

I

/var/spool/maill200 GB /var 1100GB!

/etc 5GB !boot !20GB

I

Assume that the goal is to achieve the most effective utilisation of space on the disk for a machine that is ptimarily functioning as a mail server.

(a) List five problems with the disk partition layout described above, with a brief description of what each problem is. In this context, wasting space is considered a problem, as well as more serious issues that would prevent the above layout from working at all or is against established partition layout design principles.

(b) Rewrite the table above in your answer booklet, and fix all of the problems.

Q4.

(a) What is an incremental backup?

(b) Regarding backups, consider the /var/spool/mail and /usr/local directories. How often would you perform a full backup of each directory? How often would you perform an increment- al backup of each directory? Justify your answers.

(c) What is the difference between cron and at? Describe a situation when you might use each one.

Explanation / Answer

(a) Describe the role of the UNIX kernel in the system startup process.

Answer:

The kernel in Linux handles all operating system processes, such as memory management, task scheduling, I/O, interprocess communication, and overall system control. This is loaded in two stages – in the first stage, the kernel (as a compressed image file) is loaded into memory and decompressed, and a few fundamental functions such as basic memory management are set up. Control is then switched one final time to the main kernel start process. Once the kernel is fully operational – and as part of its startup, upon being loaded and executing – the kernel looks for an init process to run, which (separately) sets up a user space and the processes needed for a user environment and ultimate login. The kernel itself is then allowed to go idle, subject to calls from other processes.

For some platforms (like ARM 64-bit), kernel decompression has to be performed by the boot loader instead.

Kernel loading stage

The kernel is typically loaded as an image file, compressed into either zImage or bzImage formats with zlib. A routine at the head of it does a minimal amount of hardware setup, decompresses the image fully into high memory, and takes note of any RAM disk if configured.[3] It then executes kernel startup via ./arch/i386/boot/head and the startup_32 () (for x86 based processors) process.

Kernel startup stage

The startup function for the kernel (also called the swapper or process 0) establishes memory management (paging tables and memory paging), detects the type of CPU and any additional functionality such as floating point capabilities, and then switches to non-architecture specific Linux kernel functionality via a call to start_kernel().

start_kernel executes a wide range of initialization functions. It sets up interrupt handling (IRQs), further configures memory, starts the Init process (the first user-space process), and then starts the idle task via cpu_idle(). Notably, the kernel startup process also mounts the initial RAM disk ("initrd") that was loaded previously as the temporary root file system during the boot phase. The initrd allows driver modules to be loaded directly from memory, without reliance upon other devices (e.g. a hard disk) and the drivers that are needed to access them (e.g. a SATA driver). This split of some drivers statically compiled into the kernel and other drivers loaded from initrd allows for a smaller kernel. The root file system is later switched via a call to pivot_root() which unmounts the temporary root file system and replaces it with the use of the real one, once the latter is accessible. The memory used by the temporary root file system is then reclaimed.

Thus, the kernel initializes devices, mounts the root filesystem specified by the boot loader as read only, and runs Init (/sbin/init) which is designated as the first process run by the system (PID = 1).A message is printed by the kernel upon mounting the file system, and by Init upon starting the Init process. It may also optionally run Initrd to allow setup and device related matters (RAM disk or similar) to be handled before the root file system is mounted.

According to Red Hat, the detailed kernel process at this stage is therefore summarized as follows:

"When the kernel is loaded, it immediately initializes and configures the computer's memory and configures the various hardware attached to the system, including all processors, I/O subsystems, and storage devices. It then looks for the compressed initrd image in a predetermined location in memory, decompresses it, mounts it, and loads all necessary drivers. Next, it initializes virtual devices related to the file system, such as LVM or software RAID before unmounting the initrd disk image and freeing up all the memory the disk image once occupied. The kernel then creates a root device, mounts the root partition read-only, and frees any unused memory. At this point, the kernel is loaded into memory and operational. However, since there are no user applications that allow meaningful input to the system, not much can be done with it." An initramfs-style boot is similar, but not identical to the described initrd boot.

At this point, with interrupts enabled, the scheduler can take control of the overall management of the system, to provide pre-emptive multi-tasking, and the init process is left to continue booting the user environment in user space.

(d) Briefly describe the difference between a monolithic kernel and a modular kernel, and list two ad- vantages of modular kernels.

Answer:

Modular kernels

A modular kernel allows an administrator to add functionality only when required. Keeping only what is necessary in kernel memory reduces the kernel's memory footprint[1] and increases its overall performance.
Each kernel module contains code to handle some necessary system functionality. Device drivers[2] , for example, are common modules: a device driver such as a network module provides the support for a particular brand of network card.
Modular kernels require a small amount of time to load modules. However, if the kernel was constantly loading and unloading modules, it would eventually spend more time processing load and unload requests than handling its other responsibilities.
To address this issue, the Linux kernel only loads modules when the system needs the functionality. Once loaded, a module remains in the kernel until explicitly removed. If another resource needs the module, the kernel can create anotherinstance to meet the demand. This scheme prevents the kernel from needing to rapidly load and unload modules.

Monolithic kernels

A monolithic kernel is the exact opposite of a modular kernel. All support for system functionality, such as device drivers, is built directly into the kernel.
Because the kernel supports all conceivable devices, especially those rarely used, kernel memory is wasted on unused support.
The image below illustrates the difference between modular and monolithic kernels

1) Modular kernels load modules dynamically

2) Monolithic kernels hold all code within the kernel