-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinux troubleshooting
More file actions
83 lines (67 loc) · 4.16 KB
/
Copy pathLinux troubleshooting
File metadata and controls
83 lines (67 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
https://www.redhat.com/sysadmin/linux-kernel-panic
What is a kernel panic?
A kernel panic is one of several Linux boot issues.
In basic terms, it is a situation when the kernel can't load properly and therefore the system fails to boot.
During the boot process, the kernel doesn't load directly. Instead, initramfs loads in RAM,
then it points to the kernel (vmlinuz), and then the operating system boots.
If initramfs gets corrupted or deleted at this stage because of recent OS patching,
updates, or other causes, then we face a kernel panic.

If we dig into the boot process more, then we encounter the Linux "chicken/egg problem."
[ Readers also liked: Terminals, shells, consoles, and command lines ]
When a Linux system boot process starts after the Master Boot Record (MBR) step, GRUB is loaded.
The kernel needs to be loaded into RAM to start the OS, but the kernel is situated on the hard disk (/boot/vmlinuz),
and the hard disk is not yet mounted on /. Without mounting, no files can be accessed, even the kernel. To overcome this,
first initramfs/initrd loads in RAM directly and mounts the /boot partition in read-only mode.
Next, it mounts the hard disk on the / partition, and the process continues.
# ls -lrth /boot/
Image
This process emphasizes the importance of initramfs/initrd in the Linux boot process.
Why do kernel panics occur?
Kernel panics occur:
1. If the initramfs file gets corrupted.
2. If initramfs is not created properly for the specified kernel. Every kernel version has its own corresponding initramfs.
3. If the installed kernel is not supported or not installed correctly.
4. If recent patches have some flaws.
5. If a module has been installed from online or another source, but the initrd image is not created with the latest installed module.
How to troubleshoot?
The first thing to do after seeing a kernel panic error is not to panic ,because now you are aware of the image file related to the error.
Step 1: Boot the system normally with your given kernel version.
Image
Then you may see this error:
Image
Press Enter or any key, and then you will see the following:
Image
This is your kernel panic situation.
Step 2: Reboot your machine again and select the rescue prompt.
Image
In RHEL 6 or earlier versions, we do not have this option, but in RHEL 7 and onwards, we have a built-in rescue image.
This image boots your OS normally.
Step 2.1: Go to /boot and list all files. Here you will see there is no initramfs file for your kernel,
but there is an initramfs file for rescue by which you have booted your system, and another is for kdump.
Image
The initramfs for the kernel is missing.
Step 3: You will need to create a new initramfs file that corresponds to your kernel version.
Step 3.1: First check your kernel version:
#uname -r
Step 3.2: Next, run the dracut command:
#dracut -f <initrd-image> <kernal-version>
Image
3.3) List the /boot directory contents again. The initramfs file for the kernel is now created.
Image
Step 4: Now, when you boot normally, your machine starts without a kernel panic error.
Step 5: There might be a situation that occurs when you boot your system with a rescue image
with creating a new initramfs file where you couldn't make a new file because it was already present.
Image
At this point, we need to create an initramfs image with the mkinitrd command or dracut command.
Step 5.1: Check your kernel version first using the uname -r command.
Step 5.2: Run the mkinitrd command with the --force option and your kernel specification:
#mkinitrd --force <initrd-Image> <Kernel-Version>
Image
Your initramfs file is regenerated by these short steps, and you can now start your OS without any errors.
[ Free ebook: Manage your Linux environment for success ]
Wrapping up
Now, anytime you see a kernel panic error, you will definitely not panic because you know why this
error occurred and how to resolve it. This article covers one of the common Linux boot problems: kernel panic.
There are so many other potential boot problems that can occur in Linux, but resolving those issues will become
much less of a panic when you gain some advanced knowledge of your system.