Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to repair a Linux kernel of Panic

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to fix a Panic Linux kernel, has a certain reference value, interested friends can refer to, I hope you have a lot of gains after reading this article, let Xiaobian take you to understand.

In order to configure a completely silent boot, he performed an improper mkinitcpio operation on Linux running on his work computer by ignoring a logic error in the mkinitcpio.conf file. This caused mkinitcpio to produce a new kernel file, but the kernel file did not work properly. On reboot, kernel boot halts in Panic state.

In general, when the new kernel does not work properly, you can temporarily boot the system by using the fallback version of the initramfs kernel file, or even overwrite the fallback version directly to roll back the changes, but this time the fatal is that mkinitcpio also modifies the vmlinuz kernel file, and vmlinuz does not have a fallback version. For the average user, you can simply reinstall the system; however, my workstation environment configuration is quite complex, which means that in addition to the possible loss of my working files, I need to spend a lot of extra time reconfiguring the development environment.

Note: The term "fix" in this tutorial means "attempt to roll back destructive human changes," so it should not be used to recover from an unexplained kernel crash.

Boot from LiveCD and view disk

With my experience working part-time as a Linux server operator, it immediately occurred to me that I could use LiveCD boot to get a temporary Linux environment for kernel repair.

I am using Arch Linux 64 bit version, so I started from Arch Linux LiveCD. After entering LiveCD's built-in root user correctly, we need to check the device name of our main hard drive. Execute fdisk -l. In my case, the device file corresponding to my primary hard disk, the partition mounted to the root directory, is/dev/sdb2.

Second, chroot to the system root directory on the hard disk

To chroot to the system root directory on the hard disk and be able to call the system components on the hard disk to make changes to the system on the hard disk normally, we must first manually mount the root partition on the hard disk. Execute (my device file is/dev/sdb2):

mount /dev/sdb2 /mnt

Not so fast. While chroot to/mnt can access the host bash on the hard drive, you can hardly complete any complex tasks correctly because there are important directories that are not mounted. We execute instructions to mount proc,/sys,/dev, and/run directories. Enter/mnt and execute separately:

mount -t proc proc proc/

mount --rbind /sys sys/

mount --rbind /dev dev/

mount --rbind /run run/

The roles of these directories are:

proc directory: Virtual Procfs file system for storing process state files (under Linux, these files appear to be text files, but are actually file mappings of process state);

/sys directory: for Arch Linux, this is a proc-like Sysfs virtual file system for storing device files connected to the system; for traditional Unix and Unix-like, it is a soft link to the kernel code tree;

/dev directory: store device files, such as your hard disk is/dev/sdXY and so on;

/run directory: stores part of the system information after the most recent startup;

After mounting these things, we can chroot to the root directory of our main hard disk:

chroot /mnt

Repentance medicine ++. For me, all I had to do was modify the mkinitcpio.conf file and redo the mkinitcpio operation to regenerate the correct kernel file. In general, this environment can solve most problems if a configuration error causes kernel Panic.

III. Some skills

1. Many configuration files have the correct version or template in the system in LiveCD. If you don't remember what they look like normally, you can refer to them.

2. For Arch Linux, you can directly use the pacstrap command to manage the package at/mnt without chrooting to/mnt;

3. It can be operated under two tty, so that files can still be transferred from LiveCD file system to/mnt after chroot to/mnt.

Thank you for reading this article carefully. I hope that the article "How to fix a Panic Linux kernel" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report