Linux Day5
Linux Day5
Azza Khalel
[email protected]
Azza Khalel | LinkedIn
Day5 contents
• Boot process
• Managing system services
• Package management
• rpm
• yum
• dnf
• Scheduling
• cron
• At
• Storage administration
Linux boot sequence
• BIOS (Basic Input/Output System) / UEFI (Unified Extensible Firmware Interface)
• When you first turn on your computer, BIOS or UEFI SW boots up from ROM.
• the BIOS first performs some integrity checks called POST to make sure all HW are working right.
• If POST finds a problem, it will often show an error message on the screen
• Then, the BIOS searches for, loads, and executes the boot loader program (GRUB2, LILO),
• MBR (Master Boot Record) / .efi boot loader
• ON BIOS, the boot loader can be found in the Master Boot Record (MBR) which located in the 1st sector (512 MB) of the
bootable disk
• ON UEFI, there is a separate partition that stores files like .efi boot loader file
• Once the boot loader program is detected, it's then loaded into memory and the BIOS gives control of the system to it.
• The MBR contains information about GRUB, or LILO in very old systems.
• GRUB2 (GNU GRand Unified Bootloader) / LILO
• LILO, the linux loader is pretty outdated and rarely used in modern distributions.
• GRUB2 is the most full-featured and widely used today,
• it can handle booting multiple OS
• Looks nice with graphical or text-based menus and has a bunch of advanced options for users.
• Once GRUB2 loads itself up, it inserts the linux kernel into memory and hands control over to the kernel to finish the start
up process.
• The GRUB splash screen is often the first thing you see when you boot your computer. It has a simple menu where you can
select some options. If you have multiple kernel images installed, you can use your keyboard to select the one you want
your system to boot with. By default, the latest kernel image is selected.
• The splash screen will wait a few seconds for you to select and option. If you don't, it will load the default kernel image.
• In many systems you can find the GRUB configuration file at /boot/grub/grub.conf or /etc/grub.conf.
• Kernel
Linux boot sequence
• The kernel is often referred to as the core of any operating system, Linux included. It has
complete control over everything in your system.
• After the boot loader starts the kernel, the kernel takes over the computer recourses and
start initialization of all the background processes and services.
• First, it decompress itself into RAM, check the HW and loads device drivers and other kernel
modules
• Next, an initial process called systemd kicks off.
• The kernel then establishes a temporary root file system using Initial RAM Disk (initrd) until
the real file system is mounted.
• Services (systemd)
• Systemd has a ton of responsibilities to get the system booted and ready to use
• It is checking for any remaining HW that needs drivers loaded.
• It mounts up your file system and disks so they are accessible
• It starts launching all the background services you need like networking, sound, power mang.
• Systemd starts all services that should be started on the system and on the selected target.
• Reads files from /etc/systemd/system
Linux boot sequence
Controlling services and demons
• Systemd is the first process to start (PID1).
• Systemd demon manages startup for linux including service start up and service management in general.
• Systemd activates system resources, server demons and other processes both at boot time and on a running system.
• Listing service units
• #systemctl list-units –-type=service ➔ to list all active services
• systemctl reload sshd.service ➔ just reload the config files without stopping the service
• RPM used to install a package which already downloaded without any dependencies
• To download a package
• #wget <package_URL>
• YUM (Yellowdog Updater, Modified)
• Its designed to be a better system for managing rpm-based packages
• Its used to download and install any package with all its dependencies
• It uses repository concept.
• Starting from RHEL8, ther are 2 main repos
• BaseOS (all OS related packages)
• AppStream (any other packages)
• From file
• #dd if=/dev/zero of=/myswap bs=1024byte count=512000 ➔ to create a new file with
size 1024*512000=512MB, named /myswap
• mkswap /myswap
• swapon /myswap
LVM (Logical Volume Manager)
• If the HD was partitioned and then want to extend its size, These partitions
should be LVM to apply that.
• Partitions’ type should be LVM
• Then convert them to physical volumes.
• Put all physical volumes in a volume group.
• Then we can partition this volume group to logical volumes.
• Mount these logical volumes on your system; it will be your system partitions.
• Here, Data is stored in an extent, before that in the normal partition data is
stored in blocks.
LVM
• Create a partition
• #fdisk /dev/sda n p t 8e :wq
• Make physical volume
• #pvcreate /dev/sda1 #pvs #pvdisplay #pvdisplay /dev/sda1 #pvremove /dev/sda1
• Create volume group
• #vgcreate vg0 /dev/sda1 /dev/sda2 #vgs vgdisplay #vgremove vg0
• Create logical volume
• #lvcreate -L +50G -n lv0 vg0 #lvs #lvdisplay #lvremove lv0
• Make file system
• #mkfs.ext3 /dev/vg0/lv0
• mount and fstab
• #mount /dev/vg0/lv0 /part1
• #vi /etc/fstab
/dev/vg0/lv0 /part1 ext3 defaults 0 0
• #vgextend vg0 /dev/sdb ➔ will create a PV from this disk and expand the VG
• #vgreduce vg0 /dev/sda3
• #lvextend -r -L +10G lv0 ➔ will add 10G to this lvm and –r to extend the XFS File
system
• #lvextend –r –L 10G lv0 ➔ this will set this lvm to be 10G
• #resize2fs /dev/vg1/lv0
• #lvreduce -L -10G lv0