Week Broader Topic Topics Tools To Be Covered
Week Broader Topic Topics Tools To Be Covered
Topics To be Covered
1. Power-on self-test (POST): When you turn on your computer, the basic input/output
system (BIOS) or the firmware in newer systems performs a POST. This is a series of
diagnostic tests to check the hardware components (such as memory, processor, and
storage devices) and ensure they are functioning correctly.
Linux System Administration Week
2
2. Initial startup program: After the POST, the BIOS or firmware locates the initial
startup program. In traditional BIOS systems, this program is stored in the firmware
itself, while in modern UEFI systems, it is usually located in a separate partition on the
storage device.
3. Boot loader: The initial startup program then loads the boot loader. The boot loader
is responsible for locating the operating system's kernel and initializing the boot
process. Examples of popular boot loaders include GRUB (used in many Linux
distributions) and Windows Boot Manager. Grub configuration file is
/boot/grub/grub.conf The following is a sample grub.conf of CentOS.
▪ #boot=/dev/sda
Linux System Administration Week
2
▪ default=0
▪ timeout=5
▪ splashimage=(hd0,0)/boot/grub/splash.xpm.gz
▪ hiddenmenu
▪ root (hd0,0)
▪ initrd /boot/initrd-2.6.18-194.el5PAE.img
4. Operating system kernel: Once the boot loader is loaded into memory, it transfers
control to the operating system's kernel. The kernel is the core component of the
operating system that manages system resources, and device drivers, and provides
various services.
5. Initialization and device detection: The operating system kernel initializes the
essential system components and starts detecting and configuring hardware devices
such as the CPU, memory, storage devices, input/output devices, and network
interfaces.
▪ Looks at the /etc/inittab file to decide the Linux run level.
6. User space initialization: After the kernel initializes the hardware, it starts launching
user-space processes and services. These processes and services are responsible for
providing the user interface and running applications. In Unix-like systems, the init
process is typically the first user space process and serves as the ancestor of all other
processes.
7. Graphical user interface (optional): If your operating system includes a graphical user
interface (GUI), such as Windows or macOS, the boot process continues to initialize
the graphical system components, including the window manager and desktop
environment, providing a visual interface for the user.
Linux System Administration Week
2
8. Login or desktop: Finally, the boot process reaches a stage where the user can log in
or directly access the desktop environment. The operating system has finished
loading, and you can start using the computer and running applications.
It's important to note that the boot process can vary between different operating systems
and configurations. The steps described here provide a general overview, but specific details
mays differ based on the system's firmware, boot loader, and the operating system being
use.
2. Partitioning
Partitioning is the process of dividing a storage device, such as a hard drive or solid-state
drive (SSD), into multiple sections or partitions. Each partition acts as a separate logical unit
with its own file system, allowing you to organize and manage data more efficiently. Here
are some key points about partitioning:
1. Primary and Extended Partitions: On a disk, you can have primary and extended
partitions. A primary partition is a standalone partition that can be used to install an
Linux System Administration Week
2
operating system or store data. An extended partition, on the other hand, serves as a
container for logical partitions.
2. Logical partitions: Logical partitions are created within the extended partition. They
are used to further divide the available space and provide additional storage areas.
Logical partitions cannot be used to install an operating system directly but can be
used for data storage.
3. File systems: Each partition typically has a file system associated with it, such as ext4,
NTFS, or FAT32. The file system determines how data is stored, accessed, and
organized on the partition.
4. System partition: The system partition, often referred to as the root partition
(denoted as '/'), is where the operating system is installed. It contains essential system
files, directories, and configuration files.
5. Data partitions: Data partitions are used to store files, documents, media, and other
user data. By separating the operating system and user data into different partitions,
you can isolate the data from potential system issues and make it easier to back up or
reinstall the operating system.
6. Partitioning tools: There are various partitioning tools available for Linux, such as
fdisk, parted, and GParted. These tools allow you to create, delete, resize, and modify
partitions on your storage devices.
When partitioning a disk, it is important to plan the partition sizes and layout according to
your specific needs. Consider factors such as the operating system requirements, the
amount of data you expect to store, and any future expansion requirements. Properly
partitioning your storage device can help improve your system's performance, organization,
and data management.
Note: Creating a partition involves modifying the disk's partition table, which can result in
data loss if not done carefully. Make sure to back up your important data before
proceeding.
1. Open a terminal: Open a terminal window on your Linux system. You can usually find
the terminal application in the applications menu or by using the keyboard shortcut
(e.g., Ctrl+Alt+T).
2. Identify the disk: Run the following command to list the available disks on your
system:
sudo fdisk -l
Identify the disk on which you want to create a partition (e.g., /dev/sdb).
3. Run fdisk: Execute the following command, replacing /dev/sdX with the disk
identifier from the previous step:
4. Create a new partition: Within the fdisk prompt, use the following steps to create a new
partition:
a. Type n and press Enter to create a new partition.
b. Choose the partition type:
Linux System Administration Week
2
c. Specify the partition number. If it's the first partition, you can choose 1. For
subsequent partitions, choose an appropriate number.
d. Set the starting and ending sectors for the partition. You can either specify the
exact size in sectors or use default values for the entire disk space.
2. Set the partition type: After creating the partition, you need to set the partition type.
Type t and press Enter.
a. Select the partition number you just created.
b. Choose the partition type code. For Linux filesystems, you can use 83 (Linux) or 82
(Linux swap). You can view the list of available partition types by typing L.
3. Save and exit: Once you have created the partition and set the partition type, type w
and press Enter to save the changes and exit fdisk.
4. Format the partition: After creating the partition, you'll need to format it with a file
system. For example, to format the partition as ext4, you can use the following
command:
sudo mkfs.ext4 /dev/sda1
Linux System Administration Week
2
Congratulations! You have successfully created a partition in Linux using fdisk. You can now
mount the partition and start using it to store files and data.
3. Virtual Memory
1. Address space: Each program running on a system has its own virtual address space.
This address space is divided into fixed-size chunks called pages.
2. Paging: The virtual memory system breaks down the program's memory into fixed-
size pages, typically 4 KB in size. Similarly, the physical memory (RAM) is also divided
into pages of the same size.
Linux System Administration Week
2
3. Page tables: The operating system maintains a page table that maps the virtual pages
of a program to the corresponding physical pages in RAM. This mapping allows the
program to access its memory as if it were using physical memory directly.
4. Page swapping: When a program requests a memory page that is not currently
present in physical memory, a page fault occurs. The operating system then selects a
page from RAM to evict (if necessary) and writes it back to the disk. The required page
is then fetched from disk and loaded into the newly freed page in RAM.
5. Demand paging: Virtual memory systems typically use a technique called demand
paging. It means that pages are loaded into physical memory only when they are
actually accessed by the program. This approach helps conserve physical memory
resources by loading only the necessary pages on-demand.
6. Page replacement algorithms: When physical memory becomes full and a new page
needs to be brought in, the operating system uses page replacement algorithms (such
as LRU, FIFO, or clock algorithms) to select the page to be evicted from RAM. The goal
is to minimize the number of page faults and maximize the efficiency of memory
usage.
• It simplifies memory management for programmers, as they can allocate and use
memory without worrying about physical memory constraints.
However, the use of virtual memory can introduce performance overhead due to the need
for disk I/O when swapping pages. Therefore, optimizing memory usage and minimizing
page faults is essential for maintaining good system performance.
• To modify the swappiness value temporarily (e.g., set it to 10): `sudo sysctl
vm.swappiness=10`
• To make the swappiness value persistent across reboots, edit the
`/etc/sysctl.conf` file and add or modify the line: `vm.swappiness = 10`
• Linux uses a page cache to speed up file I/O operations. The page cache holds
recently accessed files and their corresponding disk pages in memory.
• The `drop_caches` interface allows you to manually free up the page cache.
However, it's generally recommended to avoid doing this unless necessary, as
the kernel is designed to manage the page cache efficiently.
• Linux provides various tools to monitor memory usage and virtual memory
statistics.
Linux System Administration Week
2
• The free command displays information about total, used, and available
memory, as well as swap usage.
It's essential to carefully manage virtual memory on Linux to maintain system performance
and prevent excessive swapping. However, it's generally recommended to rely on the
default settings and let the kernel handle memory management, as it is designed to
optimize performance automatically. Only make specific adjustments if you encounter
specific memory-related issues or have specific workload requirements.
In the context of computer systems, "mounting" refers to the process of associating a file
system or storage device with a directory in the file hierarchy. When a file system or storage
device is mounted, it becomes accessible to the operating system and applications, allowing
them to read from and write to the files stored within it.
The concept of mounting is often used in operating systems like Linux and Unix. When a
storage device such as a hard drive, solid-state drive, or network share is mounted, the
operating system makes it available for use by assigning it a mount point, which is a
directory in the file system. The mount point acts as a reference or entry point for accessing
the files and directories stored on the mounted device.
For example, if you have a separate hard drive with files that you want to access, you can
mount the hard drive to a specific directory in your file system, such as "/mnt/mydrive".
Once mounted, the contents of the hard drive will be accessible through the
"/mnt/mydrive" directory, and you can read from or write to the files as if they were part of
the local file system.
In addition to physical storage devices, mounting can also be used for virtual file systems,
network shares, or other types of storage resources. The process of mounting typically
requires administrative privileges or root access, depending on the operating system and
the specific configuration.
The term "mount" can refer to different things depending on the context. It can be used as a
verb, describing the action of associating a file system or storage device with a directory (as
explained above). It can also be used as a noun, representing the mounted file system or
device itself. For example, you might say, "I mounted the USB drive to the /media/usb
directory," where "mounted" is a verb, and "USB drive" is the mount, representing the
mounted device.
In Linux, the process of storing files in memory involves several layers, including the file
system, buffer cache, and virtual memory subsystem. Here's an overview of how files are
typically stored in memory in Linux:
Linux System Administration Week
2
• File System: Linux uses various file systems like ext4, XFS, and others to manage
storage devices and organize files. When a file is created or accessed, the file system
keeps track of its metadata (such as file name, size, and permissions) and the location
of its data blocks on the storage device.
• Buffer Cache: The buffer cache is a portion of the system's memory reserved for
caching frequently accessed data from storage devices. When a file is read or written,
the file system driver fetches the corresponding data blocks from the storage device
and stores them in the buffer cache. Subsequent accesses to the same file can be
served directly from the cache, improving performance.
• Page Cache: The page cache is a component of the virtual memory subsystem in
Linux. It caches file data from the buffer cache and holds it in memory pages. Each
page in the page cache represents a fixed-size chunk of data from a file. The page
cache provides a unified view of data from various files and allows efficient access and
management of file data in memory.
• Caching and Swapping: The page cache in Linux not only caches file data but also
acts as a general-purpose cache for various data, including executable code, shared
libraries, and other system data. The operating system dynamically manages the
contents of the page cache based on the available memory and the demands of
running processes. In situations of memory pressure, less frequently accessed pages
can be evicted from memory and swapped out to disk.
It's worth noting that the specific mechanisms and optimizations related to file caching and
memory management can vary based on the Linux distribution, kernel version, file system
Linux System Administration Week
2
type, and system configuration. Linux provides a flexible and extensible architecture that
allows administrators and developers to tune and customize these aspects to meet specific
performance or resource requirements.
6. Dual Boot
Dual boot refers to the process of setting up a computer to run two different operating
systems on the same machine. With dual boot, you can choose which operating system to
boot into when you start your computer. This allows you to have the flexibility of using
multiple operating systems on a single device. Here's a step-by-step guide on setting up dual
boot with Linux and Windows:
Note: Before proceeding, it's crucial to back up your data to prevent any potential data loss
during the installation process.
a. Make sure your computer meets the system requirements for both Linux and
Windows.
2. Install Windows:
a. If you don't have Windows installed, install it first. Follow the instructions provided
by Microsoft for the installation process.
b. Shrink the Windows partition to create free space for the Linux installation.
Right-click on the Windows partition, select "Shrink Volume,"
and choose the size for the new partition.
Linux System Administration Week
2
c. Leave the free space unallocated for now. It will be used for Linux installation.
2. Install Linux:
a. Download the Linux distribution of your choice and create a bootable USB
drive using tools like Rufus or BalenaEtcher.
b. Restart your computer and boot from the Linux USB drive. This usually involves
pressing a specific key (e.g., F12, Esc, or Del) during startup to access the boot menu and
selecting the USB drive as the boot option.
c. Follow the installation wizard for your chosen Linux distribution. When prompted
for the installation type, select the "Something Else" or "Manual" option to
manually partition the disk.
a. After the Linux installation is complete, restart your computer. You may find that it
automatically boots into Linux.
b. To boot into Windows, you need to configure the bootloader. In Linux, open a terminal
and run the following command to update the bootloader:
sudo update-grub
c. The bootloader should detect and add the Windows installation to the boot menu.
a. Restart your computer again. You should now see a boot menu during startup that
allows you to choose between Linux and Windows.
Linux System Administration Week
2
b. Use the arrow keys to select the desired operating system, and press Enter to boot into
it.
Congratulations! You have successfully set up dual boot on your computer with Linux and
Windows. Now you can choose the operating system you want to use each time you start
your computer.
Swap space is an integral part of Linux systems and plays a crucial role in managing memory
resources. It provides a way to extend the available memory beyond physical RAM by
utilizing disk space as virtual memory. Here's an introduction to swap space on Linux
systems:
Linux System Administration Week
2
In Linux, swap space can be implemented using different types. The two main types
of Linux swap are:
• Both swap partitions and swap files serve the same purpose, but the flexibility
of using swap files makes them more commonly used.
• To create a swap partition, you need to repartition your disk and allocate a
portion of it specifically for swap.
• To create a swap file, you can use the dd command to create a file of the
desired size and then format it as swap using the mkswap command.
• To activate a swap partition or file, you can use the swapon command
followed by the path to the swap device or file.
• The swapon command makes the swap space immediately available for use
by the system.
• The free command displays information about system memory, including the
total swap space, used swap space, and available swap space.
• Editing the /etc/fstab file allows you to define the swap space persistence
and configure the priority order of multiple swap devices or files.
• The free command displays information about swap usage, including the total
swap space, used swap space, and available swap space.
• Monitoring tools like top, htop, or vmstat can provide real-time insights into
system memory and swap usage.
Overall, swap space on Linux systems provides a vital mechanism for managing memory
resources and ensuring system stability even in memory-constrained situations.
Swap space in Linux is an area on a disk that is designated for use as virtual memory. It acts
as an extension to physical memory (RAM) and allows the operating system to swap out less
frequently used pages from RAM to the disk when the memory is under pressure. Creating a
dedicated swap partition is one way to allocate swap space in Linux. Here's a step-by-step
guide to creating a swap partition:
Note: The following steps assume you have administrative privileges on your Linux system.
1. Check available disk space: Use the df -h command to check the available disk space on
your system and identify the disk or partition where you want to create the swap partition.
2. Determine swap space size: Decide on the size of the swap partition you want to create.
The general recommendation is to allocate swap space equivalent to 1.5 to 2 times the size
of your RAM. For example, if you have 4 GB of RAM, you might allocate 6 to 8 GB of swap
space.
a. Open a terminal and run the following command to start the disk partitioning tool:
Replace /dev/sdX with the identifier of the disk where you want to create the swap partition
(e.g., /dev/sda).
b. Inside the fdisk prompt, type n and press Enter to create a new partition.
d. Specify the partition number. If it's the first partition, you can choose 1. For subsequent
partitions, choose an appropriate number.
e. Set the starting and ending sectors for the partition. You can either specify the exact size
in sectors or use default values to allocate the remaining disk space.
f. Set the partition type to "Linux swap" by typing t and pressing Enter, then selecting the
partition number and choosing the swap partition type code (82).
g. Type w and press Enter to save the changes and exit fdisk.
Run the following command to create a swap file system on the newly created swap
partition
Replace /dev/sdX1 with the appropriate identifier for your swap partition.
Open the /etc/fstab file in a text editor (e.g., sudo nano /etc/fstab) and add the following
entry at the end of the file to make the swap partition mount automatically on system
startup:
Run the command free -h to verify that the swap partition is active and available.
Congratulations! You have successfully created a swap partition in Linux. The system will
now use the swap space on the designated partition when necessary to support virtual
memory.