SlideShare a Scribd company logo
1 of 33
Linux boot process and management
Grub and it’s pal Dracut
For FredLug September 2016
By Peter Larsen
Agenda
● Boot proces overview
– Bios
– UEFI
● Grub fundamentals
● Initramfs fundamentals
● Diagnosis
● Demos – how to fix a broken system
Boot process overview
● Bios
● UEFI
● Kernel
● Initrd
● Systemd
Boot: BIOS
Source: http://resources.infosecinstitute.com/uefi-and-tpm/
● Traditional/Old. 16Bit, 1MB
addressable space, limited
boot partition size
● “Blind” - easy to inject bad
code
● No real standards
● Very hardware
manufactorer dependent
● Basic UI
Boot: UEFI
● Unified Extensible Firmware Interface
● Trusted Boot
Source: http://www.antapex.org/diskdevices.htm
Bios/UEFI setup
● Pressing a key during boot (DEL, F1, F2 etc – depends on BIOS)
● # dmidecode
Show content of bios settings and discovered hardware
● # lspci
List hardware found on the PCI Bus
● # lsusb
List discovered USB devices
● # lscpu
List discovered CPUs and settings
● # lsscsi
List SCSI devices (most drives today show up as SCSI devices)
● Hardware vendors sometimes provide executables to change BIOS
settings.
Key BIOS/UEFI settings
● Boot Device / Boot Device Order
● ACPI – Advanced Configuration and Power
Interface
● CPU features – important for virtualization
● USB boot enabled/disabled
● UEFI mode – in this mode, each boot device
must be registered to be available. In secure
mode, they must be signed to be available.
Boot: Kernel
● Kernel is loaded into memory and executed
● Bulk of kernel is compressed and will be
uncompressed into specific memory locations.
● Memory and other structures are initialized
● Kernel modules are initialized – PCI and other busses
are found, initialized etc.
● Mounts root device (kernel parameter)
● Executes PID 1 /init -> systemd
● First systemd process is located on initramfs.
Kernel implementation
● Most people do not compile their own kernels
● Kernels are installed via rpm or deb packages
● Located in /boot
● Fedora/CentOS/RHEL puts /boot on a primary
partition of at least 512MB in size. Contains the
current and 2 other kernels.
● /boot is NOT a “bootable” partition in terms of
MBR (Microsoft terminology). The boot flag is
ignored by linux.
Kernel options
● Too many to list here – we’ll cover some in the other sections
● Install kernel-doc for /usr/share/doc/kernel* documentation
● https://www.kernel.org/doc/Documentation/kernel-parameters.txt
● Use Grub to change/set parameters – permanent changes goes
into grub.cfg
● Example (one long line):
kernel /vmlinuz-3.10.0-327.36.1.el7.x86_64
root=/dev/mapper/test-root ro crashkernel=auto
rd.lvm.lv=test/root rd.lvm.lv=test/swap rhgb quiet
LANG=en_US.UTF-8
Boot: Initramfs
● Dynamic kernel module initializer
● Ram disk image used to “kickstart” a system
● The kernel is very large, but would be enourmous if it
contained all device code statically.
● Instead the kernel loads modules based on devices
identified during startup.
● Since the kernel doesn’t have all devices needed for
boot, initramfs is required to initialize the right
modules, so the root device can be activated/read.
GRUB: GRand Unified Bootloader
● Legacy Grub is no more
● Grub2 Staged boot
● Loads Kernel
● Mounts ram disk (initramfs)
GRUB Boot process
● POST – Stage 1/1.5
– BIOS
● Finds bootable device and transfers control to MBR
● GPT/MBR contains stage 1, very small. Fits in less than 512bytes
● GRUB stage 1.5 is located in the first 30 KB of boot device immediately
following MBR.
● Stage 1.5 does better device discovery, supports larger partitions etc. and
passes control to Stage 2
– UEFI
● Loads UEFI boot system, mounts EFI partition, loads GRUB stage 2
● Stage 2
– Read Grub.cfg and displays menu and other actions.
– Grub executes the commands in the boot menu
/boot and /boot/efi
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 211MB 210MB fat16 EFI System Partition boot
2 211MB 525MB 315MB xfs
3 525MB 9663MB 9137MB lvm
● EFI is only used when UEFI is enabled. Mounted on
/boot/efi
● /boot is partition 2 – notice NOT a boot partition
● The rest can be partitions, LVM etc. - your choice.
/boot structure
/boot
├── efi
  │ └── EFI
  │ ├── BOOT
  │ └── redhat
  │ └── fonts
└── grub2
└── themes
└── system
● /boot/efi only exists when EFI was detected during
boot
● Grub themes are rather cool.
Install plymouth-theme-change to get cool graphics
on your boot menu!
Grub configuration commands
● # grub2-mkconfig
Create configuration/menu by scanning system for bootable images.
Will detect Windows and lots of different Linux distros and boot loaders
● # grubby
Command line tool for configuring grub. Very advanced. Using grub2-
install is a lot easier if you are looking to fix a boot problem. Can be used
to manually add menu items and set configuration options.
● # grub2-install <device>
Install grub (boot) on device. Injects stage1 and 1.5 boot loaders and
makes them refer to the boot device.
DO NOT USE IF YOU’RE USING EFI!
● # efibootmgr
Manage boot setup of EFI. List existing systems, reorder, add new
system, delete systems etc.
Configuration grub.cfg
● Located in /boot/grub2/ or /boot/efi/EFI/redhat
● Created using grub2-mkconfig
● If manually editing, use /etc/grub.d to add files,
then run grub2-mkconfig to generate a new
configuration.
Example configuration
menuentry 'Red Hat Enterprise Linux Server (3.10.0-
327.36.1.el7.x86_64) 7.2 (Maipo)' --class red --class
gnu-linux --class gnu --class os --unrestricted
$menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-
advanced-6e59c4d3-dbf6-4ba7-bd9e-7104482f66cd' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod xfs
linux /vmlinuz-3.10.0-327.36.1.el7.x86_64
root=/dev/mapper/test-root ro crashkernel=auto
rd.lvm.lv=test/root rd.lvm.lv=test/swap rhgb quiet
LANG=en_US.UTF-8
initrd /initramfs-3.10.0-327.36.1.el7.x86_64.img
}
Kernel: Linux begins!
● Fundamentals
– Processes
– Memory Management
– Device Management
– File systems
– Etc.
● Kernel starts PID 1 from root file system
Initramfs – managed by dracut
● Small root device loaded during boot right after
the kernel
● Created and managed using “dracut”
● Initramfs file located in /boot with kernel
● Must match kernel version
● “lsinitrd” shows/lists content of initramfs
● Extract all using zcat | cpio -i
Extract single file using “lsinitrd -f <file>”
Dracut
● Use modules to enable boot features
– Examples: lvm, mdraid, luks, iscsi etc.
● List all modules: dracut –list-modules
● If transposing to new hardware, you may need to
generate a new initramfs with modules fitting
the hardware
September 2016 Grub and Dracut
22
Customizing initramfs on boot
● LVM
– rd.lvm=0
disable LVM detection
– rd.lvm.vg=<volume group name>
only activate the volume groups with
the given name.
– rd.lvm.lv=<logical volume name>
only activate the logical volumes with
the given name.
– rd.lvm.conf=0
remove any /etc/lvm/lvm.conf, which
may exist in the initramfs
Diagnostics
● Grub Shell
● Initramfs Shell (RD)
● Emergency Shell
● Single User Mode (mode 1)
● MultiUser mode (non graphical) (mode 3)
● Graphical mode (mode 5)
Diagnostics: Grub Shell
● Configuration errors in grub.cfg is the most common
cause for going to the shell
● grub>
● The cfg file is nothing but a list of commands that the
grub-shell understands and executes.
● Basic commands to boot a system:
set root=’hd0,msdos1’
kernel /vmlinuz-<version> root=/dev/<root partition> ro
initrd /initramfs-<version>.img
boot
Diagnostics: Initramfs Shell (RD)
● Initramfs is very minimal and a bad shell to do recovery in. Use for
boot diagnostics, to see why a device isn’t found, responding etc.
● RD = Root Device
● Parameters are given on the kernel command line
– rd.break
Drop to shell
Options: cmdline, pre-udev, pre-mount, mount, cleanup
– rd.info
Print debug information
– rd.shell
Drop to shell if root mounting fails
– rd.udev.{info|debug}
Set udev to info/debug level in output
Diagnostics: Emergency Shell/Mode
● Starts minimal shell on a system where the root
device is mounted (ro).
● Full system command line options – but data
disks, network and other key features are not
enabled.
● Will prompt for root password!
● Kernel Parameter:
systemd.unit=emergency.target
Diagnostics: Systemd debug
● Systemd startup process has problems. Used to
debug services and other system management
features controlled by systemd.
● Advanced system diagnostics
● Kernel Parameter:
systemd.debug-shell
Diagnostics: Single User Mode (mode 1)
● Goes to shell after all core services are started.
Disks mounted, devices active etc. No network.
● Will prompt for root password!!
● Kernel Parameter:
systemd.target=rescue.target
Diagnostics: MultiUser mode (non graphical)
(mode 3)
● Full system running – no graphical sub
component. For most servers, this is the run
target for a normal running system.
● Network active
● Kernel parameter:
systemd.unit=multi-user.target
● Graphical subsystem does not start
● Primary services (web server, data volume) does
not start
Diagnostics: Install Disk/Recovery Boot
● Alternative: Use LiveUSB/CD
● Allows full access to root device, fsck of root device
and full recovery/repair
● Limited commands
– Full LVM
– Full File system support
– Bypass root password
● Potential selinux corruption – use with CARE!
– Always run “fixfiles onboot” if major changes are done to
files
Demo
● Show traditional BIOS boot system
● Show EFI system
● Recover boot failure
How to reset the root password
● The old tricks are no longer valid.
● Add rd.break to kernel command line
● Command line:
– # mount -o remount,rw /sysroot
– # chroot /sysroot
– # passwd
– # touch ./autorelabel
● Exit twice and system will reboot.
● Note, system will relabel ALL files on boot – and this will
take considerable time
Questions

More Related Content

What's hot

Group policy preferences
Group policy preferencesGroup policy preferences
Group policy preferencesRob Dunn
 
Oracle RAC on Extended Distance Clusters - Presentation
Oracle RAC on Extended Distance Clusters - PresentationOracle RAC on Extended Distance Clusters - Presentation
Oracle RAC on Extended Distance Clusters - PresentationMarkus Michalewicz
 
ODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live DiskODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live DiskRuggero Citton
 
PROPRIETARY AND OPEN SOURCE SOFTWARE
PROPRIETARY AND OPEN SOURCE SOFTWARE PROPRIETARY AND OPEN SOURCE SOFTWARE
PROPRIETARY AND OPEN SOURCE SOFTWARE Kak Yong
 
Reducing boot time in embedded Linux
Reducing boot time in embedded LinuxReducing boot time in embedded Linux
Reducing boot time in embedded LinuxChris Simmonds
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_TutorialVibhor Kumar
 
SQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tangoSQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tangoMauro Pagano
 
도커 없이 컨테이너 만들기 2편
도커 없이 컨테이너 만들기 2편도커 없이 컨테이너 만들기 2편
도커 없이 컨테이너 만들기 2편Sam Kim
 
Oracle EBS Upgrade to 12.2.5.1
Oracle EBS Upgrade to 12.2.5.1Oracle EBS Upgrade to 12.2.5.1
Oracle EBS Upgrade to 12.2.5.1Amit Sharma
 
Oracle E-Business Suite on Kubernetes Cluster
Oracle E-Business Suite on Kubernetes ClusterOracle E-Business Suite on Kubernetes Cluster
Oracle E-Business Suite on Kubernetes Clustervasuballa
 
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Andrejs Prokopjevs
 
Linux memory consumption
Linux memory consumptionLinux memory consumption
Linux memory consumptionhaish
 
DBA 3 year Interview Questions
DBA 3 year Interview QuestionsDBA 3 year Interview Questions
DBA 3 year Interview QuestionsNaveen P
 
Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?
Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?
Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?Koan-Sin Tan
 
Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)Brendan Gregg
 
RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkJohn Dalsgaard
 
Monitoring kubernetes with prometheus
Monitoring kubernetes with prometheusMonitoring kubernetes with prometheus
Monitoring kubernetes with prometheusBrice Fernandes
 

What's hot (20)

Group policy preferences
Group policy preferencesGroup policy preferences
Group policy preferences
 
Oracle RAC on Extended Distance Clusters - Presentation
Oracle RAC on Extended Distance Clusters - PresentationOracle RAC on Extended Distance Clusters - Presentation
Oracle RAC on Extended Distance Clusters - Presentation
 
Memory management in linux
Memory management in linuxMemory management in linux
Memory management in linux
 
ODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live DiskODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live Disk
 
PROPRIETARY AND OPEN SOURCE SOFTWARE
PROPRIETARY AND OPEN SOURCE SOFTWARE PROPRIETARY AND OPEN SOURCE SOFTWARE
PROPRIETARY AND OPEN SOURCE SOFTWARE
 
Reducing boot time in embedded Linux
Reducing boot time in embedded LinuxReducing boot time in embedded Linux
Reducing boot time in embedded Linux
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
PGEncryption_Tutorial
PGEncryption_TutorialPGEncryption_Tutorial
PGEncryption_Tutorial
 
SQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tangoSQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tango
 
도커 없이 컨테이너 만들기 2편
도커 없이 컨테이너 만들기 2편도커 없이 컨테이너 만들기 2편
도커 없이 컨테이너 만들기 2편
 
Oracle EBS Upgrade to 12.2.5.1
Oracle EBS Upgrade to 12.2.5.1Oracle EBS Upgrade to 12.2.5.1
Oracle EBS Upgrade to 12.2.5.1
 
Oracle E-Business Suite on Kubernetes Cluster
Oracle E-Business Suite on Kubernetes ClusterOracle E-Business Suite on Kubernetes Cluster
Oracle E-Business Suite on Kubernetes Cluster
 
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
Optimize DR and Cloning with Logical Hostnames in Oracle E-Business Suite (OA...
 
Linux memory consumption
Linux memory consumptionLinux memory consumption
Linux memory consumption
 
4. linux file systems
4. linux file systems4. linux file systems
4. linux file systems
 
DBA 3 year Interview Questions
DBA 3 year Interview QuestionsDBA 3 year Interview Questions
DBA 3 year Interview Questions
 
Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?
Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?
Why You Cannot Use Neural Engine to Run Your NN Models on A11 Devices?
 
Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)Computing Performance: On the Horizon (2021)
Computing Performance: On the Horizon (2021)
 
RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWork
 
Monitoring kubernetes with prometheus
Monitoring kubernetes with prometheusMonitoring kubernetes with prometheus
Monitoring kubernetes with prometheus
 

Similar to Grub and dracut ii

Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)Peter Martin
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Opersys inc.
 
The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)plarsen67
 
How to install gentoo distributed
How to install gentoo distributedHow to install gentoo distributed
How to install gentoo distributedSongWang54
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System AdministrationSreenatha Reddy K R
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embeddedAlison Chaiken
 
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606Eunice Lin
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedureDhaval Kaneria
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot processHari Shankar
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot processsagarpdalvi
 

Similar to Grub and dracut ii (20)

An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
101 1.2 boot the system
101 1.2 boot the system101 1.2 boot the system
101 1.2 boot the system
 
Understanding The Boot Process
Understanding The Boot ProcessUnderstanding The Boot Process
Understanding The Boot Process
 
Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)Basis Linux (aan de hand van LPIC-1)
Basis Linux (aan de hand van LPIC-1)
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Linux
LinuxLinux
Linux
 
The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)The ABC of Linux (Linux for Beginners)
The ABC of Linux (Linux for Beginners)
 
How to install gentoo distributed
How to install gentoo distributedHow to install gentoo distributed
How to install gentoo distributed
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
Tuning systemd for embedded
Tuning systemd for embeddedTuning systemd for embedded
Tuning systemd for embedded
 
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
 
Linux booting procedure
Linux booting procedureLinux booting procedure
Linux booting procedure
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot process
 
Linux boot process
Linux boot processLinux boot process
Linux boot process
 
Linux basics
Linux basics Linux basics
Linux basics
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot process
 
Linux basics
Linux basics Linux basics
Linux basics
 

More from plarsen67

Containers in a Kubernetes World
Containers in a Kubernetes WorldContainers in a Kubernetes World
Containers in a Kubernetes Worldplarsen67
 
FREDLUG - Open Broadcast Studio - OBS
FREDLUG - Open Broadcast Studio - OBSFREDLUG - Open Broadcast Studio - OBS
FREDLUG - Open Broadcast Studio - OBSplarsen67
 
Bash and regular expressions
Bash and regular expressionsBash and regular expressions
Bash and regular expressionsplarsen67
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linuxplarsen67
 
Open Source - NOVALUG January 2019
Open Source  - NOVALUG January 2019Open Source  - NOVALUG January 2019
Open Source - NOVALUG January 2019plarsen67
 
Kvm and libvirt
Kvm and libvirtKvm and libvirt
Kvm and libvirtplarsen67
 
JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)plarsen67
 
Open shift 2.x and MongoDB
Open shift 2.x and MongoDBOpen shift 2.x and MongoDB
Open shift 2.x and MongoDBplarsen67
 
Fredlug networking
Fredlug networkingFredlug networking
Fredlug networkingplarsen67
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystemsplarsen67
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linuxplarsen67
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystemsplarsen67
 
Intro fredlug
Intro fredlugIntro fredlug
Intro fredlugplarsen67
 
Lvm and gang 2015
Lvm and gang 2015Lvm and gang 2015
Lvm and gang 2015plarsen67
 
Bash and regular expressions
Bash and regular expressionsBash and regular expressions
Bash and regular expressionsplarsen67
 
Speed Up Development With OpenShift
Speed Up Development With OpenShiftSpeed Up Development With OpenShift
Speed Up Development With OpenShiftplarsen67
 

More from plarsen67 (17)

Containers in a Kubernetes World
Containers in a Kubernetes WorldContainers in a Kubernetes World
Containers in a Kubernetes World
 
FREDLUG - Open Broadcast Studio - OBS
FREDLUG - Open Broadcast Studio - OBSFREDLUG - Open Broadcast Studio - OBS
FREDLUG - Open Broadcast Studio - OBS
 
Bash and regular expressions
Bash and regular expressionsBash and regular expressions
Bash and regular expressions
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Open Source - NOVALUG January 2019
Open Source  - NOVALUG January 2019Open Source  - NOVALUG January 2019
Open Source - NOVALUG January 2019
 
3d printing
3d printing3d printing
3d printing
 
Kvm and libvirt
Kvm and libvirtKvm and libvirt
Kvm and libvirt
 
JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)JBoss Enterprise Data Services (Data Virtualization)
JBoss Enterprise Data Services (Data Virtualization)
 
Open shift 2.x and MongoDB
Open shift 2.x and MongoDBOpen shift 2.x and MongoDB
Open shift 2.x and MongoDB
 
Fredlug networking
Fredlug networkingFredlug networking
Fredlug networking
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystems
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Disks and-filesystems
Disks and-filesystemsDisks and-filesystems
Disks and-filesystems
 
Intro fredlug
Intro fredlugIntro fredlug
Intro fredlug
 
Lvm and gang 2015
Lvm and gang 2015Lvm and gang 2015
Lvm and gang 2015
 
Bash and regular expressions
Bash and regular expressionsBash and regular expressions
Bash and regular expressions
 
Speed Up Development With OpenShift
Speed Up Development With OpenShiftSpeed Up Development With OpenShift
Speed Up Development With OpenShift
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

Grub and dracut ii

  • 1. Linux boot process and management Grub and it’s pal Dracut For FredLug September 2016 By Peter Larsen
  • 2. Agenda ● Boot proces overview – Bios – UEFI ● Grub fundamentals ● Initramfs fundamentals ● Diagnosis ● Demos – how to fix a broken system
  • 3. Boot process overview ● Bios ● UEFI ● Kernel ● Initrd ● Systemd
  • 4. Boot: BIOS Source: http://resources.infosecinstitute.com/uefi-and-tpm/ ● Traditional/Old. 16Bit, 1MB addressable space, limited boot partition size ● “Blind” - easy to inject bad code ● No real standards ● Very hardware manufactorer dependent ● Basic UI
  • 5. Boot: UEFI ● Unified Extensible Firmware Interface ● Trusted Boot Source: http://www.antapex.org/diskdevices.htm
  • 6. Bios/UEFI setup ● Pressing a key during boot (DEL, F1, F2 etc – depends on BIOS) ● # dmidecode Show content of bios settings and discovered hardware ● # lspci List hardware found on the PCI Bus ● # lsusb List discovered USB devices ● # lscpu List discovered CPUs and settings ● # lsscsi List SCSI devices (most drives today show up as SCSI devices) ● Hardware vendors sometimes provide executables to change BIOS settings.
  • 7. Key BIOS/UEFI settings ● Boot Device / Boot Device Order ● ACPI – Advanced Configuration and Power Interface ● CPU features – important for virtualization ● USB boot enabled/disabled ● UEFI mode – in this mode, each boot device must be registered to be available. In secure mode, they must be signed to be available.
  • 8. Boot: Kernel ● Kernel is loaded into memory and executed ● Bulk of kernel is compressed and will be uncompressed into specific memory locations. ● Memory and other structures are initialized ● Kernel modules are initialized – PCI and other busses are found, initialized etc. ● Mounts root device (kernel parameter) ● Executes PID 1 /init -> systemd ● First systemd process is located on initramfs.
  • 9. Kernel implementation ● Most people do not compile their own kernels ● Kernels are installed via rpm or deb packages ● Located in /boot ● Fedora/CentOS/RHEL puts /boot on a primary partition of at least 512MB in size. Contains the current and 2 other kernels. ● /boot is NOT a “bootable” partition in terms of MBR (Microsoft terminology). The boot flag is ignored by linux.
  • 10. Kernel options ● Too many to list here – we’ll cover some in the other sections ● Install kernel-doc for /usr/share/doc/kernel* documentation ● https://www.kernel.org/doc/Documentation/kernel-parameters.txt ● Use Grub to change/set parameters – permanent changes goes into grub.cfg ● Example (one long line): kernel /vmlinuz-3.10.0-327.36.1.el7.x86_64 root=/dev/mapper/test-root ro crashkernel=auto rd.lvm.lv=test/root rd.lvm.lv=test/swap rhgb quiet LANG=en_US.UTF-8
  • 11. Boot: Initramfs ● Dynamic kernel module initializer ● Ram disk image used to “kickstart” a system ● The kernel is very large, but would be enourmous if it contained all device code statically. ● Instead the kernel loads modules based on devices identified during startup. ● Since the kernel doesn’t have all devices needed for boot, initramfs is required to initialize the right modules, so the root device can be activated/read.
  • 12. GRUB: GRand Unified Bootloader ● Legacy Grub is no more ● Grub2 Staged boot ● Loads Kernel ● Mounts ram disk (initramfs)
  • 13. GRUB Boot process ● POST – Stage 1/1.5 – BIOS ● Finds bootable device and transfers control to MBR ● GPT/MBR contains stage 1, very small. Fits in less than 512bytes ● GRUB stage 1.5 is located in the first 30 KB of boot device immediately following MBR. ● Stage 1.5 does better device discovery, supports larger partitions etc. and passes control to Stage 2 – UEFI ● Loads UEFI boot system, mounts EFI partition, loads GRUB stage 2 ● Stage 2 – Read Grub.cfg and displays menu and other actions. – Grub executes the commands in the boot menu
  • 14. /boot and /boot/efi Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 211MB 210MB fat16 EFI System Partition boot 2 211MB 525MB 315MB xfs 3 525MB 9663MB 9137MB lvm ● EFI is only used when UEFI is enabled. Mounted on /boot/efi ● /boot is partition 2 – notice NOT a boot partition ● The rest can be partitions, LVM etc. - your choice.
  • 15. /boot structure /boot ├── efi   │ └── EFI   │ ├── BOOT   │ └── redhat   │ └── fonts └── grub2 └── themes └── system ● /boot/efi only exists when EFI was detected during boot ● Grub themes are rather cool. Install plymouth-theme-change to get cool graphics on your boot menu!
  • 16. Grub configuration commands ● # grub2-mkconfig Create configuration/menu by scanning system for bootable images. Will detect Windows and lots of different Linux distros and boot loaders ● # grubby Command line tool for configuring grub. Very advanced. Using grub2- install is a lot easier if you are looking to fix a boot problem. Can be used to manually add menu items and set configuration options. ● # grub2-install <device> Install grub (boot) on device. Injects stage1 and 1.5 boot loaders and makes them refer to the boot device. DO NOT USE IF YOU’RE USING EFI! ● # efibootmgr Manage boot setup of EFI. List existing systems, reorder, add new system, delete systems etc.
  • 17. Configuration grub.cfg ● Located in /boot/grub2/ or /boot/efi/EFI/redhat ● Created using grub2-mkconfig ● If manually editing, use /etc/grub.d to add files, then run grub2-mkconfig to generate a new configuration.
  • 18. Example configuration menuentry 'Red Hat Enterprise Linux Server (3.10.0- 327.36.1.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64- advanced-6e59c4d3-dbf6-4ba7-bd9e-7104482f66cd' { load_video set gfxpayload=keep insmod gzio insmod part_gpt insmod xfs linux /vmlinuz-3.10.0-327.36.1.el7.x86_64 root=/dev/mapper/test-root ro crashkernel=auto rd.lvm.lv=test/root rd.lvm.lv=test/swap rhgb quiet LANG=en_US.UTF-8 initrd /initramfs-3.10.0-327.36.1.el7.x86_64.img }
  • 19. Kernel: Linux begins! ● Fundamentals – Processes – Memory Management – Device Management – File systems – Etc. ● Kernel starts PID 1 from root file system
  • 20. Initramfs – managed by dracut ● Small root device loaded during boot right after the kernel ● Created and managed using “dracut” ● Initramfs file located in /boot with kernel ● Must match kernel version ● “lsinitrd” shows/lists content of initramfs ● Extract all using zcat | cpio -i Extract single file using “lsinitrd -f <file>”
  • 21. Dracut ● Use modules to enable boot features – Examples: lvm, mdraid, luks, iscsi etc. ● List all modules: dracut –list-modules ● If transposing to new hardware, you may need to generate a new initramfs with modules fitting the hardware
  • 22. September 2016 Grub and Dracut 22 Customizing initramfs on boot ● LVM – rd.lvm=0 disable LVM detection – rd.lvm.vg=<volume group name> only activate the volume groups with the given name. – rd.lvm.lv=<logical volume name> only activate the logical volumes with the given name. – rd.lvm.conf=0 remove any /etc/lvm/lvm.conf, which may exist in the initramfs
  • 23. Diagnostics ● Grub Shell ● Initramfs Shell (RD) ● Emergency Shell ● Single User Mode (mode 1) ● MultiUser mode (non graphical) (mode 3) ● Graphical mode (mode 5)
  • 24. Diagnostics: Grub Shell ● Configuration errors in grub.cfg is the most common cause for going to the shell ● grub> ● The cfg file is nothing but a list of commands that the grub-shell understands and executes. ● Basic commands to boot a system: set root=’hd0,msdos1’ kernel /vmlinuz-<version> root=/dev/<root partition> ro initrd /initramfs-<version>.img boot
  • 25. Diagnostics: Initramfs Shell (RD) ● Initramfs is very minimal and a bad shell to do recovery in. Use for boot diagnostics, to see why a device isn’t found, responding etc. ● RD = Root Device ● Parameters are given on the kernel command line – rd.break Drop to shell Options: cmdline, pre-udev, pre-mount, mount, cleanup – rd.info Print debug information – rd.shell Drop to shell if root mounting fails – rd.udev.{info|debug} Set udev to info/debug level in output
  • 26. Diagnostics: Emergency Shell/Mode ● Starts minimal shell on a system where the root device is mounted (ro). ● Full system command line options – but data disks, network and other key features are not enabled. ● Will prompt for root password! ● Kernel Parameter: systemd.unit=emergency.target
  • 27. Diagnostics: Systemd debug ● Systemd startup process has problems. Used to debug services and other system management features controlled by systemd. ● Advanced system diagnostics ● Kernel Parameter: systemd.debug-shell
  • 28. Diagnostics: Single User Mode (mode 1) ● Goes to shell after all core services are started. Disks mounted, devices active etc. No network. ● Will prompt for root password!! ● Kernel Parameter: systemd.target=rescue.target
  • 29. Diagnostics: MultiUser mode (non graphical) (mode 3) ● Full system running – no graphical sub component. For most servers, this is the run target for a normal running system. ● Network active ● Kernel parameter: systemd.unit=multi-user.target ● Graphical subsystem does not start ● Primary services (web server, data volume) does not start
  • 30. Diagnostics: Install Disk/Recovery Boot ● Alternative: Use LiveUSB/CD ● Allows full access to root device, fsck of root device and full recovery/repair ● Limited commands – Full LVM – Full File system support – Bypass root password ● Potential selinux corruption – use with CARE! – Always run “fixfiles onboot” if major changes are done to files
  • 31. Demo ● Show traditional BIOS boot system ● Show EFI system ● Recover boot failure
  • 32. How to reset the root password ● The old tricks are no longer valid. ● Add rd.break to kernel command line ● Command line: – # mount -o remount,rw /sysroot – # chroot /sysroot – # passwd – # touch ./autorelabel ● Exit twice and system will reboot. ● Note, system will relabel ALL files on boot – and this will take considerable time