Linux is used everywhere in the IT world. You've probably used Linux today, even if you didn't realize it. If you have learned anything about Linux, then you know it is indeed a kernel. The kernel is the primary unit of the Linux operating system (OS) and is responsible for communications between a computer's hardware and its processes.
In this article, you will learn about one situation related to the Linux kernel: The kernel panic. The term itself can make you panic, but if you have the proper knowledge, then you can remain calm. Every system admin faces this issue at least once in their career, but reinstalling the system is not the first solution you should turn to.
![Kernel panic screen with phrase "What do you do in case of Kernel Panic?"](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/1WhatToDo.png.webp?itok=ncN5v0X7)
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.
![Linux kernel panic crash screen](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/2KernelPanic.png.webp?itok=eteJk0hU)
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/
![Output of the ls command for the boot directory, with callouts for the kernel file and the initramfs file](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/3ls-lrth.png.webp?itok=ZRCA0z__)
This process emphasizes the importance of initramfs
/initrd
in the Linux boot process.
Why do kernel panics occur?
Kernel panics occur:
- If the
initramfs
file gets corrupted. - If
initramfs
is not created properly for the specified kernel. Every kernel version has its own correspondinginitramfs
. - If the installed kernel is not supported or not installed correctly.
- If recent patches have some flaws.
- 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.
![Linux OS menu screen](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/4boot.png.webp?itok=7JQlBzaY)
Then you may see this error:
![Error screen indicating /initramfs file not found](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/5initramfs-not-found.png.webp?itok=GWD0BeTQ)
Press Enter or any key, and then you will see the following:
![Linux kernel panic crash screen](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/6kernel-panic.png.webp?itok=AlrWgkoC)
This is your kernel panic situation.
Step 2: Reboot your machine again and select the rescue prompt.
![Linux OS menu screen with the rescue image selected](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/7boot-rescue.png.webp?itok=JsKHMAP7)
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
.
![Output of the ls command for the boot directory, with the initramfs file missing](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/8cd-boot.png.webp?itok=0wraeHJc)
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>
![Output of the uname -r command displaying the kernel version](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/9uname-r.png.webp?itok=cQsGVUo-)
3.3) List the /boot
directory contents again. The initramfs
file for the kernel is now created.
![Output of the ls command for the boot directory, with a callout for the new initramfs file](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/10cd-boot-new-initramfs.png.webp?itok=RnazR2F1)
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.
![Output of the dracut command](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/11dracut.png.webp?itok=0YQ-7RuL)
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>
![Output of the mkinitrd --force command](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2020-11/12mkinitrd.png.webp?itok=d39GPY2i)
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.
Sobre o autor
Abhineet is an open source software fan, an automation enthusiast, and a music lover.
Navegue por canal
Automação
Últimas novidades em automação de TI para empresas de tecnologia, equipes e ambientes
Inteligência artificial
Descubra as atualizações nas plataformas que proporcionam aos clientes executar suas cargas de trabalho de IA em qualquer ambiente
Nuvem híbrida aberta
Veja como construímos um futuro mais flexível com a nuvem híbrida
Segurança
Veja as últimas novidades sobre como reduzimos riscos em ambientes e tecnologias
Edge computing
Saiba quais são as atualizações nas plataformas que simplificam as operações na borda
Infraestrutura
Saiba o que há de mais recente na plataforma Linux empresarial líder mundial
Aplicações
Conheça nossas soluções desenvolvidas para ajudar você a superar os desafios mais complexos de aplicações
Programas originais
Veja as histórias divertidas de criadores e líderes em tecnologia empresarial
Produtos
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Red Hat Cloud Services
- Veja todos os produtos
Ferramentas
- Treinamento e certificação
- Minha conta
- Suporte ao cliente
- Recursos para desenvolvedores
- Encontre um parceiro
- Red Hat Ecosystem Catalog
- Calculadora de valor Red Hat
- Documentação
Experimente, compre, venda
Comunicação
- Contate o setor de vendas
- Fale com o Atendimento ao Cliente
- Contate o setor de treinamento
- Redes sociais
Sobre a Red Hat
A Red Hat é a líder mundial em soluções empresariais open source como Linux, nuvem, containers e Kubernetes. Fornecemos soluções robustas que facilitam o trabalho em diversas plataformas e ambientes, do datacenter principal até a borda da rede.
Selecione um idioma
Red Hat legal and privacy links
- Sobre a Red Hat
- Oportunidades de emprego
- Eventos
- Escritórios
- Fale com a Red Hat
- Blog da Red Hat
- Diversidade, equidade e inclusão
- Cool Stuff Store
- Red Hat Summit