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.
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/
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.
Then you may see this error:
Press Enter or any key, and then you will see the following:
This is your kernel panic situation.
Step 2: Reboot your machine again and select the rescue prompt.
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
.
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>
3.3) List the /boot
directory contents again. The initramfs
file for the kernel is now created.
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.
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>
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.
저자 소개
Abhineet is an open source software fan, an automation enthusiast, and a music lover.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
오리지널 쇼
엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리
제품
- Red Hat Enterprise Linux
- Red Hat OpenShift Enterprise
- Red Hat Ansible Automation Platform
- 클라우드 서비스
- 모든 제품 보기
툴
체험, 구매 & 영업
커뮤니케이션
Red Hat 소개
Red Hat은 Linux, 클라우드, 컨테이너, 쿠버네티스 등을 포함한 글로벌 엔터프라이즈 오픈소스 솔루션 공급업체입니다. Red Hat은 코어 데이터센터에서 네트워크 엣지에 이르기까지 다양한 플랫폼과 환경에서 기업의 업무 편의성을 높여 주는 강화된 기능의 솔루션을 제공합니다.