-
Notifications
You must be signed in to change notification settings - Fork 12
Linux Kernel
kimschles edited this page Apr 11, 2019
·
3 revisions
How Linux Works
Process Management
- A process is an instance of a program
- Starting, stopping, resuming and terminating a process
Memory Managment Device Drivers and Management
Linux Programming Interface
Process Scheduling Memory Management Provision a File System Creation and Termination of Processes Access to Devices Networking Provision a system API
-
init
runs shell scripts that live in/etc
- Those scripts are called init scripts
- Most of those services as daemon programs that run in the background
- Parent process vs. child process
- PID -> process id
- pids are assigned in ascending order
-
init
is always pid 1
-
ps
shows the processes associated with the current terminal sesion-
TTY
is teletype -
TIME
the amount of CPU time consumed by a process
-
-
ps x
is a way to see processes no matter which terminal-
STAT
is state
-
-
ps aux
shows processes belonging to every user -
top
is a way to look at processes over time (ps
is a snapshot of what is happening in the moment the commandf is run)
-
ctcl-C
is a 'polite' way to ask the program to stoip -
To start a process and put it in the backgroup immediately, run the command and add
&
- example:
kwrite &
- example:
-
jobs
shows you jobs that are running -
fg
lets you return a process to the foreground-
fg %1
kills a job if there is only one running in the background
-
-
jobspec:
%1
-
kill
is used to terminate a process killall
Questions I have:
- How are UNIX and Linux related?
- What is a driver?
Chapter 5: How the Linux Kernel Boots
- To see the startup messages, find the kernel system log file.
-
/var/log/kern.log
or/var/log/messages
-
- the
dmesg
command
- First the kernel boots, then the user space boots
The kernel initializes roughly in this order:
- CPU inspection
- Memory inspection
- Device bus discovery
- Device discovery
- Auxiliary kernel subsystem setup (networking, and so on)
- Root filesystem mount
- User space start
From the LinkedIn Linux: Kernels and Logging for System Administration course:
- Firmware stage
- Boot loader stage
- Kernel stage
- Initialization stage
- kernel parameters are key value pairs like
console=tty1
or one-word flags likero
- view the kernel parameters at
/proc/cmdline
- example
cmdline
cat file:BOOT_IMAGE=/boot/vmlinuz-4.15.0-1032-aws root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295
- example
- some kernel paramters of note:
-
root
specifies the location of the root filesystem -
ro
means read-only
-
- There are different boot loaders, but we're looking at GRUB (Grand Unified Boot Loader)
- The other common boot loader is Unified Extensible Firmware Interface (UEFI)
- The main task of a boot loader is to select the kernel image and assign a value to the
root
parameter - [Understanding the Linux boot process] (https://www.linkedin.com/learning/linux-kernels-and-logging-for-system-administration/understanding-the-linux-boot-process)
- The boot loader loads the kernel into memory
- The kernel and kernel parameters are usually in the root filesystem
- BIOS = Basic Input/Output System
- GRUB
- `/boot/grub/grub.cfg
-
Ubuntu GRUB
-
/etc/default/grub
from AWS Ubuntu:
-
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"```